找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1502|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 i9 m( R& }% n, X - D, P6 O! A- y6 R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- \" g. |# v# A% z' ~9 ?( N//  ProgramCompare.java         Provided by: DRS
! \. y" ^" l8 K! U//0 a5 R) s/ I; d: k* E
//  Program shell for Assignment 2
* l" v/ p* o0 j8 a7 @  Y% @//1 b7 s9 Z( Z" }3 j$ Q2 R& {7 Z' T
//  Compares two text files line by line! \6 v! E9 u" r/ J3 Q
//*********************************************************************
, a/ [0 L, R4 `' m
+ H6 a4 D0 x( b+ A& `1 Mimport java.io.*;, K$ o3 P- o5 L5 k$ ~" d5 J0 _  W5 G
: r* [0 h! W! }" F' a; S/ M8 A. N
public class ProgramCompare# H( [3 L9 r, w' D$ V3 g
{; A; g, @7 n! T0 f3 V
        //-----------------------------------------------------------------
* v6 H+ w7 J- T" R        // Constructor9 Z  l: p/ Q. b# Y
        //-----------------------------------------------------------------
+ z1 Q) [) ]  K# {        public ProgramCompare()
+ }6 Z0 O- g( s' V* x; R9 V        {3 a4 k4 N( @8 ^7 @. ?
        }! `, |! z5 A' [) r4 r3 V

0 l. V, E! d  u; {3 h        //-----------------------------------------------------------------8 c0 K: _% u; c2 q5 B! B  z2 ?
        // Method for testing that class has been reached
# e- o5 z% A1 {5 L        //-----------------------------------------------------------------       
) Q, `8 B* [, b9 _3 N7 j  C# B3 y/ R1 R  i5 Q$ E1 [# V/ C
        public boolean ProgramCompareReached()         : X$ o2 I* D8 K$ s+ }6 j- ^8 ~
        {# }; L: j  |6 E( z4 P
      try
/ g! K" ~+ e7 u8 V) @/ U9 i   {         ) }# B( h: ^( s0 e* ^
                        ) ]" J3 K) k" R/ q2 Y# |+ `
                //********************************************************************( v' }- S. o. D
                // Try-Catch Statement is used to handle exceptions - such as file not found 5 @5 ^7 S9 u1 j/ z  w0 i
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 ~2 |, \2 {4 n* F9 d- ?" t                // For more information see page 534 of the textbook
6 H8 a2 X- n) L& A8 N5 O                //********************************************************************( e9 U' x5 I7 G5 U+ N) Z
                     # b, `. O) j' Z9 Z, @$ U
        }# a4 f! i7 v# P- e
             catch (Exception ex) // Exception caught here and message displayed to the screen + }3 s2 [! G3 y: N4 F+ _
          {1 p( F2 H5 Y: A5 \% C; f
                    ex.printStackTrace (System.err);
- [. D, {! A1 g/ p  a           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 }4 s9 ], D! O        }( y8 I7 s# m6 k! W' i
                return true;
% c" T& D& C$ }* `        }. S. X( x' `) d: E! E; }- z9 R
4 K  \! }. x5 G) }
} // end of class ProgramCompare2 }# z2 c* C, C+ Q

  H" H/ E2 I8 X6 O' \) p& _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************5 j% }% p) \- k) l/ [; V! b3 \
//  ProgramCompareMenu.java    Provided by: DRS
/ ]7 z% t) f$ Y' A, n( B! V3 L' ]( u//; t0 F# F0 ]! u
//  Calls AuthorisedUsers.java and ProgramCompare.java
) @- {" E: q. p) C  t//5 Z4 M! H1 ?" e' X/ Y' ?" |8 e' x
//  Driver shell for Assignment 2.0 Q2 x3 x7 D( w
//********************************************************************5 H0 T6 o2 l# }7 Y
* ^! n3 c6 U6 l3 i0 x# [; m- l
class ProgramCompareMenu7 o2 {2 X1 w7 ?4 e
{
8 e, [- X9 M! A: q$ k! }) r    public static void main (String[] args)- h# R1 H6 ~0 z3 d
            {1 I" Q6 t. T5 ?% y# j( i& \8 t
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
/ o) J0 }2 V5 _                ProgramCompare reached1 = new ProgramCompare();
& u, e) `! |! u( u                AuthorisedUsers reached2 = new AuthorisedUsers();        $ b% P/ M6 m$ h$ T2 q) j, O" b. ^
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 E0 V# K+ j5 f6 j$ H$ m& j  X                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
4 T. F, s1 {" m2 C! [4 I5 `. \        }3 q' ~: p( A% p
}// end of class ProgramCompareMenu8 E: v+ z2 p4 @- t
3 ^3 H+ M2 A9 v. P4 y0 s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
& ]6 T4 M; m/ t3 `//          AuthorisedUsers.java          Provided by: DRS6 Q( r! B$ O' V! h
//                1 b0 n$ h/ {" G2 _9 j
//         Program shell for Assignment 2
0 Z6 ~% I! d, T* C  T//, l; T4 e1 o7 a# r# \+ L) e
//         Represents facts about an AuthorisedUser
& v, ?. h  m! Z2 D//********************************************************************
% l+ w' Y" A* ?% H+ p* H% d4 Y
: i2 B2 j* s2 s2 q, E8 X6 fpublic class AuthorisedUsers
5 e* G* F4 W1 E; ]$ X0 y    {0 `: V/ Q2 j8 a2 [6 R* u5 I0 L" |. V+ Z
2 q* D1 c' J  ^- s( ?
        //-----------------------------------------------------------------+ o0 M5 r8 T3 B9 k& G. @6 q
        // Constructor  ?, D; y* o, C0 {5 l# B
        //-----------------------------------------------------------------7 [8 g/ m+ ~5 Z
4 X+ k! ?( B# v4 g9 I, Y4 w% F
        public AuthorisedUsers()
* M" |  W" q- R' U. D' u7 _                {
  T" a$ `! A( H) [                }2 R' r2 ~4 [2 O/ S) E

: c4 Q) W2 }8 K2 s+ S; {        //-----------------------------------------------------------------( c& e+ \: O5 l/ _) T
        // Method for testing that class has been reached
6 N& ~  r: M# a$ f% L        //-----------------------------------------------------------------        ; [3 `; M$ y/ E! s2 i
        public boolean AuthorisedUsersReached()
% h: j- g5 P2 u$ W$ [( D0 m) v                {
9 B$ P7 C; w7 A- g/ }                        return true;                       
9 }% U! S8 s' R" S8 H                }
; H; O6 s0 j( s, L               
) x" r6 v# v# v    } // end of class AuthorisedUsers
# r% {* f( v' u( F# V$ {  z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  F0 a) q: v  ~0 C7 F; ^, L
Shanghai - 2007$ f$ l# k0 D& }1 K' B6 Q( b
Assignment 2* [$ d+ T5 r) }6 B) y! M& U% U
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)
0 r4 L* P; S  l! x" ~; z# U1. 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.
9 J2 O7 p" M  w2 I7 IThe staff must be able to:
. f* B, l7 E; U' F- D: v5 x# y Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.0 Y; l: w0 G9 X, b8 B  G% N
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.
* i; T4 W* y2 t* A The interface should provide a menu so that the staff can:
* F$ g. R; p1 D# P& U# C$ ma) Enter the names of the two Java program files to be compared
. ^5 _% E& k* \. v1 \% g, z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 y) Y+ R, _2 N1 j- b4 F
** 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).
* U- }9 @4 |/ o/ [: TBSA104 Business Programming – 2007: Assignment 22 q; A/ R4 o. h5 c. K
Page 2 of 5( K* A2 s; T" L- l$ b( W0 M/ r6 g
b) Print out to the screen all the lines of code that are the same% V4 X! r: I* f" |) y" J4 H
 Include the name of the file and the line number of the code being printed for each of the two files; g  ~5 N6 B) D  L+ |# X/ v
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 h: w/ v$ Z! W% y
 the name, username and department of the user4 [( {0 V( l) N4 u$ q
 the statistics of the comparison
0 }. V8 _! ]" D! Z5 W; c- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different3 F0 v  C, u: P+ u/ Z$ W5 E
 the recommendation for further checking
1 a3 Z! T2 e  f( ]2 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
- i8 T1 s0 H  K1 k5 Y  E the names of the two files compared
( [* W0 v/ i: a; v* |" Bd) Leave the program (exit)* S0 P! e6 Z, A
The ProgramCompare class: (Total maximum 20 marks available)
$ r0 i4 b% R: W, \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)
0 E& K5 ^: ]3 a% w+ Ta) provide an error message if the files are not found or there is a problem opening them% s  H% m: u7 D: ^0 y/ n2 ^
b) compare each line of code. U  _4 l. B% ]3 t' s* M4 C
c) print out the lines that are the same
2 u" W0 d, n' g3 sd) count the number of lines compared / lines the same( W, U- b; \- c% W" V
The AuthorisedUsers class: (Total maximum 20 marks available)
- u6 h$ G6 h8 z4 ]5 K3. 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 F$ @# S& Y1 f
4. Provide methods to:0 x4 D3 t" |0 o7 b3 j* A
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
0 J6 i: m, m) W1 I. S: c/ cb) return the name of the authorised user, K" g- y0 D2 T8 W1 Z5 ^0 I  w3 t
c) return the name of the department of the authorised user
& o) |) F+ C: p! n8 nIndividual Data (Maximum 20 marks available)+ ~+ i3 A& |  ~# f! K( [9 {( ^, 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.
  A! Q* }, M5 E3 gDocumentation (Maximum 10 marks available)
% M! Q2 u$ I& N6 p6. 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." D* a6 n; \5 R4 h5 t
BSA104 Business Programming – 2007: Assignment 27 D; O+ J: z! X3 P) f
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 V+ i1 @0 h4 |0 X! v+ E& s) r/ \
不过你要翻JAVA的类库说明。你有下载没有?+ a2 t( ]' |$ g: I: x
查询关于对比的函数。貌似关键字是contrast,还有compare* G% ]) z: o# ]

  W0 V8 n1 s+ S# w2 |7 D& n6 Q9 w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
3 \$ m/ g9 l2 M" d" x; ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
6 n) W# G) V4 ]可以下载到的 是 jdk-1_X_0-doc
; U" j3 @  i4 ^! v" g. i. n
2 ~0 s( `6 x) ]1 W% E[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-29 07:39

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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