找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1585|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 a; l9 U3 g% k: i1 c8 a E* w( N/ \+ u% B4 ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 x1 y, o' P+ X+ Q% H. J- z" S
//  ProgramCompare.java         Provided by: DRS: h' ~! F  M/ E7 Y5 H6 I
//: _; o9 o7 S/ H4 L' P* l* v
//  Program shell for Assignment 2$ m8 W7 @" L; P9 }
//$ w2 g* o' x4 F4 V& q4 m9 N
//  Compares two text files line by line
  b; ?0 b* B$ q5 M3 ~; p6 C# }8 @0 W//*********************************************************************8 a( S3 ]4 O% T+ W- e* u' i

3 Y; N+ J8 F8 [* o1 gimport java.io.*;
* n3 {) L9 J. q+ N' h
6 E: `% }& s( W/ r  spublic class ProgramCompare
" c) b: X# I2 u8 D0 i/ J* a! Y{
, G' @" Z* Z- a        //-----------------------------------------------------------------
7 e- `& L1 P9 b7 f& m4 _+ d        // Constructor
9 y  l1 i3 V3 x9 }; `- [        //-----------------------------------------------------------------8 W$ `0 I7 Y  V2 I' u5 P* B& ]$ k
        public ProgramCompare()1 S0 h7 Q/ |$ _( a0 R4 D
        {
3 {' w7 Y7 D1 ]+ H2 o6 a        }
. z5 E, E: W8 r3 M' v  |7 r$ }5 E  S  Y2 G! v# P
        //-----------------------------------------------------------------
+ c6 [# E) h# n3 p5 ~* d        // Method for testing that class has been reached( x, k+ a* O: T1 K0 U9 P
        //-----------------------------------------------------------------        7 A2 @( a  O# C1 ^% L

  i; u; N$ B9 y: b1 L        public boolean ProgramCompareReached()         1 `2 {, r* {) `% x! M6 _
        {/ l0 E6 R% K! r/ J! J9 v
      try 3 X0 K- @7 D6 x# Y- {
   {         * p. W6 I& t* Z) x
                        + g, D' L) t( f, U7 |$ A' R
                //********************************************************************9 ?1 [5 _, ~) y6 r" s  X
                // Try-Catch Statement is used to handle exceptions - such as file not found
! v* j9 `3 Y# T9 W5 J* S& A1 p                // Reading the files will need to be placed inside a Try-Catch - just like this one!
1 @  ?* l: F4 x7 ?                // For more information see page 534 of the textbook
. G1 S2 x2 N. o% ?3 S+ J) r2 `  h% K                //********************************************************************
9 U) A8 L5 G: X/ A                    
' }  q( r# {- n  C        }
5 ^, w8 m- D' P0 {% g# `, R  \             catch (Exception ex) // Exception caught here and message displayed to the screen 0 `% Z9 b5 d2 g6 B* g' y' i/ Y( E
          {/ E. w0 j5 h! n- M: d
                    ex.printStackTrace (System.err);3 I8 Z; ^; V; |9 D# C1 o: R
           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 N7 s, _1 T8 E0 g+ I' b. p        }4 \0 @' W1 |; ?4 ^! g' C& R
                return true;0 R5 D1 `  N: v) l
        }0 m1 t1 I: W. O, }
! }4 x, i  V. E, }2 b3 ^# m* x4 h
} // end of class ProgramCompare
" e* y4 p% d, F2 B% C# G3 @! U9 _8 e! e
# J/ U. @/ b- y3 t1 [( ^9 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 D1 v8 U, h3 r* J7 b! F- Y//  ProgramCompareMenu.java    Provided by: DRS
0 h  v2 g1 s8 m5 g) ]( v: L//
8 y9 o$ C; d1 Z5 n/ z( x//  Calls AuthorisedUsers.java and ProgramCompare.java
+ [" |/ ?9 Y' Z: P* A8 F8 o# i//
! }0 u1 j( t5 J6 `; E$ C3 @" e$ E//  Driver shell for Assignment 2.
' B. t% z; L: z; U+ K. E8 {( k0 j3 R//********************************************************************
& X: L) j/ v  D. w. S' I1 G9 s
, R) [7 n+ l. M2 [# _+ X) f$ Mclass ProgramCompareMenu
2 {3 L2 M1 S1 w) t. A1 O- ]9 \{
, A- u" r" d- x3 Z8 O9 v- N8 u( U    public static void main (String[] args)
* C! G, v( a: O2 L  i3 e            {8 |2 t  e$ n+ V
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- V6 M! q$ ]2 B, H6 w, L                ProgramCompare reached1 = new ProgramCompare();
( F7 t$ i* D& ]# c, K+ U4 S1 i1 N                AuthorisedUsers reached2 = new AuthorisedUsers();          q1 E. t% M& |1 @9 j: ?
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 c8 O5 ]9 ^! Q5 F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ' E/ J/ Z* G  Y
        }1 s% q! M3 h: r! k9 o' I3 K
}// end of class ProgramCompareMenu1 {7 i# }2 g1 a; A1 f+ N
% M4 o" r; X7 ]1 n# N5 M/ @
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! M4 k! X! v/ r5 L//          AuthorisedUsers.java          Provided by: DRS
5 ?7 }! W6 N8 V7 L% q9 y! W) z  S4 i& I//               
) F$ j6 n+ C. ]9 s. Q1 L1 K//         Program shell for Assignment 2' ?) F. C" ~. b! {9 N: B
//
3 d* J+ ~& N" m4 X8 l+ a//         Represents facts about an AuthorisedUser
" a9 S; m0 S/ L* x//********************************************************************: T, B+ P. Y+ V, a. W3 I

! X- x* t! M9 R5 U# r4 W8 b6 \, Rpublic class AuthorisedUsers
' N0 B0 D/ J! E) ]! n# L    {
# x0 `2 z! k/ H7 w, m
0 l0 x# \/ X" u0 w& l! D, |5 ?        //-----------------------------------------------------------------
# r. t0 j' i' w# w+ t        // Constructor, k# _+ c) o" B2 J$ A
        //-----------------------------------------------------------------
! v7 L0 i# _1 O9 t: e- v  [, M2 p. Y% G/ ~9 _, H0 I. }) d
        public AuthorisedUsers()' Z" Y4 L+ `7 ^" x9 M  s& H' C
                {
% ^# k# x' \! d" l" a& X0 E/ j) O                }
: P7 C  o$ w; R/ N8 S* E4 U8 g9 f' h, L
        //-----------------------------------------------------------------
# ^8 q0 x# x2 i& u" q        // Method for testing that class has been reached' r( b' f, @  }2 X. P
        //-----------------------------------------------------------------       
+ J+ y5 q1 ^. \2 z5 t        public boolean AuthorisedUsersReached()
* H! i- V* D# F4 o* `: c7 p                {
6 M# z; z1 Z/ t0 E. r) H% C$ O                        return true;                        / R0 H  {* @, O5 g+ U
                }
+ V1 M/ a( j" h8 r8 o& P. K6 \. M                # g$ U! \: u$ i$ ?+ o
    } // end of class AuthorisedUsers, E6 K. \% R% V- l: Y9 b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 m# O# C3 `' r) T- [+ P& L
Shanghai - 20075 ?( ]+ P9 l, z9 M
Assignment 2
* R' h" Z1 {9 x& V- B$ a! k. ?5 SDeadline 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)
" v, U- }4 ?# u" b" x% U7 b; U8 Y1. 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.
/ g! q0 c; c3 TThe staff must be able to:7 K2 B2 M3 ~# c# H  B! M9 Y$ u7 y1 Q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% g6 p5 ^( N3 ~/ 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.+ G; O6 n& B; K) L: e! e0 n: ]
 The interface should provide a menu so that the staff can:
! w5 i. |% C" B# d+ L& Z, Y+ oa) Enter the names of the two Java program files to be compared- s6 h$ _( p, {
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  l' }$ u6 q# a+ z' G+ L( ?9 {, o+ x
** 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).
2 e% {% ~# M1 v2 _7 R' X8 s' MBSA104 Business Programming – 2007: Assignment 2
* l% p: r- p7 d" JPage 2 of 5
3 R* R' f$ o5 p* J( ~b) Print out to the screen all the lines of code that are the same
7 R' M3 X8 L, k7 G3 w4 | Include the name of the file and the line number of the code being printed for each of the two files( P1 k6 G0 q4 X3 Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 p+ A* |1 ~$ b8 @
 the name, username and department of the user
2 i: b! r2 X6 ]" K, B) { the statistics of the comparison
$ p* A7 k. S( \" Y% O$ |- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
5 ]3 ~4 f& _5 T3 x& {0 U the recommendation for further checking0 B8 S4 R" ]3 j+ 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
+ l# T( w7 j0 K the names of the two files compared- h, b9 S1 A1 D3 C
d) Leave the program (exit)
: z+ b" ?6 H6 p+ Z% U5 S4 mThe ProgramCompare class: (Total maximum 20 marks available)
) k/ z8 R: _1 ~, 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)8 [8 d+ E  U4 P5 G, k1 B' b
a) provide an error message if the files are not found or there is a problem opening them
6 X" G3 M/ K$ t- \* jb) compare each line of code
: O" U, \. H7 E3 F6 B# X' x. A, ~" z2 Zc) print out the lines that are the same4 B' [2 n9 H1 r0 c3 {
d) count the number of lines compared / lines the same) u" K; j3 B. r. Y2 S
The AuthorisedUsers class: (Total maximum 20 marks available)
# a2 d, i, _8 l% M4 _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)3 o* g+ I6 \; |0 F8 L$ y/ T* M
4. Provide methods to:, L# Z1 }- }' q/ U2 n
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
  H* t, E" D$ g+ ^) g+ F7 b; ^b) return the name of the authorised user
% u* Z8 s, @+ ac) return the name of the department of the authorised user
9 \; w) i# S6 i. j4 V- L0 wIndividual Data (Maximum 20 marks available)/ [+ u  h1 Z; z/ E
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.2 i2 N6 l/ D0 @1 e/ y$ E
Documentation (Maximum 10 marks available)
- U  X; H& @4 e6. 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.
$ [  |/ d1 K5 q* ?4 \5 \BSA104 Business Programming – 2007: Assignment 2% ?. W) F! ?# Y( w
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
" e, B5 v3 b, y不过你要翻JAVA的类库说明。你有下载没有?
. o, s& L$ u/ M查询关于对比的函数。貌似关键字是contrast,还有compare
( S- {! E$ T; M& R
! ?' q# }& l4 Z  J* K: x# ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% E9 w4 c6 C( c; R' [% [" B
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ L; w9 K% r7 S4 H8 V/ w可以下载到的 是 jdk-1_X_0-doc. U+ a+ ~# b5 Y. S8 E2 @7 d4 V

( O/ a8 m& Q# M3 I3 J6 P- L. \[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-28 07:17

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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