找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1339|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 ~0 N" k7 {0 ?2 @ & b& \* u* X& z7 F) j
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
+ A7 d: C. G( T8 C+ H( O# d" {! r//  ProgramCompare.java         Provided by: DRS7 u5 k, h! j' c+ U
//9 m. C/ \- {/ z8 W
//  Program shell for Assignment 21 f3 e1 `& s" m( g3 S+ e
//+ j( [4 L6 o+ d/ A. ]
//  Compares two text files line by line
& M. H; ?' x0 G/ Y& q" V' i( @4 S9 e//*********************************************************************
( E, D6 d% \3 U
  C. G- I: s( A7 U' Kimport java.io.*;
* _) a# \! V0 m2 M7 P# k1 f' \5 z$ p( p$ `" B$ f$ J- K- H5 h% b
public class ProgramCompare
3 |7 G+ o9 \; I4 V3 f9 E6 M{. C- Q( x  `6 w& F) S1 Y8 A
        //-----------------------------------------------------------------" Q3 o7 j; ~" ]8 g( O
        // Constructor
, }3 m" Y0 X1 U; k- T( y# p& f) s        //-----------------------------------------------------------------
' p" O  n& T% ~& t7 y% _7 l) b8 Z+ O  G        public ProgramCompare()
9 L/ R3 f4 \. X# A6 v. n& M        {5 V* X0 \% L0 [' v# b( K& ^% T
        }7 Z# j, C+ }+ u4 W3 C. E

, `1 r! g2 P: S5 w, N; w; A        //-----------------------------------------------------------------" @7 Q: H! j# P$ y+ h3 [7 [
        // Method for testing that class has been reached
& ~/ L4 ^3 I6 g- T$ r$ `! r        //-----------------------------------------------------------------        ) W) s! E$ M: k+ g0 J

: S9 i/ j1 V; b1 k$ d6 |5 S        public boolean ProgramCompareReached()         : ~% U- U& E8 s4 ?0 U+ m
        {, S0 O& F8 W' x. Q. O
      try / O3 B3 W+ Y7 V! O; j
   {         0 }( n" O+ @7 ^3 c2 U
                        2 ~5 q2 o% }1 ~- Q$ J
                //********************************************************************2 Z7 Y% y1 s. A+ X3 y; I: M. @4 B, M* G
                // Try-Catch Statement is used to handle exceptions - such as file not found
: ?$ _) S. V! t: Q- h4 o, n& J5 M                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, j8 y* b: C& j% O4 M$ B1 f                // For more information see page 534 of the textbook: l/ r, z! T+ ^
                //********************************************************************* X+ s% y0 W# {8 D
                    
  G, j! f" \# ~3 h0 K! u* w        }
4 T% E2 `9 {9 s+ s3 g& x             catch (Exception ex) // Exception caught here and message displayed to the screen , W1 a& L# j- Z" e6 T/ E
          {
9 A; W* T4 e' H' E                    ex.printStackTrace (System.err);
9 M. c4 `/ j- |, g$ M           System.out.println ("Error message goes here"); // Replace this error message with your own         
6 d3 z1 i- D$ c1 ?- k$ O: |( I        }
/ h$ _3 o  `/ l3 ?                return true;
$ S. M1 @+ M2 B  _7 [        }4 ?$ y: O# R9 y. O! |, Q# T
+ H9 x! o2 A8 D( j1 R8 o. C
} // end of class ProgramCompare# c2 O8 Y3 f7 p# f2 z  d& s  x0 x
2 a2 `+ p; P9 S) O  M5 H! M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 ~" m) p: l6 h( L: n& u; j. ^9 G//  ProgramCompareMenu.java    Provided by: DRS
2 V( {0 `+ l  l0 `% P* v//
# Q) w) T4 ^9 ]" E! U  m//  Calls AuthorisedUsers.java and ProgramCompare.java
* b: G$ ^- ]2 w5 G6 h& \1 B//
1 t- l, {3 \8 C: A: f* _) w5 m//  Driver shell for Assignment 2.
- Q3 E1 `, g, l0 t1 l//********************************************************************
/ ^$ T0 S) V) _5 c, q* M( O3 B( j; @9 x; Z1 S# ?
class ProgramCompareMenu$ _8 ~' K; F. v' ]( t
{6 U! y+ u9 N6 v- y1 R3 j
    public static void main (String[] args)
* m2 x1 q$ z  A' ^            {
% P. l: h* B+ _( T. q& T, ~  p                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable) h( E' r8 c- y# F" r3 g
                ProgramCompare reached1 = new ProgramCompare(); $ @2 B+ m. G% I) [4 ~- S/ j
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- ~4 S5 i# U' t* S6 w* f1 L, ]) d7 X6 G                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ V& ^6 {* _3 U' j8 [+ B7 F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + G7 E( t, k2 Y: U) f2 V
        }. d$ Q3 u/ \4 V
}// end of class ProgramCompareMenu
9 K% J% q2 B1 p( o$ Q
+ J: P% }0 R  R9 g/ ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
) A% @& x% g) p+ U//          AuthorisedUsers.java          Provided by: DRS! S+ X1 }& l* Y4 ~5 q' R9 Z; ?
//                6 W1 F1 P- H. n5 e4 h  O7 e7 I
//         Program shell for Assignment 2" D- f! C9 e6 z/ b
//4 x) l& l' F' r( T! S3 |
//         Represents facts about an AuthorisedUser
5 s( S: b, r5 X//********************************************************************$ ^+ w$ z! f; I& o0 d/ a+ a
+ W- }, H  v" Z' T% o" P
public class AuthorisedUsers0 H6 {/ _: T6 @* W- C8 v/ r
    {, I4 k5 D' ]; e/ k& f' j, @: N

4 n6 Z6 J5 |, z  |4 ^8 c        //-----------------------------------------------------------------
% H* P7 ^) _2 _1 [7 ~/ i        // Constructor% s* z: K2 y* n" w9 K) m
        //-----------------------------------------------------------------7 x# _- v9 @: D& u6 r! e
# i  h( o) K' P3 g
        public AuthorisedUsers()- N" N. N: Q( _+ ^" c& X  i0 ?
                {) _  ~2 {$ z* R9 m- g+ g0 [& M
                }
8 Q; G; P! t3 D9 t, T7 h. Z8 }+ g# Q8 ?
        //-----------------------------------------------------------------
/ v# l7 J& S* B! [# ?/ q/ k        // Method for testing that class has been reached  _: z  x& _: l: M' g  n
        //-----------------------------------------------------------------        + K8 p1 A! b+ N1 H4 m1 r( T- l7 h7 k# O
        public boolean AuthorisedUsersReached()/ {* v7 B/ _6 ?9 q8 ?  R
                {
# v) y2 F+ J% {3 Q/ _( f. m                        return true;                       
1 p2 y0 g" w" R) A) D  V                }
, w4 ?$ L- N( o                6 |- G+ }" Y$ U" _9 r4 W- O
    } // end of class AuthorisedUsers
% I, _1 b* f$ @; P  z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 P4 g3 j% S8 M! D4 G, A/ j
Shanghai - 2007
3 h5 }' ]5 u4 ]. c( A  Y3 q& K2 }9 QAssignment 2% y0 [) }2 A0 Q" j
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), i6 K1 F" ^" 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.
2 p6 @0 S& G$ j4 a. A4 U0 zThe staff must be able to:
) S( `% W* [& `% _ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **." J0 a8 K5 w  @/ u/ `1 D" s8 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.+ `* |1 c' n1 h, P1 n, `
 The interface should provide a menu so that the staff can:
5 I5 H' }) O: f4 P2 ta) Enter the names of the two Java program files to be compared
. N" [; \3 x/ w8 j For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# R: o7 v* ?: w: n# F* K** 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).
. p9 D4 F' m0 cBSA104 Business Programming – 2007: Assignment 2; I! ?5 x0 h5 A
Page 2 of 5
0 G5 T0 M, I$ J6 y3 T4 w5 n& }* [b) Print out to the screen all the lines of code that are the same
2 |1 f6 \+ p- X- ~7 j0 K$ k Include the name of the file and the line number of the code being printed for each of the two files  n" I' |, W; i0 K
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared! V" x+ N8 P, V8 l
 the name, username and department of the user
. A* _; |' N$ I; g2 C+ m the statistics of the comparison$ n% w1 ]9 C! p3 [, m- o8 [5 {
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 l$ C; ]* E0 O1 {; B/ V  M/ Q  d% f8 i the recommendation for further checking2 g) l! g% M2 g! K. M# G7 I2 a
- 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' S5 F" Z7 @/ A# J the names of the two files compared
4 ~( s. z- S3 b& d1 e+ ~* Jd) Leave the program (exit)5 ~$ @4 S. j5 ~5 _3 s8 a) E
The ProgramCompare class: (Total maximum 20 marks available)
9 M& k8 x9 d1 w/ `. L8 o( x1 r2. 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 i* E) \9 X+ }' T1 n0 a
a) provide an error message if the files are not found or there is a problem opening them- A: L8 L3 t1 f, r# s* y
b) compare each line of code* k+ K0 y, Q' _: W/ m! \
c) print out the lines that are the same
- ?) y- N2 s; G6 @9 s- kd) count the number of lines compared / lines the same
3 k0 C6 ]& U! R. JThe AuthorisedUsers class: (Total maximum 20 marks available)
# \) t$ `7 M/ b' t$ L3. 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): ~2 I/ E) f: ^6 T) C, V
4. Provide methods to:
2 |% N4 s0 N2 f+ G; Xa) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match4 R8 _1 Q8 O( J2 F
b) return the name of the authorised user
( h" K: J6 L6 G& B  k+ N) oc) return the name of the department of the authorised user
( F9 [2 M8 n2 Q  Q- x* I( nIndividual Data (Maximum 20 marks available)! I1 h3 a; p' `; X/ A) B
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.
% K) _; M4 J8 Q" U4 |) nDocumentation (Maximum 10 marks available)5 F: T( i; i! V7 X' e9 Z
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.
, S6 }( t1 P. n$ {BSA104 Business Programming – 2007: Assignment 2
6 a! W  w: z9 q0 {" K0 m4 ~0 K3 WPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# ~9 u2 a# V) g! [
不过你要翻JAVA的类库说明。你有下载没有?  v  i4 ^5 T. S1 I2 k
查询关于对比的函数。貌似关键字是contrast,还有compare" q# e* E" ]! ?2 ]( z
1 t4 J0 S, X! C3 n$ H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
0 N% Y7 l- J/ [9 h6 L痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 p; E- N% c' E1 y可以下载到的 是 jdk-1_X_0-doc1 q: ]: \5 Q* ~! O+ i5 {! X$ u
; |* S4 x) {8 p* k
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-2 08:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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