找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1848|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急! ?# z, E9 H9 V+ D) I * K# U, D" }; h
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************1 r, _8 }, K% S- s! _
//  ProgramCompare.java         Provided by: DRS
0 v, G8 `2 h; K4 Z9 y0 o//
6 \, w/ |" ^; v//  Program shell for Assignment 20 ^/ ], D: h/ k7 i- Z9 ?/ J1 N1 W
//" J- k/ p+ R$ Z* u+ u6 y! i
//  Compares two text files line by line
& e2 n, b1 ^3 E" ~* A//*********************************************************************7 [: \0 |6 B& w4 U5 C

* E2 s( O! ]3 J0 A% B' p7 Uimport java.io.*;7 M0 m; N' b4 N) f& l, o2 I
' T" l& c5 t8 H/ x6 h5 q- F' s
public class ProgramCompare! h4 E) y0 M) |0 y" c% ?6 W: H5 E
{
1 m+ g! a; e4 W! i& H        //-----------------------------------------------------------------
/ x9 W' ]8 v+ f) W  x5 n( r        // Constructor
+ ^2 [3 F5 `/ t3 Z        //-----------------------------------------------------------------
4 w- V" X; R& |! h4 ~8 a2 ~        public ProgramCompare()
+ r8 Y7 V7 P" q        {
, {: ^! \+ d; C' V0 F        }" m7 V( I+ {5 \4 W6 _; L# Y
3 R! L' O, E# ?: v' I
        //-----------------------------------------------------------------
5 F$ r# h4 i$ ?) [1 {/ R1 y0 v        // Method for testing that class has been reached
* e; K  K2 `; J+ D' D, @* ~  D        //-----------------------------------------------------------------        - s. v1 l4 u5 w2 V2 }# P, f' o2 Q

. ?% d$ {# U) {5 D& ?& T+ \2 P        public boolean ProgramCompareReached()        
9 K6 |7 g6 E# ]: N        {; E. }" G9 y1 W. G5 L+ _
      try
$ i1 d4 H; p3 O; M. j+ u   {        
5 y8 B$ R1 O; e( J                       
* j2 X! `( N9 G7 r                //********************************************************************$ C2 c7 _, `6 O. E" y
                // Try-Catch Statement is used to handle exceptions - such as file not found 8 B7 U$ i+ E6 F- X" n/ S# F
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 y6 |% h& t9 W/ P. W, e                // For more information see page 534 of the textbook  W  G! i0 Q9 S3 t5 u/ \3 c
                //********************************************************************
. `) v' e. }2 E! {                    
3 H: k3 K1 X3 s4 x' H. b- |; e        }5 _+ Q  f# s0 Z2 x
             catch (Exception ex) // Exception caught here and message displayed to the screen 5 M" ?1 G9 Z  f. j6 k
          {
# V6 w3 v" \2 S( ?" M                    ex.printStackTrace (System.err);& |8 Y) B- y: d1 i' Q
           System.out.println ("Error message goes here"); // Replace this error message with your own          8 t9 M1 V9 t) w$ b
        }1 A7 b% X' w, R$ _
                return true;
, b* o1 L2 p. b6 @0 H$ a( O8 ~) f        }
! L1 a6 f5 k/ d1 w- g) b' d) D& U6 g( N$ G" ~' {
} // end of class ProgramCompare
3 A/ u; y9 R$ [; T4 S3 O. c
  D2 K& w/ q4 Z% ]/ y! G$ U$ R//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( K& \! p- z6 C2 P- w0 f//  ProgramCompareMenu.java    Provided by: DRS, E( C- {6 ?8 _( L
//. x# W! {/ @# [* M; \7 |4 u9 n
//  Calls AuthorisedUsers.java and ProgramCompare.java* I/ b, w' `( t) Z. O
//: L/ v  b  C$ C% n
//  Driver shell for Assignment 2." V8 j) F8 P5 O3 n6 n
//********************************************************************# f0 l3 x" k5 ?5 p* f
$ f& v1 Z! {2 N
class ProgramCompareMenu
: s! ~# q2 `6 _. P4 F4 S: n" E, p{
+ t1 ~6 D! C: o    public static void main (String[] args)
3 o  j0 O$ j8 Z# V% F            {
5 U9 |0 m, x5 f$ H                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& P% T& p1 q+ |5 o                ProgramCompare reached1 = new ProgramCompare(); 1 w8 s) r2 Q3 k1 D
                AuthorisedUsers reached2 = new AuthorisedUsers();        # H* M5 ~, A( |4 ~. d: A+ ]6 u2 |" L! M- r
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ v/ B! T9 w( M: a  E, u# u                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) {* v& Y0 r. x# r        }
; h6 A8 g% g$ K}// end of class ProgramCompareMenu. F- }: _) f7 E; g  }
& ?+ ~! S  P: f: e6 R+ D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************: s2 ]2 ^' }1 z% p  j, n* z! r
//          AuthorisedUsers.java          Provided by: DRS
; V  C8 ]# F) d. c, x- f//                ! j+ x5 D) E8 g( w+ _! R; {2 n
//         Program shell for Assignment 2& O! T+ Z+ R7 W
//5 Z/ l8 b- h. H9 ?! R3 M7 R( q
//         Represents facts about an AuthorisedUser/ w/ I$ Z5 u& m) N2 n! v/ F
//********************************************************************6 N5 p/ Q' f4 R1 p( `; c
+ s- t6 M. ?0 V$ ?  Y
public class AuthorisedUsers% \' J3 z) @6 d! B1 e
    {
. H% I! h4 y/ w" a
6 T) y* n4 y4 L( s1 S        //-----------------------------------------------------------------: V; D% n' {2 v% K1 A$ a5 H
        // Constructor
8 ]5 f# R: H+ c% P- Z5 @        //-----------------------------------------------------------------
3 a, o  w9 X! o
1 B, f  Y' L& Z/ ~        public AuthorisedUsers()
% G* l5 V" P9 A+ h9 O                {- T, R* ]. D( G. Y6 n6 k" w
                }
