找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1538|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急* U# A- P$ ` f8 H ; P, v7 [% @+ v* H+ b( W. t
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. T4 E( p. [. o* R! g//  ProgramCompare.java         Provided by: DRS
/ F- G! W$ P# ~//; b0 l, h, O5 ]" T( }
//  Program shell for Assignment 2
' |: K. z# `- z4 ^//
+ E  x) C- y# s" X  A1 ^7 j//  Compares two text files line by line
: z* C' O! I% B+ C( }4 q* C//*********************************************************************
+ @$ N" Q- X7 O& X9 }# j. @1 B* n5 s8 ~8 M" @
import java.io.*;( e& F+ V- y9 v( K. z

% C( I* m8 l8 R/ m+ `$ Upublic class ProgramCompare5 f( X8 h2 h8 E! {* U: ~2 q6 Z7 t0 x* N
{3 w) u; d0 R6 |5 s& J& D
        //-----------------------------------------------------------------
0 i$ H) h/ H, z        // Constructor. R. ^9 d3 ^& D+ N7 v% j
        //-----------------------------------------------------------------
' i9 }0 Z* X& [  j! S- a        public ProgramCompare()
" |) M9 o5 @  j5 V% c. N0 @* [        {
8 y3 |: `4 K& M7 j) Q        }
7 ]" l/ _( y1 e0 P7 e% D6 I. q
        //-----------------------------------------------------------------
+ k9 F1 J/ [- D  w        // Method for testing that class has been reached) I8 I8 Z7 r4 ~7 K& S' {/ k/ r
        //-----------------------------------------------------------------       
6 Y! `' D5 t4 y; I# a, x4 U  H2 Q8 e' \- h2 j! r4 P3 H
        public boolean ProgramCompareReached()           [) f; W& r$ i6 B5 N' c
        {
. }' j, ^6 N; b% N1 b      try
4 P: v' f! g0 q0 a   {         9 f2 R6 D' ?% W# a
                       
  k) |0 `8 y, ]/ E3 x                //********************************************************************
" n) u$ B# S$ \$ p# D                // Try-Catch Statement is used to handle exceptions - such as file not found 8 y7 J0 Y4 h3 }% M3 S
                // Reading the files will need to be placed inside a Try-Catch - just like this one!, i0 r5 z+ v1 x0 R; W- N
                // For more information see page 534 of the textbook
. p3 o* n6 {2 Z0 W9 Y                //********************************************************************
# D- A/ w1 B- G  d3 }                    
; u# I9 ?) G+ @$ i3 Y  }8 e5 L8 ]' J        }
" h+ C% i# t: S: Z             catch (Exception ex) // Exception caught here and message displayed to the screen
% B( ~* L/ r5 j          {
# @! d' I$ @" a$ j  L& Z( m1 K" w! c                    ex.printStackTrace (System.err);9 w& s& m% V- z4 F
           System.out.println ("Error message goes here"); // Replace this error message with your own          ! w. P; q% n3 F8 P2 x, W" K+ L
        }7 U& ^8 `( }" |" I
                return true;
/ E. [$ W" I& K7 f- ?        }- Y* R- ?2 n# T: g8 Z  c
7 q) T9 E: ]2 i, m0 J) Q  h
} // end of class ProgramCompare+ N) h9 ~/ m. o) d' ^! ?
' ?# S# ?& [$ e5 e$ c$ O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& z- T( q7 R& N6 T7 U
//  ProgramCompareMenu.java    Provided by: DRS. |$ O/ r2 |" O
//
' O$ M4 F! S2 u//  Calls AuthorisedUsers.java and ProgramCompare.java% ?1 u6 Y$ }9 X. A, C
//
% }0 |1 u* E: l$ `//  Driver shell for Assignment 2.
$ Z* E9 G* ]$ Y: V. s4 M* @% ]//********************************************************************' ^5 {' J9 u3 b3 N) R  b# w, l8 o

2 i9 X+ S" }2 h; q( zclass ProgramCompareMenu$ W. L: n) D+ t8 s% w
{/ b4 \, A8 H, `% x/ _# l4 j
    public static void main (String[] args)$ N& {4 Q$ M' _+ W8 F5 \( V0 ]3 w
            {
. Q: e* E0 H" T- Q9 X                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable" s  i% J9 c3 S
                ProgramCompare reached1 = new ProgramCompare(); 4 _  q; ~( i! s! V! K: l6 U. K% h
                AuthorisedUsers reached2 = new AuthorisedUsers();        : w: W* b) l, m# l: s
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, o$ p' X* R- r$ L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
9 P+ u" [. N0 N        }
3 ^; c. K/ }% g/ i}// end of class ProgramCompareMenu
2 c, [0 \6 f$ m1 A: y/ k
1 o' L0 Z  C7 o; ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ l4 z" r8 M2 `* B" X- A
//          AuthorisedUsers.java          Provided by: DRS: j" A% ?2 K) v8 u) M) G" o! u
//                ) {0 q! J! @/ y$ z) ^: p/ A. a1 i
//         Program shell for Assignment 2) Y/ p! k6 [4 w
//
5 U; _- S3 n7 O: ]//         Represents facts about an AuthorisedUser
9 S) J. j# I, T) H8 v5 l//********************************************************************
2 R1 y% S) C0 U% x# h+ }+ ?5 r% Q: L2 X9 @* t/ V/ ?
public class AuthorisedUsers1 z  E: B$ Q$ n( a) Z
    {
  w" m7 w+ |1 v+ Y0 n
  [3 P  P6 Z/ N  a$ h" q8 X        //-----------------------------------------------------------------2 b. C" V* t2 r6 _2 S
        // Constructor. X4 @" m# ]% ^2 I
        //-----------------------------------------------------------------
) T( _# p5 r2 e6 n1 q3 f
5 j% v8 ~& B7 h0 p) s        public AuthorisedUsers()' g+ Z9 f  m& _& {3 y
                {
/ D6 `# F/ l% o                }( D2 z6 y$ n7 @9 V
- T. T$ B6 u) n, H2 K
        //-----------------------------------------------------------------
( z' i1 ~, R3 @3 A/ a& [; h        // Method for testing that class has been reached
, i8 @1 `7 @4 I! O5 t        //-----------------------------------------------------------------        1 O* D8 O  e# i; ^( |8 a
        public boolean AuthorisedUsersReached()
; e: U! U! e8 |7 S8 m4 K) j, P                {5 P/ C7 r. k" D1 O# k! Q# b
                        return true;                       
5 K+ m( [& Q7 l                }
- n7 y- ~( m" X2 l0 ~8 W7 ]: V               
4 }8 v+ u4 F) B1 u) v0 r8 D2 u6 q) }0 @    } // end of class AuthorisedUsers
3 n4 K; H4 n" G7 G& r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( ]+ s) m, w( X/ _+ tShanghai - 2007
6 ^) w) G9 g  d. FAssignment 2
( F3 J% i1 e( ]* MDeadline 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). T  R8 s0 b7 O" I
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.
) T+ W/ v0 G1 c+ CThe staff must be able to:' m: N5 E; ?0 [4 B/ v) m8 u
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 p; p4 v) f& c5 S2 y- `6 k1. 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.
' n+ E/ ~" s) t% J) g The interface should provide a menu so that the staff can:( ?( k" t! Y, Q) e4 X. B, j
a) Enter the names of the two Java program files to be compared
9 E% U- z! X+ O( F8 n6 N' Q For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 ~  m% W/ A  }' A% _* Z5 s0 B
** 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).
) `8 p: C3 c6 H& ZBSA104 Business Programming – 2007: Assignment 2/ H7 b9 u8 c/ Q. a4 Z
Page 2 of 52 T6 y6 S/ y1 q. g1 r0 P; e/ Q" X
b) Print out to the screen all the lines of code that are the same& C0 O, e' ^) Y% S- S, C5 S. ^5 }
 Include the name of the file and the line number of the code being printed for each of the two files
  V7 F2 q( y9 D% hc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 p) N; o+ x& W* o% k9 f  E the name, username and department of the user
