找回密码
 注册

QQ登录

只需一步,快速开始

查看: 932|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: a6 v2 Q4 P3 i9 @: h' j t 9 Z! h0 k. _, 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 | 显示全部楼层
//*********************************************************************
- P2 J) e' S9 E* B//  ProgramCompare.java         Provided by: DRS6 J5 E( Q% {/ U' b$ G
//( `  X4 m* I; p& C% S. y
//  Program shell for Assignment 28 S  f* B9 w3 K
//" V! J: x) h9 z: Y/ I
//  Compares two text files line by line
2 Z2 b' j) W% N0 D# r9 H& }" F//*********************************************************************
4 {; [  W# x& |, ^6 w
+ M% N; r4 N8 S7 L* gimport java.io.*;
! h! _- q" b* N+ q) Y) ?9 P1 _9 {/ z: ^# _4 \% o$ j
public class ProgramCompare
0 B+ p. M6 r. i' s0 p0 o{
6 ]' i3 L5 \- P- O9 {+ B        //-----------------------------------------------------------------
: W8 j5 W1 _; F) t% u        // Constructor
2 Y% x( X3 B; |4 Z" X$ X7 T2 Q4 i4 \/ E        //-----------------------------------------------------------------  b2 D7 x8 j/ a+ o2 ^6 b! F
        public ProgramCompare()
/ ^- P0 a" A+ u1 m& P! k        {
+ O* H: ^, m, q" C) w: w        }! r- b% t- U6 q8 Q4 w; x$ l
6 t/ Y( d2 [0 D) q2 @
        //-----------------------------------------------------------------1 c$ f: I5 W8 X' b* j7 `" Y% S3 v
        // Method for testing that class has been reached; B: @) z/ N! `: N
        //-----------------------------------------------------------------       
9 U8 t4 D3 Y& L8 L. [5 M! b# `" l& K1 \$ ^. s
        public boolean ProgramCompareReached()         ) c5 N+ [% E4 j
        {+ ?: c2 E: {: o" M
      try
# U4 @+ B$ |# R3 F) \  y   {        
3 [# o4 d' p8 j$ S& Q" A5 k4 a                        2 n5 A0 R7 q  }! Q3 s7 b% z# ]$ `
                //********************************************************************) |) F+ v  y$ m9 y8 k( D& ?& j) c
                // Try-Catch Statement is used to handle exceptions - such as file not found
& d" P0 E, b$ Q% \  {                // Reading the files will need to be placed inside a Try-Catch - just like this one!5 @8 u" w2 x3 y0 \) Q2 F2 L
                // For more information see page 534 of the textbook0 g" r" h! R8 }* s
                //********************************************************************
7 ?, ^  [) }$ W; M+ `: z0 _                    
) E6 I) Z0 n' `  z- V+ b# l( ~; y        }
- ~3 t) `! w) [! b$ E4 Q1 K  w# Y             catch (Exception ex) // Exception caught here and message displayed to the screen # z$ I1 n& a( C$ E* p1 T
          {
% p/ y$ n$ [" V6 D                    ex.printStackTrace (System.err);
# ^, R+ s. x7 m           System.out.println ("Error message goes here"); // Replace this error message with your own          ( N( K+ ^! u- `+ u6 J
        }2 W/ I, ]- ~, {4 j3 k
                return true;& C6 _& Y9 E+ e2 h- C/ i4 i
        }
, B' S& c" x6 z* G0 a- k' W
5 ^( h4 f/ G; z' c$ k, I} // end of class ProgramCompare
, f! o  b1 i4 V2 _
5 Y# C6 D' l" v8 w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& y) ^' i: |1 g4 d2 r* f+ g8 h
//  ProgramCompareMenu.java    Provided by: DRS
, M/ Q( ?- w) ~& O9 X//
% ~; N3 H; d0 D6 _' R$ O//  Calls AuthorisedUsers.java and ProgramCompare.java* ]0 ^0 u# G/ H' ?$ W
//, R. M$ [1 f2 d" Q! o, k# y6 d3 i( s* b
//  Driver shell for Assignment 2.* B# N) a( G0 E* X, b% _
//********************************************************************& {5 X$ v1 ~2 a7 o1 V8 N( A* a
2 d  U' h8 P& p% K5 g0 C
class ProgramCompareMenu
- [* f4 w' l5 P{& J% V* ~/ t$ `( s6 u
    public static void main (String[] args)
- J9 b3 W5 H7 O            {
' o. V6 x' q* d" P& Y5 m% z0 ?: j. ~                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* e1 X3 K! h  N( `  @  s                ProgramCompare reached1 = new ProgramCompare(); & Q- J0 z5 h% g8 D' {
                AuthorisedUsers reached2 = new AuthorisedUsers();        5 O' W! Y: t# A, u! Y& o
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' |, V$ Q8 t7 e2 X9 l+ _( [
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
4 l* ]5 `$ n! F. d  ]: P        }* A* ~2 J1 J. B1 y9 Y+ q
}// end of class ProgramCompareMenu+ y3 x: j9 l+ |" N& Y0 _) B

4 V: f4 k; U% `% C& Q4 B6 z7 s3 F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) h8 m  `- h/ N' v* k% u7 J9 {+ z
//          AuthorisedUsers.java          Provided by: DRS
6 k4 C" v8 H' m6 R- r! I//               
( J' \6 `0 }' r//         Program shell for Assignment 2# T3 ]- w, C7 j) ~* Y* B
//; R4 p7 G* S" J+ n' p+ L8 O
//         Represents facts about an AuthorisedUser% t2 O+ k0 _% \" ]5 k. z
//********************************************************************  T4 A" v9 W5 q

. z! E- U! m% r5 p5 N0 Dpublic class AuthorisedUsers
2 {, V# `5 X. U* s" G: P' y3 |    {
# X; ?' }5 h4 X+ y; b( z& b* n8 \/ K, |# o! X
        //-----------------------------------------------------------------
$ F- \6 w+ U( d$ G' [. G        // Constructor3 m! Z$ |+ T# d6 C
        //-----------------------------------------------------------------
1 N& P4 B8 U% N0 l$ h7 e! ^9 @) ~% H! G6 j8 L7 b- ?/ N6 q
        public AuthorisedUsers()8 w. F% k9 P5 d7 _9 U& s
                {2 t  c- E" L, R5 ~5 T
                }; Z7 y0 b1 \+ ~" N# y

. C2 T& z) `  f# T2 x% w" j5 T        //-----------------------------------------------------------------
3 W8 f! a: z; y        // Method for testing that class has been reached$ X2 q/ A: O: h0 B# H: E; Z
        //-----------------------------------------------------------------       
: }- ~. l+ }( M( I2 m- w        public boolean AuthorisedUsersReached(); L. t: z6 U9 u: Q' S! g. e
                {
7 t' }& H+ ~3 f9 `  N3 b# \- a                        return true;                        7 W7 i, f. |( C) G2 h) J$ l
                }. j6 q. v  P6 @5 H. @9 I( U8 g
                1 D* Z% y* I$ s6 B5 F
    } // end of class AuthorisedUsers0 E+ @, `) P/ p7 L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, C& g6 K/ I. CShanghai - 2007
