找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1293|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 c5 a+ j8 d; n- u M5 A5 j8 a. S" G j
回复

使用道具 举报

 楼主| 发表于 2007-5-9 13:57:40 | 显示全部楼层
没人懂吗?
回复

使用道具 举报

发表于 2007-5-9 13:58:19 | 显示全部楼层
偶懂一点点点
回复

使用道具 举报

 楼主| 发表于 2007-5-9 13:58:55 | 显示全部楼层
我在做作业啊...遇到不会的问下你..
回复

使用道具 举报

发表于 2007-5-9 14:00:01 | 显示全部楼层
还给老师了
回复

使用道具 举报

发表于 2007-5-9 14:00:25 | 显示全部楼层
我晕到,做JAVA的作业啊  ,你学啥子的
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:00:46 | 显示全部楼层
问下,如果有两个.java的文件,这两个文件有相似性...我们的要求是写一个另外的java程序,然后可以载如 这两个java文件,进行code的逐行对比,然后列出相似的行和相似内容,应该用什么类
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:11 | 显示全部楼层
//*********************************************************************
- }. z: i0 R! q9 u& V. j0 M//  ProgramCompare.java         Provided by: DRS
; R& N( U2 Y3 D3 }0 C//
2 O4 u6 Q; G1 v1 x//  Program shell for Assignment 2
7 e1 \6 b5 @8 a& L2 @# `//
0 Q/ H( c( A+ v/ \//  Compares two text files line by line
% W% b8 _9 D( X) `//*********************************************************************8 E7 L0 j3 w5 O! m& O$ K

/ e( L+ L) n, ^3 T" i; Z( Mimport java.io.*;- {$ Y$ s  B% k" B& u' @

6 ~0 E# f, }$ S% N3 k- V" ?, V/ A$ N, Mpublic class ProgramCompare
3 h- |! f( G, W: G) O  w{
+ w, p! C5 A# z8 n! u! b0 M  q        //-----------------------------------------------------------------
8 c9 Z) \* r' J  @' w, A        // Constructor! p. L9 @- a7 |$ j+ y6 C
        //-----------------------------------------------------------------
- e- J! @' g: \" M$ k2 v1 \/ [# ]        public ProgramCompare()
) ?. g4 v7 z/ `. m        {8 G9 W* W4 m: |0 W2 V) t0 s& ~/ s
        }1 f! z  g9 Z2 K1 T3 X& O( g

' A. O: E* }( M# x: }        //-----------------------------------------------------------------
9 V0 m" L# g( ~8 Z$ h        // Method for testing that class has been reached
- f  \$ x: }, S+ d+ }, J+ W6 L        //-----------------------------------------------------------------       
/ M1 n4 }  z% V  u3 \9 t/ b* S. t4 d* h0 Q5 Y  g  Z
        public boolean ProgramCompareReached()         0 r& d+ b! f! F2 a' P
        {6 ?. P) _' V3 A  l* r
      try 5 u/ T. H/ a5 @  r
   {        
' e+ C1 H& E7 {8 ^# b- m                          i& N  \! N+ \
                //********************************************************************4 j, d% X" H$ _% N' j3 V
                // Try-Catch Statement is used to handle exceptions - such as file not found " M! o: C! g* Z7 \, w( _- W2 n( w, g
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 |0 d4 ~3 w% U  u; S, L                // For more information see page 534 of the textbook
2 ]7 G; O3 ~5 _0 f                //********************************************************************
+ ]: G, N6 T$ O; x: N  ~                    
8 M  t% O5 l$ k) \8 a- P! E. T; h        }
2 ~* z- f1 s$ f- |             catch (Exception ex) // Exception caught here and message displayed to the screen / m- Y2 K) |* M4 E( A& t' Y6 ]
          {
0 Z) ]/ R5 T  Q8 ~& ^9 a                    ex.printStackTrace (System.err);2 y& x  I2 a: [, Y
           System.out.println ("Error message goes here"); // Replace this error message with your own         
" o; f/ F' T3 D, A; N' M; T( d$ p        }+ }; {3 x+ U" v  t5 b# Y
                return true;
3 w- Q! S( Q7 s        }2 W" Y1 U. `  A
" I+ D4 P! A( u$ P
} // end of class ProgramCompare, W  P; b: E8 g8 D6 j( L

