找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1373|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急$ [+ T% j# T/ F) E0 H " n+ o/ O' Q. T; m4 {
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************( k8 ?$ [% E1 k
//  ProgramCompare.java         Provided by: DRS, Q* c1 G+ n" y: Q
//+ [! X2 Y( c# Q' r- d# H% G
//  Program shell for Assignment 2
: V! [0 G/ W, m7 Y0 L: f) }2 o//, |; W. A' J* `9 k. y$ P2 d" m
//  Compares two text files line by line0 s0 j' p" o7 O7 A
//*********************************************************************0 n* J- \( O1 f! H9 ?

! H3 d% d/ ~- Rimport java.io.*;
1 e* a) v: z1 v" [6 @- @, X( j- m4 O1 W7 o& N/ [  U
public class ProgramCompare
5 ^  h. b5 s8 Z. R% j, E8 z{
! y  ~. s3 i7 i        //-----------------------------------------------------------------
' h' b; ^" O4 H        // Constructor
" D6 e9 q% o. M* C& Y" K        //-----------------------------------------------------------------
0 w: G( S. Z+ p9 M: R+ B        public ProgramCompare()) l+ ~& F' D( a8 h; {. F' j
        {
3 }' A- b4 @/ l: _+ \        }4 I! w' L3 x4 N. f- |

7 V: R4 _- l/ P/ v/ ^+ r- F1 a# U        //-----------------------------------------------------------------/ e) u4 a, T) W4 o2 k( b/ C) Z
        // Method for testing that class has been reached
' P4 B% z. Z& e' ~/ z        //-----------------------------------------------------------------        $ x; W6 ?# h6 c

, N/ J5 B& L, D* G3 L        public boolean ProgramCompareReached()         ) x) y$ Q8 s' w
        {5 p4 H) O) _& Y
      try
# @5 P) e# S. s# _' }4 L- _   {         : v6 }7 Q' H+ T5 [6 s: s
                       
4 c! W) p# O) F) s& X7 z1 ]: F# J) O                //********************************************************************
1 p  [1 j5 H6 e2 F+ J                // Try-Catch Statement is used to handle exceptions - such as file not found
& w' s' \5 _; X+ T; b                // Reading the files will need to be placed inside a Try-Catch - just like this one!' P4 y4 A+ @( ~$ k
                // For more information see page 534 of the textbook
# e# i2 E- r. c* s" ?9 x0 `# R                //********************************************************************0 {7 |; G. r9 K
                    
/ B1 ?( Z0 n$ x' o3 m        }
$ F% V8 h2 m' U- w) y- }             catch (Exception ex) // Exception caught here and message displayed to the screen ; t8 w4 f$ ]$ k
          {
; T" d3 d* H" o. d7 S" p                    ex.printStackTrace (System.err);
2 R+ T) C7 I+ K5 |% k           System.out.println ("Error message goes here"); // Replace this error message with your own         
- l( ?, |/ Z2 Z  V        }& ^+ ?! S+ Z- e5 C$ r" _2 m+ j
                return true;) v2 o% {! I0 k! K, |
        }" ?0 M+ L" p, N
1 B5 L4 L0 P" v' r* A
} // end of class ProgramCompare
5 R; L% Y' ^" Y. D/ c) y# h6 B* O% ]6 _0 t  y6 v7 b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 H  u* L0 |- k" r
//  ProgramCompareMenu.java    Provided by: DRS
. N9 @  D; X. ~6 s5 U8 }//
. ~( a3 H6 U+ X/ u, C- f//  Calls AuthorisedUsers.java and ProgramCompare.java
& T" U' H. C  p6 a* p//
3 Y4 r/ K( J/ K( J//  Driver shell for Assignment 2.
  `1 Y- B# X9 d/ |1 I* K' j//********************************************************************
4 Z7 r8 N5 H( C4 R
( c2 G6 N1 m& h6 P2 F' D: ?& u& g) Mclass ProgramCompareMenu; j& A9 I2 I" L' M' ~
{
) h8 f9 r+ Z( t' V* y    public static void main (String[] args)
- w( y$ V5 T0 e            {$ Y4 {3 b$ K" c7 @5 U8 F0 `
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& s3 ]& c8 t6 o- ~* r
                ProgramCompare reached1 = new ProgramCompare(); ; J& ?! t% p. c9 t% l
                AuthorisedUsers reached2 = new AuthorisedUsers();        - {" e1 n- z& S. D. e3 g( ^: @
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
4 }- b/ k& W! Q                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + K2 z# c+ A) X) p
        }
6 e- o, G3 k" K6 w. e4 x+ k}// end of class ProgramCompareMenu
) F/ d: _4 l6 m/ ?- o. x7 o
! Y! Z4 x3 y' H: Q. y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 {" U. e2 K$ v/ A
//          AuthorisedUsers.java          Provided by: DRS
' t# S+ b- P( N% `9 [//               
4 G& x3 ?  c" v7 F& w  F/ _& i3 d//         Program shell for Assignment 2& I5 d6 h& ]  y8 Y9 \
//+ Z9 X1 g3 |% K+ Z  s
//         Represents facts about an AuthorisedUser8 E( y9 {; K% e3 |
//********************************************************************
' Z' `4 j, }% x, w: F2 a$ ~  f" x( g
" W. ^1 \0 Q9 L* j5 \: U3 A) U8 Cpublic class AuthorisedUsers3 W# L" ]0 u7 l
    {7 L4 a9 v+ W8 b8 K7 G3 Y. a6 P

% q7 H' j( m* u8 y  C4 x2 f        //-----------------------------------------------------------------
/ k1 o  M6 |9 k% w: W& C) r        // Constructor( g9 J# r; ^$ L+ E) k. s
        //-----------------------------------------------------------------
- ~" G& N3 p( M( i. \$ {7 _4 X. u, Q3 e
        public AuthorisedUsers()
6 M4 U& F) c+ t+ v* `% C+ q3 N                {5 @8 G5 V. d& J/ M4 g
                }- ^( w: e7 j4 X/ J

& o& S5 @- f2 }0 f" e; |0 J7 x: O        //-----------------------------------------------------------------
- M% {# [' U# x4 q        // Method for testing that class has been reached
3 y3 ~+ q/ H1 H- X        //-----------------------------------------------------------------       
2 S8 X) C8 w0 N2 |  x# D7 u        public boolean AuthorisedUsersReached()
& s5 ?5 I* R& d# W                {; @2 j: e# X$ f# W  f
                        return true;                        ' K3 {& ?' R4 Z7 E
                }4 v& L' }& g1 S7 m
               
