找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1628|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 I1 W: b+ R- R2 B9 a! D " j5 p" h4 s6 Y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; [9 U  H: `9 F" O//  ProgramCompare.java         Provided by: DRS1 P2 z9 @+ n( E4 [- R! K! z
//9 D5 `# q% i9 d' I- c
//  Program shell for Assignment 2
* D9 d2 N# {( v) E0 s0 f, l//7 P" t0 ]& a. A1 q& _7 W, A
//  Compares two text files line by line7 j, U$ P+ h1 j' l
//*********************************************************************- x* J3 ^/ _7 P  E. A- ]5 @

: \8 h  T9 d, q9 \( A4 a0 P( _import java.io.*;4 R' n% V; r: e2 C
9 m1 ^0 q4 m  O' k& l1 Q8 x
public class ProgramCompare
$ g. L1 @( F' d2 L* @{. V& d8 @5 H* n! E% A
        //-----------------------------------------------------------------' P# |6 _4 ~, {6 x% i9 f
        // Constructor& ]" q* K% l( ]' `& I5 {- Y
        //-----------------------------------------------------------------
& p- _- ^1 k& v6 j( t4 q7 c        public ProgramCompare()
6 n- k: l+ A+ K6 S# b8 N        {
$ w+ a# M; v" M1 \" Z+ g9 m        }- S( x& Q* e9 [2 y5 H! g2 m! G4 i6 Y4 D+ w
: W2 x6 Q6 J5 g; x( m, p
        //-----------------------------------------------------------------3 w0 t" a% l# Y6 Q
        // Method for testing that class has been reached2 w2 ?; ?+ O/ A' P9 q' p# W
        //-----------------------------------------------------------------       
7 V: L" N, M, C8 B4 v5 @& Q
. W( O, x! L7 R. T, C$ C3 G        public boolean ProgramCompareReached()         ' c) [) [3 G& F1 k
        {
, p" }' H1 P" G5 T" o4 K      try
! ~: `& @1 y) ~8 ~% S/ M   {         6 t# O* g% \( ~" c
                       
9 S0 H& Z3 N% N3 N" U1 X                //********************************************************************
* {! K9 h5 @5 h0 m7 O                // Try-Catch Statement is used to handle exceptions - such as file not found
- n' \/ L0 _5 C7 F, L, q9 J+ R                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, A% ~8 }7 `, n3 `; Y7 @                // For more information see page 534 of the textbook
) t, p0 N/ Z2 e2 X' S8 g* q                //********************************************************************, j/ W5 g. B1 O4 m
                     ' j2 |( T; G7 j/ d) N6 D( }. Q
        }
! @, |( {% n+ T/ [             catch (Exception ex) // Exception caught here and message displayed to the screen ) q% }, h) @/ p$ F
          {
$ ?5 o. F3 K4 T/ z/ q9 l                    ex.printStackTrace (System.err);
6 W  q) E$ U8 T) W! @           System.out.println ("Error message goes here"); // Replace this error message with your own          2 ~% ^& X9 b, M1 ^+ |% c
        }
7 ^+ @) W2 T; \* H0 ^, z4 z/ }                return true;
+ r4 y% b* b* c! d# K- T! q  z        }: }' X5 w! v4 M

) T* p* D7 ~* N+ T7 |} // end of class ProgramCompare
# `* u+ ~% y4 l, K% Z
2 q$ Q* f: o- q/ |* @1 ^2 Q9 U; g6 V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' z  j! s! l( y; x% h& p//  ProgramCompareMenu.java    Provided by: DRS+ ~: a5 L8 L1 d  e/ M* D
//4 [8 ]2 X8 o9 s2 f& v; Y: r
//  Calls AuthorisedUsers.java and ProgramCompare.java; _6 l9 d1 l- A- H/ x6 h9 y
//- ]/ ~0 A( I: a
//  Driver shell for Assignment 2.) D) l) O( K" k: |2 q
//********************************************************************
$ _$ Z# P! L  l& X, d( v2 X' L( K
  f5 h! m3 _* [. aclass ProgramCompareMenu6 W1 S! ?6 D! R$ l8 [1 b2 l
{9 J: H0 V% D3 G2 I' `
    public static void main (String[] args): Y1 P6 l; a4 ?0 e+ a- _
            {( ~6 f8 f* s, t- c+ o- t
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable6 c1 }+ ?0 j" \7 ?( v, y
                ProgramCompare reached1 = new ProgramCompare(); ; v' w) ?9 Y. ^7 i5 Z
                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ ^" {  ^6 m8 x( C" n: V8 w                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 b& t& Z- ~8 _$ q: y7 ?
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# c4 C9 e' b& n8 A* A; U        }
+ f% x0 K1 r8 H9 M}// end of class ProgramCompareMenu1 c" T  L; f2 E* G

1 t+ i9 a. B: P2 |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
) k, j) L9 \3 ]/ _  D/ n//          AuthorisedUsers.java          Provided by: DRS
) r( {) U5 w% D7 p8 U5 S//               
3 P' I) k9 {# B0 J) F' x( n//         Program shell for Assignment 2
3 h1 i5 R# X' N- k' ]1 D//" {+ I  B# w3 R5 ]' Q
//         Represents facts about an AuthorisedUser
; f, ]1 Q8 \6 n. K% l1 @5 t//********************************************************************
* e2 Y+ N" E4 X3 d1 s
  `8 x5 ~& c! E! k4 z( r; d- vpublic class AuthorisedUsers7 w& Q' C7 u1 m& D; x  d) f
    {
9 a4 ?; r/ p) H! p3 z4 E
- z, t+ S; M& a9 V6 d) f: Z+ e        //-----------------------------------------------------------------2 z; c) a+ A/ t9 Z3 Z
        // Constructor, I5 A1 a, x$ N) [+ |( I- @4 `  k
        //-----------------------------------------------------------------  ]  A2 v2 |+ k5 s
/ E0 a& ^6 Z! q. B" a
        public AuthorisedUsers()
: |1 F' r9 h! ^( |1 {8 A! Y( L                {* k: A% C; j3 B; h  z5 }
                }' m. E/ Y6 R! c" H, f; y1 L
6 B9 z$ A( C- p- G0 d
        //-----------------------------------------------------------------! u# M3 O8 @( x1 }
        // Method for testing that class has been reached  z. C' Q7 ]7 d, d9 R
        //-----------------------------------------------------------------        / D! x4 Z. }& i
        public boolean AuthorisedUsersReached(). _2 T: |' P- H3 `
                {
8 |7 E( E+ M' j, ?( O  O                        return true;                       
: ?: o9 ]3 x! U( H9 l& c2 e                }
9 s8 F+ d- O0 d, d' k, i; n; W$ d9 h1 j               
# m+ C5 {5 N% b  ~* c: a3 ~    } // end of class AuthorisedUsers* N8 @% Z  `: b  D8 ]; [& ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, ]: V( j7 c& mShanghai - 20075 \4 g7 g7 ]8 y9 X
Assignment 2
! T* H+ w  v& t& v- v. A2 xDeadline 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)
5 Q6 b. A7 a, I1. 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.
4 C5 ?$ l$ V2 B+ VThe staff must be able to:
" M. D7 M' H7 n6 b3 T- ] Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% b' Z# v( }$ ]; f" k; q6 ~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.( S! d7 H. O8 v' j! ]
 The interface should provide a menu so that the staff can:4 u$ O. M3 ]2 u) d' X' a
a) Enter the names of the two Java program files to be compared
- d5 x, n: G4 l0 p* Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ ]1 G: b- _* c- z: x0 i** 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).
+ f5 e" m8 }/ o, D* v" b* aBSA104 Business Programming – 2007: Assignment 2* E+ _4 C2 u1 W* E* i5 s7 l0 Y7 y
Page 2 of 5/ x6 Y; _% c8 U; l1 Q, W8 O
b) Print out to the screen all the lines of code that are the same
* p& T% C, K, ?! R, y& Z Include the name of the file and the line number of the code being printed for each of the two files) ^2 u. ]: X) _
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 m! ]- L- G7 p
 the name, username and department of the user