+ G, m3 T5 P. h6 a3 J  k) o9 {, H7 MAssignment 2
" t. R& P& S% V9 F$ i% G. H' m% zDeadline 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)
9 T* g2 X- Q0 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.& A9 i. o% P# `6 N2 a# ]
The staff must be able to:; G4 z6 k, Y7 [/ N/ p
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 L5 X4 h9 p: M6 H* ~
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.  }3 U) p, G4 G  G6 R- C5 q
 The interface should provide a menu so that the staff can:
. O2 R8 g, ]( u: La) Enter the names of the two Java program files to be compared' d9 R" ^/ ?* v& n
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# _9 \& L$ ~" K/ v** 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).8 D- s& P* u- }+ B+ ~$ L
BSA104 Business Programming – 2007: Assignment 2
+ C7 p4 Z" ]" q3 N# p0 zPage 2 of 54 a6 _  b( }& h% T$ G$ ^2 V
b) Print out to the screen all the lines of code that are the same
( N5 C! ~5 O" [6 ^ Include the name of the file and the line number of the code being printed for each of the two files$ e. o0 X3 _/ S9 ~$ t% W
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
$ n) ~) X' G9 L2 @3 e6 v1 j! B the name, username and department of the user
5 {4 W% f4 w8 P6 F7 V7 h the statistics of the comparison( J6 v; }* |+ g' g8 O6 \) Y  [) h
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% @) r/ D) p/ l. q the recommendation for further checking) e' W4 q7 u* a" q. t
- 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
, C7 \1 S8 ~4 Y0 i( Q8 j the names of the two files compared; m* R6 F5 ~0 S( B. Y( `' U2 O- e
d) Leave the program (exit)
' [5 g5 u/ k% }, U, EThe ProgramCompare class: (Total maximum 20 marks available)8 F9 z: g  ]1 I
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)
4 Y6 b: Q- i# a8 g) Q; Oa) provide an error message if the files are not found or there is a problem opening them  A# r, Q! ?- {% L
b) compare each line of code
% t% t6 u- E/ T( a& z5 T$ e3 A9 O5 zc) print out the lines that are the same
+ i0 M! |. @. I& ^, V. `  F0 Kd) count the number of lines compared / lines the same
1 i; ^2 Q. Z! M! FThe AuthorisedUsers class: (Total maximum 20 marks available)
0 z! ]$ a: M/ e9 o3. 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, M0 Z2 F/ ~7 }) z" @
4. Provide methods to:" ]$ @+ D, {1 A9 Y
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& _& }7 f' o3 q$ f
b) return the name of the authorised user* U2 n0 }/ r8 i5 d! k
c) return the name of the department of the authorised user+ f1 o  _* P6 ^0 O) V: a) F& y
Individual Data (Maximum 20 marks available)# P+ R$ {1 J* @1 Q; 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.; W- P! i% c4 S' K6 z/ [( i* a
Documentation (Maximum 10 marks available)6 ^; Z- Q; B/ z% D
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.
" {) g- _. c8 b- {BSA104 Business Programming – 2007: Assignment 2
' b/ k5 s( s+ L% D# o  X. a1 R# qPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了3 [! \6 ?: ?( C4 T
不过你要翻JAVA的类库说明。你有下载没有?/ c5 i: R4 Q2 M$ R6 B. s
查询关于对比的函数。貌似关键字是contrast,还有compare& ^6 L( X& m3 x" ?9 A$ V. |
8 ^, @' Y4 o  ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 t5 ?  ~5 J7 x' V# N
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- c$ j; @3 I$ k, K. w& T% s可以下载到的 是 jdk-1_X_0-doc1 e  N0 o/ v( H1 r" p: P# l
7 X9 e! D, k& z, X$ i3 w: @& `
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-10 08:51

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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