找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1371|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - e+ f# I2 E4 h: s6 W4 A' m/ T0 [9 Z" i6 L) [+ G! q" ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' H9 Z) I% y. X+ \. W
//  ProgramCompare.java         Provided by: DRS, O/ w5 V, |. j9 [
//
( a6 I$ t7 B, F//  Program shell for Assignment 2. n$ F  X8 o) _
//
$ z1 ^4 v" W5 D2 B( ~% H$ _. x//  Compares two text files line by line- _: g/ G* s& \! D+ D' U
//*********************************************************************/ ?! d" H: c2 Q; l& n
. n4 v6 N4 h1 T/ ]0 ?$ U1 O
import java.io.*;. S& c! w$ M. W& v

, k. i$ D) A- s, \) ~; Lpublic class ProgramCompare. f1 |1 b1 [9 Z/ R1 y
{/ Y3 w' z# s' @: @) B7 k: o
        //-----------------------------------------------------------------# ~2 {" p* c& I
        // Constructor
8 j3 G. X3 o8 {% I2 P        //-----------------------------------------------------------------
' Y$ ~- e( i  k% I5 \        public ProgramCompare()
' `; Y) t# Y" D/ Y* q        {
" a5 h* t4 N+ V! b! _& A        }
  a) ], Q7 G- ]* C: O+ I. J* G1 i* B  v9 v7 s
        //-----------------------------------------------------------------% Q0 f4 C5 u% T+ E% ^- ?
        // Method for testing that class has been reached4 `. E  ^: C/ ^7 x7 p
        //-----------------------------------------------------------------        2 H5 e6 x4 M. \# C1 J
" V) M; y) G( A5 v" l1 L6 V( U2 R
        public boolean ProgramCompareReached()         / ~% c& n) j$ x
        {( |* t# g: E' L/ Q( u1 ~6 x
      try
) h" R9 ^0 `( N5 E( E6 ~! ?   {         # E8 g! u: \. _; ]: {- l) P
                        6 s) h8 K" F0 L2 @/ x% h- Z
                //********************************************************************$ l6 e% R' f: c1 U4 q
                // Try-Catch Statement is used to handle exceptions - such as file not found " J" j4 }+ [; D8 \8 y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. G9 \+ M1 o( ?                // For more information see page 534 of the textbook% O5 l- E8 e" e/ T( s3 J+ Z
                //********************************************************************1 s7 }8 ]. [& Y5 _1 ]3 H. i+ Z
                    
