找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1030|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) T6 o$ i$ g7 k/ ~4 `2 p/ [+ Y! ]8 }" T& Y1 x6 U \9 A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 A4 a7 }1 u( \. F( _& }' L1 [$ h
//  ProgramCompare.java         Provided by: DRS
: }7 R2 z5 ~( d& m//( L: Z' ~3 Q1 N, {
//  Program shell for Assignment 21 o9 _0 a: T; {; f+ F9 P: ~
//
, b, U- [8 q& p4 a8 W//  Compares two text files line by line2 i+ c# L- I$ s
//*********************************************************************
) @8 E+ D1 H# G$ B  ~. _
, O6 V! U+ p# q) f7 f1 jimport java.io.*;
- ^1 g' n: q3 V( t2 ?9 v# z3 b3 `5 C2 B& A
public class ProgramCompare7 D  R) J) b0 r
{6 }2 I- O0 J7 c9 T* g8 l
        //-----------------------------------------------------------------7 T, f4 Z( Y. t) t* p* d$ C" z: z" q: F& a
        // Constructor
% Q' J* M/ Q4 L" i2 q        //-----------------------------------------------------------------! d$ O+ ~- t( a/ C
        public ProgramCompare()
1 E' h0 ]* X, p, B. J; y        {5 O1 ~2 j2 i, n' f% ]
        }
( I( L/ M2 U) g1 M' k1 I9 F1 h& [+ B* B+ s) y5 d5 F
        //-----------------------------------------------------------------, J2 `( W4 S$ K9 v/ C+ B5 s
        // Method for testing that class has been reached
/ g& @5 {! l  S% r  V6 B        //-----------------------------------------------------------------        + E) [' U  x$ r& f& P) d
: H2 G- R% F% H" O) E$ u7 h
        public boolean ProgramCompareReached()         " I- I+ M7 l2 Q$ t' q: D
        {) s" a' e! }% f, d$ h# ?
      try 9 N  w, N% Y( ?# v& t
   {        
4 f6 ~( o1 H8 H# s% C1 F" }5 [                       
( ~6 P' m4 M9 h- ]3 x9 c                //********************************************************************5 }: t# k8 \' V9 O2 k
                // Try-Catch Statement is used to handle exceptions - such as file not found 5 i3 w3 s% u- ~
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
7 N( z) B& P2 k+ \$ I6 z/ X6 `& g                // For more information see page 534 of the textbook( I- I5 b. u1 U
                //********************************************************************, o" ?: o5 s- X* ~* c5 o6 o* a
                    
- T2 L: f0 L* n) r& g        }1 r- u& q4 p0 D8 r( Z! b5 J+ R
             catch (Exception ex) // Exception caught here and message displayed to the screen
6 m' v0 b: B$ K1 s! w          {9 T4 h% e8 {+ ]8 _
                    ex.printStackTrace (System.err);
+ D/ P: k4 v" t: v) @! B           System.out.println ("Error message goes here"); // Replace this error message with your own         
1 ^/ F- C8 b- w. q; B2 g* n( o        }
# v% @: X4 B, R- l4 W                return true;1 [6 T- w0 P0 h
        }
) o* u( l# J; X2 V9 X8 Y5 o- {: k: ~  ~4 r3 H. N
} // end of class ProgramCompare" B. k3 Q  o1 o9 u4 l
8 S" N1 u7 l8 |2 N" \) S' x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************/ @1 `' N8 V/ u4 S
//  ProgramCompareMenu.java    Provided by: DRS
% ~. |* O' Y$ o//0 @, n* E: {/ n* a
//  Calls AuthorisedUsers.java and ProgramCompare.java' U+ ~! I  J+ [  [- q$ h
//+ c( N9 K2 Q% W7 j  Q9 y
//  Driver shell for Assignment 2.7 L+ X; ?8 n- `0 `
//********************************************************************
" A, n, `5 q$ X4 G0 w3 Y7 N0 h- u8 P0 _" T% M) b/ w% B3 y
class ProgramCompareMenu
! t+ F- u) ]( X# b* n3 s2 ]' X{
6 V9 S) ], M! \5 E, e    public static void main (String[] args)
/ n+ ~' q1 F" X( Y1 R5 ~: n8 G            {, N0 t& F$ k% g3 t7 Q: h2 T
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 L  N. Q  D2 X9 c                ProgramCompare reached1 = new ProgramCompare(); + _' i. Q: M3 t8 ]6 W/ E
                AuthorisedUsers reached2 = new AuthorisedUsers();       
! g* L+ {5 g# v3 A                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
( i4 M# q" \* a1 ~1 S- H                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 M) k4 m. d  c9 q
        }
& V( |* R2 |2 A1 R0 g0 @}// end of class ProgramCompareMenu- O) P2 r" q4 f7 o1 w0 J

2 ~5 A# s' C0 H( b5 p6 E9 F, v7 W6 G//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. S/ u: ~8 u6 O: M& R) L//          AuthorisedUsers.java          Provided by: DRS
: _: e' E% r1 }0 X7 T" ]6 R( O3 \//                4 k: x3 p; r/ E. e- D. {9 l& o
//         Program shell for Assignment 2
' r) X5 K, C) c1 u2 m  X/ M6 O/// N5 z# [' ]8 z" d8 }
//         Represents facts about an AuthorisedUser) w& D1 a1 d5 ^6 o( `6 S
//********************************************************************& B$ h  a6 |3 }2 v( l
4 y7 l% p: d: v+ L% _
public class AuthorisedUsers
; ^4 B" ^$ b4 h/ e7 ^    {* ?' f2 Q8 R! r

) d0 k& W- n; U& Y: P& t        //-----------------------------------------------------------------
- b2 O( A7 j4 a4 N% O5 y        // Constructor$ e2 A. v# C" x7 b9 ?4 _
        //-----------------------------------------------------------------: w) A( T/ V/ X+ q/ N* R2 b
- X/ S# U$ U) n2 a
        public AuthorisedUsers()
0 r: S/ p/ |9 O% j% F: M                {
) i2 z/ M* q, V6 @) @                }
+ j3 e2 R. V) |. b0 u2 ]0 t0 U% C" c% S2 f! D+ a
        //-----------------------------------------------------------------
