找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1419|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急5 L: c: s8 g2 `3 k6 h+ } 9 b. ^( M) j* T9 R3 Q% Q# k
回复

使用道具 举报

 楼主| 发表于 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 p4 D7 }2 r) \. c/ i, c
//  ProgramCompare.java         Provided by: DRS
( ?5 W: ], }" z/ y//* m+ i6 [0 u3 j9 p( i+ u4 N
//  Program shell for Assignment 2
7 n4 Q. x7 F$ \4 Q! h$ n2 i# R( U//4 t* s9 D, L8 `. d
//  Compares two text files line by line
/ \  _5 Z9 k2 O  o% X1 }; y  C//********************************************************************** s* ^! B7 X& f( r* W7 h2 U6 j& d

$ ?. X: `7 w9 L" U8 R  B9 timport java.io.*;" R" @0 U" v. F$ n

) ?8 V" k: b6 l4 e2 S! jpublic class ProgramCompare7 X$ e0 E7 X) ]) z* S" T3 k& D
{# S- m# ]: I, Y- y( E8 s7 ?7 ^- B
        //-----------------------------------------------------------------
, Q5 O3 ^& S, J; }# o6 K5 T        // Constructor
  o' k* g$ P- \! X, e        //-----------------------------------------------------------------. }- d0 W& X9 n: D! t
        public ProgramCompare()
$ e6 W8 p+ c0 h% K0 I" t        {" x! u# P+ A  a4 Y4 Q" m
        }% Q$ b9 [0 f# i

" |4 Y. |0 Q! o) D3 B        //-----------------------------------------------------------------/ @0 w; g+ B/ J- C/ d, ?+ G
        // Method for testing that class has been reached
' m( p# b$ k8 @6 Y+ ?        //-----------------------------------------------------------------       
) f0 r: s& k% H7 V/ Y9 u" O+ ^$ d5 R4 P) ~
        public boolean ProgramCompareReached()         . {8 o+ k% J/ \- F
        {/ c. N2 Y( q& z6 u
      try 7 D. C! F" X# }0 e
   {        
) E; Q/ j6 u: R$ \# t' u7 ?                        & M1 Q: t/ @& \2 q* G' V
                //********************************************************************
  }" M; |; V" j# I3 ?                // Try-Catch Statement is used to handle exceptions - such as file not found
3 {! e( }, k: v                // Reading the files will need to be placed inside a Try-Catch - just like this one!
7 ]( y8 n0 R+ a+ X                // For more information see page 534 of the textbook
$ y( j( n. M* z# x) t                //********************************************************************1 X! ?9 @( t: k7 L
                     1 |' |2 y6 {- \& }/ u
        }/ S' T# ]' t6 f; {/ R3 n9 ?7 {
             catch (Exception ex) // Exception caught here and message displayed to the screen 6 J" F" ~  w/ s$ f- E$ l: ?
          {
8 o# S: n, B+ {1 C" X" q                    ex.printStackTrace (System.err);
8 N. L  |) x5 x/ d' B4 b           System.out.println ("Error message goes here"); // Replace this error message with your own          1 i. c: v1 u9 d; Q* Y
        }3 G4 p) y- w8 ~: y* p! O; n3 I4 @+ C
                return true;# h7 _" n# ~' z  n, e/ n2 D" |
        }& S( a1 z. o3 m' t* Q
2 m) j* k0 H' b# b! ^* t4 O
} // end of class ProgramCompare
" ^, h" }) y7 M1 g% _9 N6 ~) m% s/ M! j/ n. \# @
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 A  W5 f; }9 N1 I- I
//  ProgramCompareMenu.java    Provided by: DRS
  T: T! M7 O; l//( b7 w7 z! C8 T7 W$ k0 Z3 N
//  Calls AuthorisedUsers.java and ProgramCompare.java8 e, c5 D9 w- j
//( ?& ?# O6 _% C' w/ {, i
//  Driver shell for Assignment 2.
3 l' ^/ _. R* \5 ^1 P" g8 u//********************************************************************
* {/ \! y2 s. F9 z
1 K3 B. @, Q( ^" qclass ProgramCompareMenu$ E7 |- W" u1 e. P
{1 i  o) C4 t. b- V8 n
    public static void main (String[] args); Q" k7 D) `* y1 I& H
            {# _9 E+ v  c) i- m/ c& s
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& S4 G, V) Q3 s3 E1 f1 ^& r* k                ProgramCompare reached1 = new ProgramCompare();
1 {2 m% p  [/ D                AuthorisedUsers reached2 = new AuthorisedUsers();        ; j3 o8 u7 l( A7 ~' {
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 O" |" p- x& p2 j$ w
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ' r5 R2 z; i  W% D4 F
        }
, |, T+ i( y) B4 D+ F; l; n- f! g}// end of class ProgramCompareMenu
  |8 l& l, g* J) K' F1 r1 f7 |) }
) e  Y1 _" ~0 h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! A- z8 ]: F$ f8 w, o- M//          AuthorisedUsers.java          Provided by: DRS" s4 `2 ]  T. s9 E  I
//                * K9 x( b. S7 l" g% A/ J7 o( ]
//         Program shell for Assignment 2
3 ?7 s: J8 z+ B3 @, A//# h+ w; R& I# N8 ^
//         Represents facts about an AuthorisedUser* @7 @3 R9 ]- d! u$ Q
//********************************************************************
' `  m+ Y7 {7 {2 |
6 o% b0 x4 ~- Lpublic class AuthorisedUsers1 U. H# D- z, `; p5 y5 r
    {
. _0 c7 u5 l. \6 j9 z* [  B( Q/ ^, i2 l1 @" y
        //-----------------------------------------------------------------3 z; ?! T- o0 h( @6 K
        // Constructor
- D) ^  i$ ]) L) A3 g        //-----------------------------------------------------------------. ?1 [9 o( l7 y- i

4 a2 _/ `. D# t- u        public AuthorisedUsers()
% l) r9 t8 @( J                {2 {. v, V# a: P1 r1 e. L
                }
4 }- P& Q6 F* V2 p$ d9 o7 _( N! z
        //-----------------------------------------------------------------4 K' m$ ^) u# t
        // Method for testing that class has been reached7 b" I! ^6 j+ U- d7 ~
        //-----------------------------------------------------------------        3 u9 R7 U# h# C
        public boolean AuthorisedUsersReached()0 L  B: }9 P- K$ Y8 [( o, E+ T
                {2 F' R7 b4 B8 Y" H( z* _  r4 S
                        return true;                        ; }  c% j+ v) @6 \5 L% s
                }6 }" G. H0 d$ h* b: \3 F
               
' C; C' Q  B& E4 y$ X+ x4 w    } // end of class AuthorisedUsers
) P6 \5 T+ K' w9 h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! P) q$ W+ j/ h; V/ ZShanghai - 20076 P3 S: Q4 D# c0 [
Assignment 2
6 K( d' t1 {8 P' G. j6 pDeadline 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)$ @% r; l! z3 h5 @, u
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.
) R* U3 u- `1 D7 IThe staff must be able to:7 {& q' d) Z2 Y5 L
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* ]' M5 V9 ~, H% p  P' R4 N1 w1. 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.$ M# {3 S9 b. J5 U+ F9 U/ J! m
 The interface should provide a menu so that the staff can:5 Z/ f' S9 q  t) n7 E5 ]" o3 j
a) Enter the names of the two Java program files to be compared
' }/ ~% |  {1 g0 v5 ] For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 f+ v3 a: [0 t. b. Y( 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).
3 r4 w4 g- Q4 N, {. c( GBSA104 Business Programming – 2007: Assignment 2! A- U1 T1 F, s" ]- _$ `
Page 2 of 5
5 ~& M4 j# y7 Rb) Print out to the screen all the lines of code that are the same
* Q% _# w8 c5 J2 r! L, S Include the name of the file and the line number of the code being printed for each of the two files! w) Z1 T, n& `9 \3 \7 j$ A
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# y' e9 }1 ^5 C* G$ M
 the name, username and department of the user* J5 W( b5 C% c
 the statistics of the comparison9 H% C9 p0 w9 i& m* W3 f' l$ O: e
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 v1 C+ O# J% o  C1 @ the recommendation for further checking
; I3 C: Q2 B% T5 f- 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. e1 l3 i" S
 the names of the two files compared
: P- I8 u( g- Y+ h$ D8 Vd) Leave the program (exit)
2 Z' ~1 `1 X+ Q, P/ A) f# xThe ProgramCompare class: (Total maximum 20 marks available)
- {" E0 l7 w3 L2. 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)
! X9 k! }/ d: Y- X* l  L3 K( e# Na) provide an error message if the files are not found or there is a problem opening them3 c$ s% d- A" `6 A# H3 a, V9 A
b) compare each line of code
; O# B* [/ `. J4 H/ Ac) print out the lines that are the same4 y1 j9 ]8 k: P
d) count the number of lines compared / lines the same+ i6 ~3 k$ T# g4 J' n2 D
The AuthorisedUsers class: (Total maximum 20 marks available)
2 {6 _% t1 p/ Y3 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): n. H; ~9 Q: R! ?
4. Provide methods to:; e0 m$ g+ Z# b5 z2 y2 I4 e& \
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; v8 g  l: s( H1 t$ ~
b) return the name of the authorised user
* E4 H3 f2 s( w, Rc) return the name of the department of the authorised user+ d' Y% W- A+ n" w. R7 y& U
Individual Data (Maximum 20 marks available)
( T6 x0 c) E2 R" R1 x0 ~# q1 v5. 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.
  w1 y' [( j( D) V" N( D8 N" p+ _Documentation (Maximum 10 marks available)
2 N: {! e0 g: d  }# q6. 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 ^# C- k/ Y1 R% i8 q- x  A/ Z# z% ]( \BSA104 Business Programming – 2007: Assignment 25 f' p- z# I- h' @  ]
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
0 X7 k! M0 }" t/ m不过你要翻JAVA的类库说明。你有下载没有?5 R8 [( Q8 {( ^
查询关于对比的函数。貌似关键字是contrast,还有compare
, d; i+ {# z' O! |. W4 G' V. H% F& P' v0 i' m# s
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -; Q  Y$ Y4 Q% ]$ ]$ A) A; q* e( }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" g3 x+ j6 R. I* k3 ]1 i可以下载到的 是 jdk-1_X_0-doc
, D( {# l! W. m# ?
: N3 L5 k4 K* \4 P' E4 n* Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-27 15:57

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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