找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1523|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 {4 z1 T% @7 H" e/ L- l' v ' X* u3 {( B; J8 ?' U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//********************************************************************** O8 f0 W6 o* m3 u3 D( Q. F( |" z
//  ProgramCompare.java         Provided by: DRS
8 [/ C/ d/ [/ {+ K//
- m( B7 W1 Y& O' p2 r; t//  Program shell for Assignment 2! D5 t4 Z! ~  O
//2 M, _  n: }+ W2 g
//  Compares two text files line by line
7 t9 J" R" y  J3 R3 J, G//*********************************************************************
( w5 a3 k2 a9 x8 `1 R9 j7 }: D  f3 g4 m
import java.io.*;1 _8 m0 j: O4 t: v

0 X( {( V3 l; o6 {8 |# R2 B5 gpublic class ProgramCompare
7 v3 }& i* X7 k$ [' z, [{
1 G9 |: P3 d+ }9 Y# ~5 x. O        //-----------------------------------------------------------------3 C! M! j  E8 I9 ~; R6 S8 l! u
        // Constructor% a( O- K2 A. Q( K1 V
        //-----------------------------------------------------------------
0 z7 x. s9 f5 v# O- G        public ProgramCompare()8 v, ]- A' r) I# z9 n, ^2 ]; ?. W$ p
        {2 R- ~" [' @/ [: r" K
        }
0 `0 v" f. F. g2 Q" h, m' k
4 P' I0 O, F- v        //-----------------------------------------------------------------& H( O7 m  z$ _8 P4 T) `" P6 ?
        // Method for testing that class has been reached4 \7 c- {5 B' A
        //-----------------------------------------------------------------       
$ K4 p: {1 b$ F9 F' O! M% o4 K- N! n3 p  }
        public boolean ProgramCompareReached()        
6 x+ ~$ e( f5 n. [        {
4 ~$ D7 Q) @, H/ ]0 K6 ?2 J      try
( P$ s4 Z* D0 F7 J   {        
/ h+ }" Y" T2 a% G5 ~$ ]+ Y7 a$ B* c8 R                        ; k' X+ j& C1 O( Z
                //********************************************************************
$ _+ H# z3 F2 j, e& K* R  M                // Try-Catch Statement is used to handle exceptions - such as file not found
+ h5 S9 ?2 q/ ?# \! }; C8 ~% O- s                // Reading the files will need to be placed inside a Try-Catch - just like this one!8 ]4 c$ H# a# t, h5 y: |
                // For more information see page 534 of the textbook2 u  G5 S7 }" e. d  \
                //********************************************************************
# ]' H4 n: T5 I+ M                    
* d5 Q8 T* }2 g' R        }( j# O: k! ?* q- R" j& P
             catch (Exception ex) // Exception caught here and message displayed to the screen " y& _9 k: @8 c0 N% h: W- z# \8 C
          {
# X4 I9 }6 f& w                    ex.printStackTrace (System.err);
5 m& Q0 y& v3 ~; O5 `, ~: J& ~4 n           System.out.println ("Error message goes here"); // Replace this error message with your own         
& H, x4 o- x, x6 C# r        }
4 v3 d% t: J0 W2 R# a+ ~" C                return true;
8 C# w# O* l1 N) H        }
$ P$ {% F) z" n8 w. Q# Y% s9 f" B
} // end of class ProgramCompare
2 w0 A2 j9 A2 d/ o+ U0 w7 Y: H" h# K% |) l7 K3 i* R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
5 n3 R# m( C3 f- k, y//  ProgramCompareMenu.java    Provided by: DRS
/ q/ u) d8 y6 h! A  _//
' `2 w* t' R# w/ f//  Calls AuthorisedUsers.java and ProgramCompare.java6 p) m% n4 S, r" W0 p
//
1 r$ l8 D( D  n' }7 k//  Driver shell for Assignment 2.4 v$ [* K' p* O& L( Q
//********************************************************************" P* S4 f. Y+ ~/ v' b  ?

' U) {5 q* i9 P/ Oclass ProgramCompareMenu
2 u7 M2 J) y$ m{2 z6 I  t  ]4 r$ ~! R* c: ~
    public static void main (String[] args)2 y. e7 N. W5 S
            {
7 \; ^3 M9 M% Z, ~) _                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 A0 I) y( i; b                ProgramCompare reached1 = new ProgramCompare();
, H* C4 s+ `6 ?7 Z7 N1 ~  B$ B                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 p: c- G' V" d: C8 D% k( t4 s                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% X, R+ C0 ]  `! G$ C                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ S1 n) c, q+ P. ?% D* F) W! @
        }! C& Y9 N* X4 Y2 }' r
}// end of class ProgramCompareMenu
7 {. ?2 H9 \' Q5 N9 A- n" j8 I  G! k, R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) X# \1 d) L* f: i) `" D8 Z- P
//          AuthorisedUsers.java          Provided by: DRS
) v# R! M7 |+ x: C4 J" n//               
% O8 t% w+ g* s0 h0 P//         Program shell for Assignment 26 v/ y( n' |  \3 B* ~+ k& n1 {) d
//
& @" v& ~* j! X1 I! d//         Represents facts about an AuthorisedUser
9 ]( o# G, S/ ]( w! m3 @//********************************************************************
3 t5 Z2 Q+ n' L# d* B3 q% X1 I
6 Z7 b) z6 R1 [: z# P* F- bpublic class AuthorisedUsers" E* k' ^% v6 M5 y2 S
    {- c# m" g4 t$ Q, v* d- ?

$ O. k; \3 `5 ^. X        //-----------------------------------------------------------------4 u# y3 M, G0 [2 s1 C9 Q
        // Constructor
& s# k8 C8 I* d7 G        //-----------------------------------------------------------------" T9 Q. a9 p. Y
2 b8 `; u' H+ R
        public AuthorisedUsers()2 M1 B! R6 I  g( n% C  S( Y/ T
                {
& k, N3 o6 t- O                }. L5 L& Q6 \( n0 @

+ _- _" _6 E1 I) [* X4 @% a        //-----------------------------------------------------------------0 K: H5 B5 C7 m5 c1 g: E- e2 F
        // Method for testing that class has been reached! w! c" Y* r$ \+ O; W
        //-----------------------------------------------------------------        ) n6 m$ k1 I) L: h
        public boolean AuthorisedUsersReached()
& u0 [$ S/ ^9 {2 n3 ?                {
( g$ _* g5 T1 f3 _* m                        return true;                        % @* ]- d9 n7 s& h
                }
4 s8 g8 c" e  h- j7 N                9 U" P  k/ j9 ?, Z9 p9 C0 F
    } // end of class AuthorisedUsers
) ?( e( R* D3 E! G4 C' V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 ^7 R& q/ v) Y% wShanghai - 2007+ c# }- v: m, I, d' `6 B
Assignment 2" s$ l) H( m; [2 L( m) L
Deadline 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)
: E9 N& ]9 W' ]/ ~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.
$ O# a: Y3 n* x3 V+ N; |& RThe staff must be able to:  F  p7 S5 Q7 ]7 `: R
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 L% p" p  M' m8 Y
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.
; x, N: i2 I- \$ d The interface should provide a menu so that the staff can:# {$ D4 V8 I: P3 X& V/ P- i
a) Enter the names of the two Java program files to be compared# V! @" s# _- A3 z1 k
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' q7 \  O% E3 V' X* {; Z6 g) ]3 D
** 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).
" {- ~7 f3 B2 E+ W! b, [BSA104 Business Programming – 2007: Assignment 2  Q; {% K7 V, J6 m: T# S  n
Page 2 of 5
1 N$ y0 Z! F4 q+ Q" db) Print out to the screen all the lines of code that are the same
$ E# O1 \: Z, D; z1 j Include the name of the file and the line number of the code being printed for each of the two files; e9 y* a+ P; d$ @- O
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared+ d' f( c/ a1 p+ ]( `! G2 Z
 the name, username and department of the user
5 Y2 y* s$ R* r! I; E the statistics of the comparison( ]  f6 i, }4 u3 K
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, i( z  ~, i7 u( A7 N& I3 s
 the recommendation for further checking  \8 l* L+ C  A
- 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
/ F. l+ K: v& }! } the names of the two files compared
! D, h6 w+ T8 \# c, X8 ^d) Leave the program (exit)' r0 o! K& g# g* I8 w
The ProgramCompare class: (Total maximum 20 marks available)' e3 W) L& Z  `. n
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)
( @1 g# R' R3 T; m# t  W9 D5 k; aa) provide an error message if the files are not found or there is a problem opening them
& T# c) _2 O: W0 kb) compare each line of code
5 w/ o4 a0 R* t& Jc) print out the lines that are the same0 w; U1 i. Y4 O, z
d) count the number of lines compared / lines the same
; k9 u- b& }: V; M  P) [The AuthorisedUsers class: (Total maximum 20 marks available)! E4 n* Y$ O8 z) L
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)4 `$ w6 h' h" b# i- [
4. Provide methods to:2 K7 ?" U* I& R1 O- d
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
) S; b3 v$ M1 o% D, Hb) return the name of the authorised user: }4 M: U) [! R6 X% i4 c
c) return the name of the department of the authorised user
  e+ [$ m$ p* T8 d( K; F6 \Individual Data (Maximum 20 marks available)
8 N8 ^/ ^, x$ w9 u5. 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.
" z4 J3 k2 X  x; R. yDocumentation (Maximum 10 marks available)' E& Z- t" P! ~8 w" ?: ^$ }
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.
8 v2 O& O& T' j: OBSA104 Business Programming – 2007: Assignment 2; Z0 c) \/ ]7 n9 u* s. O+ @, ]
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了' k9 o, y0 }& D% L4 k- Y
不过你要翻JAVA的类库说明。你有下载没有?+ N* n" y# O) L3 Y: q' k' q6 Y
查询关于对比的函数。貌似关键字是contrast,还有compare6 c8 {7 E- U) k& a0 F4 S

9 _: X  K- R, i* m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ h5 x2 b# ~" l9 G( M; d痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: O1 [5 K3 w1 c
可以下载到的 是 jdk-1_X_0-doc
: R0 X. Q) ]7 N" A' b
1 @& e' P# l9 q& `2 |" O7 {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-6 08:59

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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