! A+ U7 V- n4 ]% r, q( F        }; ?7 _7 u. V. M8 @, d8 e
             catch (Exception ex) // Exception caught here and message displayed to the screen , g7 n8 Y0 ]+ F
          {- R6 ?$ h- ~; P! X4 [
                    ex.printStackTrace (System.err);
0 i1 u8 D: Q. @+ g           System.out.println ("Error message goes here"); // Replace this error message with your own         
0 e/ E' p- n) G7 j; c1 ~        }! L2 @7 W# g4 y) m
                return true;
5 ~4 A4 Y' ~( F' p  ?        }
" B" G/ L! f6 F3 `
! O, P* c( G2 k5 U+ v} // end of class ProgramCompare
  e8 B# p3 ?  X9 C* S6 ~3 [* z( w1 L. k4 x# |( I9 l8 n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( [/ @9 Q$ T1 t' ~# Z//  ProgramCompareMenu.java    Provided by: DRS( A4 w' G  n3 B/ ~
//
9 Y; J# \) E+ _2 `//  Calls AuthorisedUsers.java and ProgramCompare.java% g1 F3 z$ [  @
//
. q4 {! a0 R9 T" B- ?- c//  Driver shell for Assignment 2.* q1 B# A5 T* D
//********************************************************************
: W2 J* U$ C4 f( e5 V) g9 ?
8 [- c2 {: f  u0 ^. z+ nclass ProgramCompareMenu% h' ], B% z. U; A" g+ t$ J
{
, h' Q4 y  w% E( f# P    public static void main (String[] args)
" j. {/ i: u$ V            {; O' V8 P. M3 I! y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 r! N& p1 H& p% d6 t, _) C: M3 n
                ProgramCompare reached1 = new ProgramCompare();
% S* J* k) l1 c% V                AuthorisedUsers reached2 = new AuthorisedUsers();        ) x8 M" E1 N: u) x9 u1 _
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# h0 f+ ^2 K; W2 @' n2 |                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 g, K3 ~8 Y: p& y7 l" O% D        }
9 a6 F  j6 L2 B9 P. p9 U}// end of class ProgramCompareMenu. T& U$ J, {1 l- x1 g

1 g/ f9 a- V' A# [( r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 H2 I  b) Y4 \. {( O' }& v
//          AuthorisedUsers.java          Provided by: DRS1 o/ T& O6 R. z: H; u9 x- {6 g- \
//               
( t; r; p3 f! J7 x. P6 p" {1 D% ^//         Program shell for Assignment 22 N! k8 C1 M, Q. H* z
//7 {7 o3 q: _; @2 D$ u7 ~% T
//         Represents facts about an AuthorisedUser
9 `' Y5 P8 u* ?0 V) Q//********************************************************************) m! N# j  e* w2 ?, O* s
8 g" I2 c* m+ F) X9 P
public class AuthorisedUsers- Q$ _- O1 v# y. `  i3 X% J
    {$ D$ X  t$ P$ l2 V! i( K, b/ v
& f8 T( [9 T7 f0 u6 _" C1 E3 F- i+ F& l
        //-----------------------------------------------------------------
2 ]0 g$ \, C- B& r+ v9 Q7 V        // Constructor
9 Q2 p3 x: k/ R+ p: n        //-----------------------------------------------------------------$ Z* i8 x( x' M3 ]) C& v# g
1 ]6 Y4 P+ W' {% P6 `# i$ y
        public AuthorisedUsers(), o- F! U, J  T, c
                {; C- w5 O+ a, R& y1 p
                }
0 h# {- h" c( K' _8 ^  ?- j! }0 I1 V2 n/ T) v0 X
        //-----------------------------------------------------------------
# B1 J3 X' m4 U        // Method for testing that class has been reached; w4 l3 H; p: j- s3 S
        //-----------------------------------------------------------------          l, v' `) H% `. s
        public boolean AuthorisedUsersReached()6 R4 ?6 u/ B3 A) f5 o
                {
2 k2 Q0 x) u5 _- N% f* D                        return true;                       
/ Y* d/ V% V2 T; F* n                }
2 l$ r# |/ I# o6 w# T- i6 L! m; j               
$ q; r) L4 C9 i4 |    } // end of class AuthorisedUsers" H- p! J- T# ]$ ?7 B! J6 [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming( y2 \3 j& s6 ]( m2 a/ \, s- }6 `$ X
Shanghai - 2007- l, E2 ], `& W% G3 o& F
Assignment 2
' Z( |: w9 C' O2 D2 C( [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)9 [5 m' A8 g8 y2 q! V4 r
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.
' g+ D4 e9 l. T- k% x4 G% dThe staff must be able to:& G4 W$ H' {7 t$ g' _# D
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 b( H' s3 f6 X4 V1. 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.
% L7 `+ N4 m2 S' d2 ]9 L- g# Z The interface should provide a menu so that the staff can:. k) K! f3 ~2 g' |
a) Enter the names of the two Java program files to be compared
$ G+ K2 W5 _# Q8 {; B For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: V: I$ w7 _/ ?; e9 k: O$ d** 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).; A/ }' _! W+ t6 c2 f& ]- |' {( ?
BSA104 Business Programming – 2007: Assignment 2
4 e( @' _  j7 @+ u* u  sPage 2 of 50 P( K7 ^3 d% E, Q+ A, p! J
b) Print out to the screen all the lines of code that are the same
( k5 t4 P6 X) q  X( K  t* n( s Include the name of the file and the line number of the code being printed for each of the two files
' g. K. n2 z% M3 p/ Pc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: e! Y9 h9 X: ^) d) g; D the name, username and department of the user
1 n- y+ ^* w+ V the statistics of the comparison
( E* X7 \& q- U/ x; ~$ E- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 n3 q! R% f; z0 M. z* p/ } the recommendation for further checking5 o9 s- _( d% i6 P% ?6 R: ^
- 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 closely6 z: C+ k' a. j$ M7 f  l: e) g
 the names of the two files compared' M+ W! [, B# ?- j
d) Leave the program (exit)
7 Y( n# w. Q, Y0 I# D& Q' }6 pThe ProgramCompare class: (Total maximum 20 marks available)
4 r9 \' R4 ~0 b* U" S6 Q6 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). G( b- p+ L8 h, I# f: z% B
a) provide an error message if the files are not found or there is a problem opening them3 c/ a% z. H* k
b) compare each line of code
% C% g" C0 _2 B1 F: \& c  E" gc) print out the lines that are the same/ e& \5 g; [- c0 S) ]
d) count the number of lines compared / lines the same
! o$ K) u5 b! C9 k- a5 h' r8 _The AuthorisedUsers class: (Total maximum 20 marks available)/ p) M( F( _1 K* x* o, k
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). |: A& Z' }0 Q4 ?% D9 l- s8 A
4. Provide methods to:
4 J8 I2 Y  s% S! ^6 R" Ga) 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
2 [; b9 x9 k- d- [b) return the name of the authorised user
( P2 |' M% ?7 n  Y1 Pc) return the name of the department of the authorised user! i- H0 \4 w! U) s; x. n  P2 U
Individual Data (Maximum 20 marks available)- F. q* c2 u: l* Z
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.& Y- A- s6 q, ^, U! ]
Documentation (Maximum 10 marks available)+ _5 H- G( n% Q; Z( s$ 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.
. y% h/ A, \( z3 n# q, F, j$ MBSA104 Business Programming – 2007: Assignment 2
1 a  D: }5 A) x. ]/ PPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( i8 m/ D( T$ T& h4 b& D! b& C; l不过你要翻JAVA的类库说明。你有下载没有?
* @( d% k2 _0 e2 P' ?. f查询关于对比的函数。貌似关键字是contrast,还有compare
: U7 Z5 ?5 r0 [) f8 w; U! ~; t: H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -1 y3 o* X8 `( K1 v- Z0 X
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。  a) m# i, S- C& w
可以下载到的 是 jdk-1_X_0-doc
4 l/ U# |: |) }2 L/ Z, M- N$ G) {+ y' S4 }3 T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-10 00:43

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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