& @' Z1 H# N1 K7 @* i+ f, r2 Q* \: [8 o9 ~1 F
        //-----------------------------------------------------------------
" N# D- E. Y5 R5 n6 Y" F, a        // Method for testing that class has been reached
5 ]+ h5 j) N+ O4 R  O, U5 q. a        //-----------------------------------------------------------------        & {+ U+ i& r; E6 e% {
        public boolean AuthorisedUsersReached()
0 h+ _7 N# N9 {9 F( c                {
; [) B, r5 Q. Y3 W1 m7 Q' c                        return true;                       
0 h  N- O: h3 H4 `                }
7 ~: O/ n2 o/ z0 r! {: s                ' Y1 ?6 [9 A# I9 O3 C9 F2 G0 |
    } // end of class AuthorisedUsers" g! a( H$ n" N+ g' R- x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, K3 F/ z7 ~: x8 ]5 }  [) j" F  qShanghai - 2007
( E7 f& f6 |' f' b2 F% n. p* O3 @: UAssignment 26 \- s6 A' I7 L7 r/ i2 V0 @$ L: @* s
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)
3 c. X, }3 O3 U* H3 P+ I4 U# t1. 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.
" d& k' g7 {. `; w3 J, b8 q! |' ZThe staff must be able to:+ y  Y5 u& z  e) d- J6 d) E8 _
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. X) z/ _7 S1 f9 K$ d
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.: d8 s* E/ S0 i# ^- G5 I. d7 N: b
 The interface should provide a menu so that the staff can:- ~; t; f) R# J4 y% w& O
a) Enter the names of the two Java program files to be compared
+ O3 S- u, `+ i# Z3 R, n. K For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 \9 D! U. l5 ]' }+ L; j
** 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).
9 Y, e+ d( I! \! c+ S0 WBSA104 Business Programming – 2007: Assignment 2. N* h- }8 K7 r2 n
Page 2 of 5
) @$ \8 n& j, Q+ ~0 vb) Print out to the screen all the lines of code that are the same+ E; w1 k$ Q: T
 Include the name of the file and the line number of the code being printed for each of the two files
/ @$ ^; H3 B2 Z4 P7 \# y( [c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ z1 J, n& J0 i0 ]% p
 the name, username and department of the user
) e0 _6 s# _/ S0 k the statistics of the comparison
# a: q( w3 k% I3 |( i( L- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 B, s: J; X# l$ F+ Q the recommendation for further checking: Y: |) V% l: y( H* A, w$ ]
- 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- @2 N% D" W8 X6 ~% w! [- |/ J the names of the two files compared' i% k) s5 \3 o5 n% d5 m( l
d) Leave the program (exit)
0 E' M0 X- l5 }The ProgramCompare class: (Total maximum 20 marks available)
5 W& D4 Z/ J6 _, I2. 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)
* m: ~7 j8 P! H6 }7 fa) provide an error message if the files are not found or there is a problem opening them' X0 x, n+ o9 N+ d$ F
b) compare each line of code
- }+ ~3 @, E  q: O* g' D. \" _7 y+ Oc) print out the lines that are the same$ a- s8 `: ^1 g( \6 @' x. Y
d) count the number of lines compared / lines the same
4 B- ]  @- a/ _: a: jThe AuthorisedUsers class: (Total maximum 20 marks available)
( ~" I( E" }/ r/ W* |4 I3. 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)5 T% O# e$ i8 Y! G2 p& H( @
4. Provide methods to:
  O/ _5 y0 x# [4 P5 p& r; 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 match3 y3 R0 T/ H( ]; j: g) J9 L
b) return the name of the authorised user8 D1 d) @( W$ \% B
c) return the name of the department of the authorised user
8 H, t+ Q. W, y4 }2 O$ p) {Individual Data (Maximum 20 marks available)
/ C; W5 w6 f. n5. 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.
: j! S1 |9 q2 E' _: ]Documentation (Maximum 10 marks available)
4 m* a' U3 K- r  k0 I/ a6. 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.
7 g& T: _; K7 W7 d- P( f' kBSA104 Business Programming – 2007: Assignment 2
: L% o6 q" R7 n7 C7 g( ~Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# I8 G. Z7 @8 ?1 T* W+ `1 `0 S& H6 O
不过你要翻JAVA的类库说明。你有下载没有?
2 i2 O" R1 l% _- V' l. @# K" X7 u查询关于对比的函数。貌似关键字是contrast,还有compare
' F( o2 T( S9 ?7 R) u' Y7 {) z; ~% W+ S0 q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# T) x# h/ Q* P3 _3 Z. w" l
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。7 F/ l% X6 j: Q7 }9 Y! A
可以下载到的 是 jdk-1_X_0-doc
) |3 @3 j3 {  U$ S) K( D
& }, f: I/ H1 n. T5 ^; a  }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-21 06:24

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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