; e) {! }" T) ]        // Method for testing that class has been reached
' ]) t' U7 A( P$ {        //-----------------------------------------------------------------        9 ^3 f5 R+ p: C+ @; K* G. y. k
        public boolean AuthorisedUsersReached()
6 l/ i% T+ I9 D                {: j* G! O5 O+ }% `) ]5 n
                        return true;                        + X9 `* y; f4 k4 G6 N
                }
; r/ |$ L9 {9 D1 l               
5 g1 m9 e1 ?5 A1 G: ~    } // end of class AuthorisedUsers
6 {! X5 |6 T# m- p6 ~( B- t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 `0 D6 v7 I1 v( F0 d+ ~Shanghai - 2007/ a/ S& \6 J6 `3 l. X7 \' {# {* D
Assignment 2
4 q- Y5 q# x. j6 P& 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)
, c; g! z) z; ?6 T8 b/ t4 p, R; x  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.
6 E$ _+ \' ^( i5 DThe staff must be able to:
: d% @( W/ T! N6 V/ }* M& i Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.; ?( }+ E! n# b3 o* g. K* ?
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.
; }  ~/ L$ R( \ The interface should provide a menu so that the staff can:; c! b) w2 ~% P/ s, Q. S* U
a) Enter the names of the two Java program files to be compared' d( x! f! R" V% \7 N3 P0 U
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( |1 s% N+ T% N$ [7 X2 M** 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).
+ z5 o  ]! l; m: X1 WBSA104 Business Programming – 2007: Assignment 2$ l% L, {1 K" C) {
Page 2 of 5+ V  @2 r8 p' X
b) Print out to the screen all the lines of code that are the same& m9 J# `: ]+ V+ A# j
 Include the name of the file and the line number of the code being printed for each of the two files# ]' Y* b" R3 V, W3 a; b9 e, L
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 _$ `/ ?1 I! v8 k0 ?# [, e9 | the name, username and department of the user' n6 I. q& v9 Q1 ?# q8 y
 the statistics of the comparison8 w; v( l" H5 h! ^9 A1 b
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 c+ f1 |7 ?$ w3 U3 x; ?( a7 K
 the recommendation for further checking3 O  Y% B  ^( z; |. @2 g0 K* m- S
- 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
. E2 d' h  N! q* `* ]$ g5 y1 Q the names of the two files compared: g6 ~0 N9 e3 E3 N! b, y
d) Leave the program (exit): `5 T- c& J1 Y
The ProgramCompare class: (Total maximum 20 marks available)
. M  m3 o, e& O2 Z3 r; E2. 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)
! e, ^0 M, n1 @6 T! }a) provide an error message if the files are not found or there is a problem opening them4 ?8 L: u  n* ?3 }' j: Y0 f6 y
b) compare each line of code
- k* \/ w& N/ B3 Q" v2 h$ z! Hc) print out the lines that are the same
/ v* i! Q/ s0 `  M" zd) count the number of lines compared / lines the same3 x6 I5 ~. V# o- E1 x/ \
The AuthorisedUsers class: (Total maximum 20 marks available)
7 v2 I7 R7 f, d% f/ C3. 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)
9 O2 Q" u1 a2 e2 k, e7 P# _8 N4. Provide methods to:+ {, v( k) |  z# b$ i
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
+ K5 I# W; o1 D( Ab) return the name of the authorised user8 l$ X* e: M# v$ U' Y. o0 K
c) return the name of the department of the authorised user( W% ?2 X: G  g. P, N6 g# A6 d1 A0 q
Individual Data (Maximum 20 marks available)
, W7 L, h( c( D8 A: T, L5. 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.
- r. a0 w. ~& FDocumentation (Maximum 10 marks available)
/ l6 E/ b9 X7 e2 q! T* n6. 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.
0 c8 k6 p5 n# ^2 G1 K# v' VBSA104 Business Programming – 2007: Assignment 22 `0 w; b1 G  ^8 A1 ^2 P. V' A9 U
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% G9 ?3 f& ?$ M5 b" ]5 L* C: C. F/ S0 G不过你要翻JAVA的类库说明。你有下载没有?' s0 Z) R* G; C4 u% X
查询关于对比的函数。貌似关键字是contrast,还有compare; w; N. ~, D9 W! i, K4 d0 e

1 t, B; G5 J! y6 ^; w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ _/ h' V9 _- H. \痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。. Q8 F/ {. }& N& `9 r6 X
可以下载到的 是 jdk-1_X_0-doc, X3 v! M- ^0 Q. `# y! b5 @+ ]1 U
$ U% [1 S/ B3 v: `
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-9 22:03

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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