( \' u8 R1 z- u the statistics of the comparison
  A/ Q! {( }% s( }9 W# i- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 M3 o9 q: ^0 H9 a/ x
 the recommendation for further checking& Q/ t  N: ?% j& N9 ^7 x+ X
- 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
' c& Q/ J3 d1 T( C+ n- J( u2 d the names of the two files compared9 U' V4 v% f: [0 R% r9 T( _
d) Leave the program (exit): M' j. ~) P" {7 F; t( ?
The ProgramCompare class: (Total maximum 20 marks available); n7 `. b/ O) i, w% u0 p: _
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)
" T7 {' x. t) Oa) provide an error message if the files are not found or there is a problem opening them' a' Q6 S. R: I
b) compare each line of code
& Y1 ~# b/ A2 U4 Sc) print out the lines that are the same  p/ p& [1 b7 s# _) ~
d) count the number of lines compared / lines the same
8 {1 T5 D/ w. D) D1 R  QThe AuthorisedUsers class: (Total maximum 20 marks available)( u& A5 }# y. G. z
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)
" i- z4 _6 u, w  @4. Provide methods to:
7 [: n* M; f. y: T" Ia) 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* z( q& I( p: J8 q3 j3 E8 j
b) return the name of the authorised user6 a* y7 ^' I2 A% e. F
c) return the name of the department of the authorised user' h1 O# E# L, U6 b: _
Individual Data (Maximum 20 marks available)
' A* s# U( F, [5. 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.
9 [2 V& o8 z- g. ?- p7 RDocumentation (Maximum 10 marks available)
. a2 Z" V$ B/ m+ f2 q' j7 g6. 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.
7 v5 c- o, j! F6 U7 V. a7 yBSA104 Business Programming – 2007: Assignment 2/ b$ n* j' K( C# ?5 a8 z: e0 z1 V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  R  D3 X+ m$ B
不过你要翻JAVA的类库说明。你有下载没有?0 o8 n, |; p- `8 R% y# _$ [  |" `
查询关于对比的函数。貌似关键字是contrast,还有compare4 A/ k" [5 l3 J

8 f0 N- P8 n0 R- e% s[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
" X4 e+ h2 l8 V7 R: J! u8 Y5 F( o痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
1 v$ h- Z3 l6 H8 ~. S/ v& f可以下载到的 是 jdk-1_X_0-doc
% K7 f7 ~) n6 ~$ _8 E6 e% ~/ O8 g3 ^0 n5 W
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-14 18:26

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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