找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1847|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急( o9 }4 T# }4 h* |" q, s1 g6 J 3 @ V7 C; f- b' t7 o, E
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************1 H: m. S9 G6 y
//  ProgramCompare.java         Provided by: DRS4 v& ^: O% G+ g3 x
//4 Z$ {. I' V2 b
//  Program shell for Assignment 20 z( V4 q* x/ k% h' r
//
- g/ F% _& P! Z# o//  Compares two text files line by line
" `% a: v" Q' T, _7 m) [//*********************************************************************3 D. N* q% R. A' u5 ^5 F

7 _5 q2 K  }9 @" o5 S9 oimport java.io.*;
$ w0 v, U9 `: J) Q6 Z6 }& f* n
' E; @& E1 [0 D( ^) ipublic class ProgramCompare
( D- d, o. c) _! q5 Y% t2 b8 S{
- U4 j9 J. T  D* \) t2 ^        //-----------------------------------------------------------------0 M/ u8 H+ u: A. Y6 j
        // Constructor
1 ^8 O( f8 i  M        //-----------------------------------------------------------------
7 `4 R7 D* b& ~) x! ?7 S, ]3 V        public ProgramCompare()0 X' O0 ~7 L2 @" }# f
        {
" P0 V; h" }( @        }0 U. K0 {, M) N0 d& n* A2 R: l

: }) r* P1 G! H6 o5 _! I5 f        //-----------------------------------------------------------------
6 M! ]& {- J: ]9 H, j        // Method for testing that class has been reached
9 h+ }3 C# N8 X$ R$ S- ?: |        //-----------------------------------------------------------------       
; g+ K( Z/ G- ~
+ [% O" z5 y+ ^* A( m- t        public boolean ProgramCompareReached()        
+ v+ j% g( ]3 M        {/ \/ j/ H$ h8 V+ W5 Q
      try
0 ]* E0 K7 G4 [   {         ' T4 N+ \2 u0 X1 q" d8 }
                        9 t5 f$ e/ M. _9 Y
                //********************************************************************
% d2 A+ N% X/ O6 ~' @                // Try-Catch Statement is used to handle exceptions - such as file not found
/ `9 `4 y5 a1 e" ~0 a                // Reading the files will need to be placed inside a Try-Catch - just like this one!) v: ^1 @; V8 L$ f8 o! B! g
                // For more information see page 534 of the textbook
3 O' }& S  t" f1 m# h                //********************************************************************4 j0 L1 q. E$ m4 U4 g
                    
' j* ^. k( U9 {' F5 A        }; M9 C/ j, d5 j4 f8 Q
             catch (Exception ex) // Exception caught here and message displayed to the screen . ^; u. g3 b5 y" S
          {
$ v  D8 w- d* h1 w  Q                    ex.printStackTrace (System.err);
7 x0 b7 D: U9 B" _7 ?, t* x7 h+ f) J           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 c! K9 Z8 X* r5 e' r, s        }
* A* _& A0 U( o3 B- ^/ g+ u                return true;
/ }+ D5 c# ?1 e        }0 ]) q3 w* ~- t0 u/ {0 l0 }
( T1 P& @9 l- N) G9 p
} // end of class ProgramCompare
4 K1 o" U. J, T( |9 \# ^, `
; Y0 w3 B* |  y& h( M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) G- Z; @4 a& q: ]# A% t$ s
//  ProgramCompareMenu.java    Provided by: DRS
3 x& G/ [0 q  S7 ]2 ~7 K0 @$ R//3 N, d' l. V8 ~! r
//  Calls AuthorisedUsers.java and ProgramCompare.java% Q+ H; P  p# G5 S4 l
//
8 [  U; \  F$ X1 k$ N- O//  Driver shell for Assignment 2.
  x2 U& R- ]. i0 b//********************************************************************, N, \: o  O: B

0 Z3 x% A3 ~& M' [& _class ProgramCompareMenu
4 |/ v" m6 t# s! U- E{+ r/ x# w) J6 U3 p$ `1 t. N
    public static void main (String[] args)+ Z* ~) `% G' Q' W
            {
+ e9 p; y% U: a  j% G( D5 s                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, N4 @/ Z+ s4 e" N' q. f                ProgramCompare reached1 = new ProgramCompare();
5 C6 U% y% a2 {. L% M6 {! Q                AuthorisedUsers reached2 = new AuthorisedUsers();        8 i! c2 h9 j% i/ u- Z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 s7 v2 o# J; ?& J, {2 `9 @7 s% U
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) W8 i3 {: Q4 J! x5 l7 ~
        }0 H; a5 I' t4 @! z% u
}// end of class ProgramCompareMenu) R8 c  d- Y; s1 v+ S3 \