# B- R- e% ~/ _! Y2 [( a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************: _+ e- T- m2 H1 D* \
//  ProgramCompareMenu.java    Provided by: DRS# \6 `, h, ^- Z
//
1 N' Y& w7 [/ ]# O5 p" V//  Calls AuthorisedUsers.java and ProgramCompare.java8 g+ }7 s8 J+ m6 f+ a
//( `, J( I; N4 F; k- Q9 v- H
//  Driver shell for Assignment 2.
( d2 X6 p  r! k: `//********************************************************************" D" \1 a1 }% K

% I6 \4 K- o, w) @' E+ v- Q" ^class ProgramCompareMenu
0 p6 q- I- h9 i& A$ d{
  M6 v; \0 x' g* [1 ~. D+ @) @; b# z    public static void main (String[] args)
( e% K8 R$ R  }9 Q9 X3 B1 X. X            {
: ^9 T3 @# K1 N* |4 q% g                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable( X6 w  E. {% v) u0 m1 O
                ProgramCompare reached1 = new ProgramCompare(); 7 K+ D0 g& F7 _
                AuthorisedUsers reached2 = new AuthorisedUsers();        2 r, G; K3 d: {4 k
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());+ a/ D5 A& R2 I: K$ W2 S
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
* F: J& L4 O7 m2 O. }- K9 j        }
7 ^. u1 |% I7 u6 ^6 c1 l9 M}// end of class ProgramCompareMenu
; ~. r6 u) ?7 b, s  U( Q: q! @/ X& M, y3 B4 B1 }" I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ O( V: d! ^2 M# u//          AuthorisedUsers.java          Provided by: DRS' s4 o- p: w# z8 E) y* f
//                2 S/ A& D+ m  F0 _; n
//         Program shell for Assignment 2
) w% s) A# L+ m5 Y; d6 R//1 h! m. {* c8 m8 v2 {
//         Represents facts about an AuthorisedUser1 C; k  k3 |7 v; ]2 U
//********************************************************************9 Z3 C, u, A- y& W

9 U+ \% A( s7 g/ \/ @$ h, `4 u3 {public class AuthorisedUsers
; Y: e7 \; S$ L/ G5 n9 |    {8 p; G' @* E" Z6 X  V  S

) g  k0 \: r- S1 {  E8 u; b5 m        //-----------------------------------------------------------------' V; y" U! I2 ^! P' n- X
        // Constructor3 }* b% n0 o# }6 e4 F* Z5 Z& S
        //-----------------------------------------------------------------) X. p* t' t$ }+ d' X7 a3 u% z
' B! v1 J- L; a3 X3 B
        public AuthorisedUsers()6 S, ^; X4 F5 Y* c5 z
                {4 |  R7 E5 ]5 e. T$ I) \/ w- c" i- ?
                }
/ k0 ?- K  s& m4 h: I
' p6 R6 e7 @( P0 N+ w        //-----------------------------------------------------------------
- _- o1 Q* j( B: e        // Method for testing that class has been reached
5 l0 \/ a8 F& X7 d        //-----------------------------------------------------------------       
* o/ f4 B1 d, Y" ]        public boolean AuthorisedUsersReached()' G! Y+ R9 N( x
                {( H7 F2 C" ]# e( @8 y
                        return true;                        % d. q+ }* X4 n$ T# }
                }
2 `* C: W8 E  c! ?               
" D7 P) N( {  f/ c$ j# N    } // end of class AuthorisedUsers
' n# U0 @2 H  d! P, i! q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
7 C; `* j. d3 P, C4 |% F' m. IShanghai - 20072 f& p1 o  ~$ I- m3 s6 N$ A
Assignment 2
; S8 Q3 C* K  b" I+ E; PDeadline for Submission: 10:00 pm (Shanghai time), Tuesday 15th May 2007 Assessment Weighting: 20% of the total assessment for BSA104 Assignment Type: Individual Scenario: The teaching staff at a nearby university are concerned that some of their students are submitting other students‟ work. They need a simple Java program that will compare the text of two other Java programs, line by line, for equality, and then print out the results, and a recommendation. Requirements: Consider the three Java Classes: ProgramCompareMenu.java, ProgramCompare.java and AuthorisedUsers.java, available from the Assignment 2 page on Vista. You are required to perform the following tasks: The ProgramCompareMenu class: (Total maximum 20 marks available)" X1 t  G, J  `: G# k
1. Provide a basic text-based menu interface to the ProgramCompare class so that it can be used by two staff members to determine if the two supplied Java programs are the same or similar.
( t7 F0 q$ V- b, j) s! uThe staff must be able to:9 s: @* t1 t8 k: w# _
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.' i: l( j/ J" E. S3 c2 \
1. The user should not be able to use the „system‟ until they have provided the correct user name and PIN combination. You should give them a second or third chance to get it right before shutting the „system‟ down.7 L$ P! A) W. t
 The interface should provide a menu so that the staff can:
+ h9 R5 }3 Y" |, v  ya) Enter the names of the two Java program files to be compared$ t2 t: P$ z8 {& `
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 q2 A5 I. u  G3 A** You must use the two user names and PINs provided in your individual data available from the Assignment 2 page on Vista (see requirement 5 below). The user names and PINs should be included in your code, and the output to the screen should prompt the user with the user names and passwords (for marking purposes).
) P2 E, }) c- e2 ^# tBSA104 Business Programming – 2007: Assignment 2
7 `& S7 }$ _5 ]) P2 mPage 2 of 5
* Y" |. K& l/ T7 V+ d6 a$ vb) Print out to the screen all the lines of code that are the same
" `7 ^9 d$ s8 @) z' \* R Include the name of the file and the line number of the code being printed for each of the two files+ J' r% O* Q2 O0 l* i8 ^" \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  C' ~6 d" w6 k7 }/ C
 the name, username and department of the user
