找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1312|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 . n, b# K- b* d( C+ l3 P( Z( }: M1 r1 z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& y3 e/ U7 x- t' G9 o+ H4 _
//  ProgramCompare.java         Provided by: DRS
/ w3 g, P% n+ a: J. e//( {# Y7 ?5 L& D5 E; S
//  Program shell for Assignment 2
/ A' P8 o& L$ D! z1 I//
/ w9 `8 f2 n, E* v# I7 X//  Compares two text files line by line% R' {2 m8 X; X
//*********************************************************************
8 M% {( a2 Y/ S* K) L8 M% ~
8 n# B  `5 P$ Q8 Rimport java.io.*;" r+ [' ~9 a  f, S! J% J; C# `2 o# x+ {- N
8 F+ j% I9 Q2 |7 u( a1 w3 X* r) o) s
public class ProgramCompare: Y. T- t, E( e$ Y
{3 e  A: ^: K1 g$ y6 y. T5 O
        //-----------------------------------------------------------------2 T5 [7 a' ~( y5 x
        // Constructor
; a' t& X7 j. u9 k9 S        //-----------------------------------------------------------------) z$ P/ ?. h- |" T
        public ProgramCompare()
0 F( C/ B3 a7 P' `        {7 }% q9 W8 t( k2 f  n
        }& M) h* Y7 Y& G" o) ?  A- ?

6 I3 Y; z5 E4 D# f# D5 Q. i6 U& p( l        //-----------------------------------------------------------------; b% f. ~( N' N2 ^, L2 ^  g
        // Method for testing that class has been reached
- Y2 B  [( ]. \1 P, U& x        //-----------------------------------------------------------------       
) w/ ?0 i% B- V5 k1 }/ ?' W1 b
6 \) H9 V. q* Z. h* x        public boolean ProgramCompareReached()         * V' g. s2 J1 _# s. M
        {1 W7 ?6 I# H7 |' E8 t0 N" m
      try
* Y1 q# p4 c$ `0 M   {        
% \. P! S% C( W& s3 d& s                       
9 H5 |! T: \7 l( N* G: a% q                //********************************************************************  K) y9 _* B, T6 M* T# x
                // Try-Catch Statement is used to handle exceptions - such as file not found
! z( [! Z5 }: w0 d( W                // Reading the files will need to be placed inside a Try-Catch - just like this one!( w( w5 ?- }' W, V2 @8 \
                // For more information see page 534 of the textbook
: L0 ~2 I( ^" }; X; f- l                //********************************************************************# W" t, v! G# S- S1 Q: l( p
                     $ a: D  Z& ]7 C: H* R% }0 l4 S( m
        }
" f, d; o) h6 s% M  M# e             catch (Exception ex) // Exception caught here and message displayed to the screen ) t$ x9 ?  a7 g) P- b
          {
7 N  g0 N% L3 N( \( }. ]                    ex.printStackTrace (System.err);
$ o/ _% {# E# V5 ?+ I4 ~           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 O3 Z; G( [% P2 j        }( c* y  C+ ]: M4 p. z2 u
                return true;
) a% l0 F% S$ z- P, n        }
. l. i. x+ W) Y9 b  @4 x6 v! Q; u  U5 L5 M3 E( o
} // end of class ProgramCompare2 P+ ?/ P; g/ I% |, u0 t, _  S
) F5 K  s, A. h) P8 H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************/ K& o  w9 D; b& W' ~1 H6 y
//  ProgramCompareMenu.java    Provided by: DRS" c2 P1 h! @5 S' x+ R. }: H
//- t, p$ T( C  Y1 Y: h" m0 l: L
//  Calls AuthorisedUsers.java and ProgramCompare.java% e0 s' H5 r; D& L1 o9 c9 D' c' ~
//
! @' f+ I- V* X//  Driver shell for Assignment 2.+ h7 j4 ~9 n0 ]. S- v
//********************************************************************! B1 @) D1 c5 R3 T0 s! V

' k: z; m4 T, J% J% f2 }class ProgramCompareMenu
* N. \1 O& A2 C0 r5 c{
+ {* u: e8 v, }/ J* P% {+ S    public static void main (String[] args)% j7 K; u# B$ s+ U9 j( y- j3 w9 E1 B6 m
            {( U# H+ p7 E$ c1 _9 J8 z3 l2 j; o# K
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
/ z" G6 O9 \4 |- z) H6 T9 `; d9 y                ProgramCompare reached1 = new ProgramCompare();
* W2 R7 d* Z/ }2 D                AuthorisedUsers reached2 = new AuthorisedUsers();        , f" {$ M, P/ _" a: x, l: a4 ]5 Y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: _& W% b6 T! b; U1 Z3 E4 g, d1 q
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 B! o( P. Z% h/ D; g9 Z        }
' `4 k0 I, Y6 I6 `- J- F* L}// end of class ProgramCompareMenu
6 V5 I7 z9 [! h: M0 O# M$ a" [4 X8 v
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************# F8 E& B* C1 M$ z& z  x+ M
//          AuthorisedUsers.java          Provided by: DRS* w% |9 T8 @1 H" n
//                ( A& U2 T  I& t
//         Program shell for Assignment 2+ p0 ^, _4 E# V: B; W& \' p. s
//
9 K: t' G4 X* n- T4 @( f: V8 n# R# M//         Represents facts about an AuthorisedUser8 f9 |& }+ {  Y0 a5 y( g
//********************************************************************! b& {6 J9 R4 F! F
, F  v: s: m3 h4 j# P
public class AuthorisedUsers$ K* q& J7 C- q& `% B
    {# U# Y# k9 p1 c  `# w
5 y! ~; d* c$ Y: b: D) \( F* f
        //-----------------------------------------------------------------9 [5 Q9 E4 B7 W
        // Constructor
0 M- \& j7 g  k$ L: q6 @; m        //-----------------------------------------------------------------& l! A, r1 F" G, j; A9 y
7 D# M4 w0 l" ?$ w' s( Z0 P$ L
        public AuthorisedUsers()/ d# r6 ]& S1 w0 c
                {) B; Z- {& u8 t9 R; n: Z" {
                }
  }! w7 D4 ?5 j& m; K% ?9 X3 E' U2 ]/ S: S
        //-----------------------------------------------------------------
1 N! Z) p# y4 e& D" t  X$ c  y        // Method for testing that class has been reached
7 Q$ f$ r, ]6 S; C. j        //-----------------------------------------------------------------       
  r8 k7 f" |+ R6 Y/ U/ O+ \: B( b        public boolean AuthorisedUsersReached()5 W$ c9 l8 [  Z. |. a& g5 @
                {' W: |( U) k* h- n& l# ]7 v
                        return true;                        ( T4 s$ u* N9 @& s$ R
                }
. ?9 y- R. k4 |8 h3 d, z1 E1 h               
5 \5 f2 I2 U$ ?( s( m' H$ ~    } // end of class AuthorisedUsers! o. ?6 e* ^/ [! ]2 b3 x: z. G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! n) F1 p1 ]! r- U: t/ JShanghai - 2007) @3 G$ {% j2 U  T+ u
Assignment 2
- K) F6 g8 }! Q" d- E5 Q/ a/ ?+ gDeadline 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)
. B* K) o8 F; S$ b. e1. 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.
1 e; y' C* K! g/ }$ ]The staff must be able to:0 C5 C- u. r3 \" E8 x) }! \
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% e. U' E) w/ g9 [
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.
1 p  W% G# t* \! G2 V, K The interface should provide a menu so that the staff can:
0 n( }' n6 ?) Z  U" v3 _a) Enter the names of the two Java program files to be compared
8 W1 K: L( H3 U, ^* Q For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 R) g# }/ [5 p, H** 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).
% W5 g2 B7 N/ x% ]# c1 E8 PBSA104 Business Programming – 2007: Assignment 23 I& r3 S. P5 w  i9 I* T: K# j
Page 2 of 5! o, r6 g2 w4 ^) f5 k7 z0 P% k
b) Print out to the screen all the lines of code that are the same9 s* E$ x: x! g; R- j- _; N
 Include the name of the file and the line number of the code being printed for each of the two files