# F- s# D2 b8 m5 j6 V    } // end of class AuthorisedUsers
& b/ F& o6 t) \, A' G  k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 ^% Y+ z& m2 l) l+ O) JShanghai - 2007
& H) s# i/ B+ N0 p# ~Assignment 2
" P3 S5 \1 m/ nDeadline 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)+ Z) v+ b( L) m5 o8 H  y# o
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.
' h6 F9 E) w; Y  ~' |The staff must be able to:
6 o+ W, C  Y  b7 [$ _4 `& ^9 A+ p Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" i2 b1 e0 c: w7 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.
2 B& c5 \5 L5 h! S( }1 { The interface should provide a menu so that the staff can:
$ \. Q) T/ B9 T! ba) Enter the names of the two Java program files to be compared0 h/ Y1 B! e* @
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.; \# X5 D. \9 }/ 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).
# Y# E0 f/ D" EBSA104 Business Programming – 2007: Assignment 2* K- N) V) p; e# k- {) r
Page 2 of 5( @9 s  d$ n' l3 y# k. H' S
b) Print out to the screen all the lines of code that are the same
# r' h! B) g  S! m. O1 q Include the name of the file and the line number of the code being printed for each of the two files7 ^3 e$ Z7 N2 _/ z, ]5 E6 c
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared- J, R! @7 k0 N- @* E0 [
 the name, username and department of the user
8 c( L) P; [" j6 p the statistics of the comparison; [2 b8 P# \& ?4 n9 b
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
- s4 a9 @6 ^# E+ \7 z- J the recommendation for further checking
* |9 K/ t, C/ M2 `- 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. v# q  I, o& e; F' L  E' _
 the names of the two files compared/ d, s" f! F! H5 `$ F
d) Leave the program (exit)- F0 O! ~9 }- L: L: {/ k
The ProgramCompare class: (Total maximum 20 marks available)* I8 y- V4 o+ b# 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)
. \- q( }7 c: W4 {# W$ @2 y  Ia) provide an error message if the files are not found or there is a problem opening them3 ]* U% O) d3 t/ J# y. a* @
b) compare each line of code
; c' j/ }' c+ m( V' Pc) print out the lines that are the same
$ A4 X* h3 u$ X( _$ ]3 Td) count the number of lines compared / lines the same
5 ^' z- L4 e( L6 q- w0 r! M/ ?$ }The AuthorisedUsers class: (Total maximum 20 marks available)5 f+ y* s2 Y  D7 K3 H+ s* J+ X
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); P+ B3 V9 h& B4 Y, t+ d! ]7 f
4. Provide methods to:
4 G( @& ]' l& p$ Ya) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match0 s' T6 b" N" I9 F( ~+ ^8 ^  |
b) return the name of the authorised user
) I  c1 ^! i% l9 O4 y) m- ?: Yc) return the name of the department of the authorised user) Y# Y3 s- z2 S" Z* c
Individual Data (Maximum 20 marks available). \5 s2 S- S1 a5 Y# _* N8 l
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.$ O1 {8 S+ }1 V) _& b# U
Documentation (Maximum 10 marks available)3 M( x. W  C$ t* G  y6 c' w
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.
; C: O1 L, Y/ o- `0 }( H3 ABSA104 Business Programming – 2007: Assignment 2( Z: G$ }1 L" Y! V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了! R0 |6 R6 b0 n. o6 k
不过你要翻JAVA的类库说明。你有下载没有?. f; b& T8 ~# _/ P$ h* I/ ^6 N
查询关于对比的函数。貌似关键字是contrast,还有compare
) F5 f- }; m1 H* J
" W. C  s# T- r! b[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& b/ T/ Q* y% ?1 r- {) T" o$ Q6 h2 v
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 i. B1 E! t, G& F" [) P6 t
可以下载到的 是 jdk-1_X_0-doc
& L' j  H1 J  M! R8 Z' n
* h; y: h) |7 V[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-10 13:29

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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