; P8 P6 [% M0 ~0 W' V# [ the statistics of the comparison1 U0 S% g( }, W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 A* J; W; L5 K: N! e9 @; P% c- H6 } the recommendation for further checking
" x5 o: h9 v3 v, \8 x" f: m3 n* H- For example: if more than 5 (five) lines of code are the same in each Java program file, then print a recommendation to the screen that the staff member check the files more closely
- v. f9 V, G6 [' k6 e the names of the two files compared
8 T& g0 {& D4 ?2 m9 k7 ud) Leave the program (exit)
* z* R0 f6 B  K" K/ F3 Z, kThe ProgramCompare class: (Total maximum 20 marks available)' x( a6 X% C3 r8 x0 G. t" z, c
2. Provide a method/s to read in each line of code from the two files identified by the user: (assumed that the two Java program files are in the same folder as your program)
& ^0 v, x# }9 i7 C4 Ea) provide an error message if the files are not found or there is a problem opening them. x1 W: j2 P- U- r/ ]( c9 P) [6 y
b) compare each line of code
. y; @7 |! e; x8 @/ }c) print out the lines that are the same4 H: H) V) j" c1 P$ |
d) count the number of lines compared / lines the same
' ^: N2 x3 ~* gThe AuthorisedUsers class: (Total maximum 20 marks available)
( C* o/ ^: f2 Z6 C2 J- Q9 }) C3. Provide an object that contains the name, username, PIN, and Department of the authorised users of the program (user names and PINs as provided in your individual data - see requirement 5 below)2 U# w" O/ L8 ^
4. Provide methods to:
7 p5 e( y, e, X. ^a) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match
1 k# G6 P7 G, \  M: Tb) return the name of the authorised user
- w$ ^3 T7 e8 f( w! n" X* Mc) return the name of the department of the authorised user
2 H, @- ~* g. {, Q' W5 [Individual Data (Maximum 20 marks available)
  m, c8 }1 i( Q- d: l5. You will be given two staff member names, usernames, PINs, and department name, plus a set of two Java program files to compare using your program. You will need to log onto the BSA104 Assignment 2 page on Vista to generate your individual data and instructions for this requirement. You will need to use your University of Tasmania (UTas) student number.
5 Q; c2 s+ t& A+ b  \Documentation (Maximum 10 marks available)" h% V9 q4 t4 G  ]1 V
6. Your program files should be fully documented, at least to the same standard as demonstrated in the textbook. This includes in-code comments, descriptions, and where appropriate, explanations for each new constructor, method and variable.
0 l7 a1 ~1 D1 |8 y3 P5 G7 m7 n+ g, g4 e4 JBSA104 Business Programming – 2007: Assignment 2
4 q4 O' Z; C8 |- d" nPage 3 of 5
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:53 | 显示全部楼层
上面是作业要求,然后前三个是给的java程序,要求自己修改- -
回复

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" W- P0 I/ a5 E! a/ H8 E
不过你要翻JAVA的类库说明。你有下载没有?
3 a( n9 G3 d0 `; u; }9 Y' ~7 x查询关于对比的函数。貌似关键字是contrast,还有compare
! m; g! r/ L2 X' Y3 t+ B3 ]- b9 W; q" k# _$ c7 H9 l. S  ~& [" P( ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 Y* L1 s8 \4 Q2 ~" d
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 B/ s) l4 Q4 n; u. {2 E  E- R可以下载到的 是 jdk-1_X_0-doc+ Z) T5 c( ?$ H$ J

7 @; B, ]5 a+ L" x& ^7 R# M+ H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|=|HERO|=战队 ( 皖ICP备19020640号 )|网站地图

GMT+8, 2026-5-18 13:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表