/ |% x0 N3 i* ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  _" ^' r9 @& y7 c5 C//          AuthorisedUsers.java          Provided by: DRS) a' ]# t9 p4 `3 y) l
//               
& U0 y& f4 w5 W/ O; i. N//         Program shell for Assignment 2
' W  a" h  ]) p, @+ L. S//
4 N) }5 W% ]" y* f" q//         Represents facts about an AuthorisedUser
* Q4 i2 E3 z% A8 D& h//********************************************************************
: i+ q8 ]) N, y. {
: `/ z1 @+ X2 a- D  p& }7 qpublic class AuthorisedUsers
0 O$ Q8 ~8 p& k. g8 s( S' `) i6 M    {
' G+ b+ @4 g, Y9 @/ E7 M/ s. D2 i. F6 C2 J' S8 t
        //-----------------------------------------------------------------
3 p$ F" @, E) y7 R  V4 \$ m        // Constructor: D* ~" \  l' O! P- ?# K* |
        //-----------------------------------------------------------------6 Q0 i, q' _" _( f
& Q( ~, `3 r( j4 ?3 N3 O
        public AuthorisedUsers()
2 W0 Q! J- U$ l  j                {" {9 I  [$ g7 R) o, n& N9 ]
                }
$ s/ D/ Y" d7 C: q/ [  B! D& H/ l+ \! G- T7 z7 |
        //-----------------------------------------------------------------& q" m( X% q) `& _
        // Method for testing that class has been reached
& U2 Y4 o  N. p- q. U7 q" b        //-----------------------------------------------------------------        . `; C8 z0 o# p( j4 E
        public boolean AuthorisedUsersReached()0 B' P) s: z; ]% w4 q
                {' j& _* x+ |1 e
                        return true;                       
$ O$ P- b6 C0 e1 v$ c# _                }
9 K$ x: L! K; @( p0 {               
* z- r; a  p4 f, k" J4 ^" D. H, r+ C    } // end of class AuthorisedUsers
9 z6 g2 M* b6 ^: W" g$ ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 g4 |; r. S  T( n- t: e( P
Shanghai - 2007( K5 ?1 T6 ~) f; V1 K- e0 W5 j& L
Assignment 2
7 V1 D, N" [0 f' @8 N! JDeadline 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)
1 W' R/ s" n' s( [2 D1. 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.- N/ }# Z$ g1 y; ]" g% |
The staff must be able to:! U2 h) t5 Y/ Y' U( X
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* ~. ~* G1 M; a" i( h6 j
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.5 O7 N9 {% e+ n' r2 x* U
 The interface should provide a menu so that the staff can:
, s& \2 \$ Z$ ?a) Enter the names of the two Java program files to be compared
* \$ {! _6 C( I* J% D- h% w* _& A& n4 I For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& e, L" {+ `: Y' 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).
  m% }% u7 X3 B) _# J; p/ QBSA104 Business Programming – 2007: Assignment 2" p3 J5 I6 f1 ^" x- _$ X( V
Page 2 of 59 X8 F! u  O7 t: |7 I# ]' U; K0 X
b) Print out to the screen all the lines of code that are the same
0 t0 P7 ^- u% y, u5 P! h Include the name of the file and the line number of the code being printed for each of the two files( p; e% }" g: \4 A  D
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, L. |0 N$ I, v9 m
 the name, username and department of the user
! }( _- T! o# q* v) _ the statistics of the comparison* Z! B$ h, n  _- G. A7 N
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% a) }) N8 b: x6 H4 _- `
 the recommendation for further checking
( t: z2 W$ i- a9 j- 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
$ J9 V3 a. c4 d1 W$ `# Y9 ^' F the names of the two files compared
; y5 \, ?+ g8 e$ c/ h- H0 w' R/ Sd) Leave the program (exit)
4 x$ y  D( ^* aThe ProgramCompare class: (Total maximum 20 marks available)
, _% r* k/ p" r% ?/ a1 O% k2. 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)
5 x) }4 o- _( B- W5 h9 t" Z3 Xa) provide an error message if the files are not found or there is a problem opening them
. G2 k- w+ R% Hb) compare each line of code
; b- t* f. M! C4 f/ n1 l3 ec) print out the lines that are the same
! A; l9 c0 t0 @* ]d) count the number of lines compared / lines the same; C/ K4 Z" n2 V. g* x5 C* f
The AuthorisedUsers class: (Total maximum 20 marks available)9 j$ a8 t" b$ }# p# z$ x
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)1 M1 O9 K5 \" a7 f: w: T$ D  P8 ~
4. Provide methods to:
/ s( x& U* c: \$ ea) 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
( Q9 W8 p, }" c. O' Sb) return the name of the authorised user5 e0 x0 Q0 p! h/ }0 S8 S
c) return the name of the department of the authorised user
* t+ U; o6 ^. Q/ ?  D. H/ g+ RIndividual Data (Maximum 20 marks available)
) E4 l1 N/ H% L" z% f# z% 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.
& \' j  \( V2 f. C( [8 a  IDocumentation (Maximum 10 marks available)" j, n) h( }$ X8 O3 i. {! i
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.% T3 B( ^9 f# }9 ^: l$ x
BSA104 Business Programming – 2007: Assignment 2
" E& v1 f; ]( X1 w6 @" F) g( oPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ {: w1 u3 O8 p( B# Z) k) j不过你要翻JAVA的类库说明。你有下载没有?
6 _/ ^( G- p5 w4 ~8 O4 R查询关于对比的函数。貌似关键字是contrast,还有compare8 y+ p7 m: ?# k+ q' a
% ^! h+ Z5 [' U8 i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" O2 B* u: z: f3 G
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' J( L9 p# o5 T+ \- Q) K/ v6 S
可以下载到的 是 jdk-1_X_0-doc
3 K# K) O# p, c: o6 k" e$ O
$ P$ V2 k' _0 B6 T[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-20 16:48

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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