; j% f* U0 z) e" j; gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. a0 C* t9 G" @. O" w the name, username and department of the user
& n3 A1 R; m% C3 f6 z2 h) N the statistics of the comparison
/ Y. u9 g  `$ B. D- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 m% ?7 M0 {5 \  g. M: {& j
 the recommendation for further checking& n9 F2 F% E7 b
- 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 closely3 X- ~9 _3 g7 [
 the names of the two files compared
: J& Z, Z) G: F( o5 h$ X* td) Leave the program (exit)
) t6 l- G8 w* g! ^9 A* uThe ProgramCompare class: (Total maximum 20 marks available)- q2 k  p- o* X) B" M: m; k
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)6 x( @  U  G1 B( t% N6 U: U
a) provide an error message if the files are not found or there is a problem opening them
' c1 h; f( S/ Z; h' {b) compare each line of code
5 R1 c3 t" E3 Tc) print out the lines that are the same
8 r2 u" b. u3 H" zd) count the number of lines compared / lines the same* _, \2 H; D6 F* ?7 b! j
The AuthorisedUsers class: (Total maximum 20 marks available), g7 ?6 a/ {. L/ X6 ], t4 x  l! H2 O
3. 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)
* ]( b/ G# N8 e9 `7 u. Y6 ^" ~4. Provide methods to:
9 }1 B1 o" r5 Ba) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match1 t$ q4 z6 y  b9 K1 I3 t, |
b) return the name of the authorised user9 l9 A% c3 S1 c
c) return the name of the department of the authorised user
# P) B7 ~/ X6 Z: G6 C4 t. Z1 AIndividual Data (Maximum 20 marks available)
4 n/ i( t' k. f7 W0 Q8 T5. 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.
( T% f$ I) d- z5 l* y' {9 O( X, QDocumentation (Maximum 10 marks available)( j, p/ A- P# ^* @
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.
3 A8 C! e: b/ P  B+ v5 kBSA104 Business Programming – 2007: Assignment 2
; F, x. r% d8 ?Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了; q8 g" A; S" i1 v3 d8 p
不过你要翻JAVA的类库说明。你有下载没有?
; ^" }  w; z/ U1 B* W6 `2 O- y查询关于对比的函数。貌似关键字是contrast,还有compare" f: O, z8 b- k. ]4 {+ J# \* A

8 {1 A* b1 U# ^2 F+ ^) t[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# l5 r! F2 I0 X% p( v: m
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; _: l5 i# a* B6 p/ `' O可以下载到的 是 jdk-1_X_0-doc2 \, P4 G5 `' `  O6 [
. c( o. Y% }* q; W+ l5 s5 R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-25 09:57

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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