/ x- W' i: k% P8 W0 Z, t/ q8 a+ T the statistics of the comparison
/ `! a% h" ^, h( O8 ?, x- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, e( }+ |9 O% N/ E& u9 Q
 the recommendation for further checking
+ @' F6 d& l4 f, d) n1 W- 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
' g0 l+ i$ s; ]3 Z' P the names of the two files compared
2 d2 B. f8 W1 l1 |. o. ~d) Leave the program (exit)1 ^! D1 g* R( P5 V0 C% f$ y  R) g
The ProgramCompare class: (Total maximum 20 marks available)
: G/ H. \* s, x1 V+ z2. 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 K# j& x) U# s! y" |) \a) provide an error message if the files are not found or there is a problem opening them
. c4 U) k+ a5 e. E8 f: _# f6 gb) compare each line of code
$ t# p& ]6 ~6 T1 `# v" K8 Zc) print out the lines that are the same4 ^" {' J) y  U3 r7 @
d) count the number of lines compared / lines the same
' Y" \$ W& w" y& Z3 A8 I9 @The AuthorisedUsers class: (Total maximum 20 marks available)
& q" h9 B9 A" C& {4 n3. 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)
/ D# T7 l) k& o* f6 p5 l, V# z4. Provide methods to:  C% P  A/ }. E- P% a, G
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 match1 {7 n- h' t' `; R3 F
b) return the name of the authorised user
/ ~) G0 A$ H; o! c+ ]) Q, cc) return the name of the department of the authorised user
/ j( `2 Q% H( }8 T/ RIndividual Data (Maximum 20 marks available)* W$ H0 T/ ~+ J1 P
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.0 I2 ]+ N6 N! m9 f! z$ Y/ Y
Documentation (Maximum 10 marks available)# u% L, I) E5 L7 E/ h$ }. }
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.
7 w, B/ [; G, p; q; C' u. ?BSA104 Business Programming – 2007: Assignment 2" i6 O& I( @: q  K4 M  a  Y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 h5 D, |' ]3 H1 A6 n
不过你要翻JAVA的类库说明。你有下载没有?
. M6 `& c1 X. Q, M查询关于对比的函数。貌似关键字是contrast,还有compare
* I) n5 g( I7 y( s8 H' {: H/ D" p" ^9 ~% V' I
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) x' }+ A4 r% d, v痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。$ m: H2 S  e+ K9 Z) i
可以下载到的 是 jdk-1_X_0-doc% W" a3 o% a* Z
- t: f# p* x7 b6 f( W: H' F
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-12 21:18

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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