找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1301|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 N) p2 n# Z5 h$ l9 s3 G0 n & I0 t3 P7 a" U# f. i2 x# D
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
' e7 H* E! \. g7 r# R, \- [% x9 \//  ProgramCompare.java         Provided by: DRS
1 i+ n' @- G3 s//
5 Z+ H% x. ^# g) W/ _( `/ L//  Program shell for Assignment 2: p) S& d# F/ ^  m+ S* A# C: L
//
& i' e2 }2 s$ d0 r1 p- q' L//  Compares two text files line by line' E8 H7 e6 n2 ~0 m/ e9 W
//*********************************************************************2 K+ y/ y" c% l: R. i, E
) v# [4 W7 D+ \, G" _  f, T9 o7 n5 x
import java.io.*;
4 B0 [* f( h* ?" L8 r) {4 P; x. b$ ^0 q. [4 L
public class ProgramCompare& P# x3 \) B8 l1 t3 c
{
! `% q: m5 G& W; T2 \        //-----------------------------------------------------------------* M2 }) m; x4 w3 V9 x( L
        // Constructor
1 E! _% Z( u  S) d        //-----------------------------------------------------------------/ y' x, X& b: K5 `# c! Y
        public ProgramCompare()0 m$ R, _7 F. m3 |8 i! t
        {9 h0 O0 R( l) u& _
        }
: l( |: J  u% A/ \" i2 O1 S3 {: S$ k: h3 }3 f5 r
        //-----------------------------------------------------------------& r5 E3 E" R1 a3 r
        // Method for testing that class has been reached
0 n5 ^; F: i6 r9 t, r        //-----------------------------------------------------------------       
3 q. y1 V1 p' T; L% n7 Y: q2 a: S: j% [# g
        public boolean ProgramCompareReached()        
, l% j2 P6 G' Q" A        {2 k6 V- }1 z! M& Y0 X! q( n% s
      try ! A2 \* p/ Z3 P7 v- w  H* C% P) N* e
   {        
7 b3 s1 Y* F/ c* R# `# S. _                       
7 c3 H2 h& A* d" i5 ]6 m                //********************************************************************1 f& o1 ^7 I7 T. N
                // Try-Catch Statement is used to handle exceptions - such as file not found " A2 A. C' S  x; D8 D8 u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!7 g" V' i% _0 a* ]( w% O5 T
                // For more information see page 534 of the textbook- d5 S1 Q8 R1 ~/ J2 [
                //********************************************************************) O1 X) k# @1 W6 S7 C: i' U( f
                     3 @5 `7 y1 @! H8 }+ z
        }+ L! q" j. K3 {
             catch (Exception ex) // Exception caught here and message displayed to the screen
0 P  ~. w0 u7 J# _          {
/ u3 c6 r8 Q4 b$ o                    ex.printStackTrace (System.err);1 O) J2 E: W. |3 b0 ]
           System.out.println ("Error message goes here"); // Replace this error message with your own          2 W1 L6 s' W- g% q8 C- o
        }
/ X0 H  Y! ?+ x1 ^0 Q/ M                return true;
; x; _* _1 |2 u1 H3 ?8 t        }$ R' J3 K3 r! q1 Y0 b
( e0 d7 I  L; s( t% x/ ]
} // end of class ProgramCompare# q5 ?: ]3 c- B+ A% i9 ?

3 H5 a. Q5 |5 l7 N+ Q; }+ T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* t% D; u! C; o: {! C2 x% k//  ProgramCompareMenu.java    Provided by: DRS
5 x( I3 q" B2 i//" c2 a1 A% ?$ ^6 Z5 g
//  Calls AuthorisedUsers.java and ProgramCompare.java( D. X, k; n, R
//) ~2 u! E# \: ~, y, l; a% H; i
//  Driver shell for Assignment 2.: _( D- E# r$ h: Y
//********************************************************************
6 J* _' _" B/ N  Z9 y" D+ J9 |; G% {8 l1 [
5 V. l$ i6 B7 x: X+ N0 S% X3 F/ F/ uclass ProgramCompareMenu
9 X' ]7 I7 u. o7 p' N{
9 u% [1 S3 T9 S) v6 O    public static void main (String[] args); i5 X5 {- }: |
            {* h0 O5 }& e; D% F( `
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; p' Q* z& Q+ A) S0 }
                ProgramCompare reached1 = new ProgramCompare();
& J0 F1 B* i$ [/ F                AuthorisedUsers reached2 = new AuthorisedUsers();       
4 r" ]9 H: e, H: O. H- k0 c% h  z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 F5 P4 q6 r" N( n* n- s+ K1 D0 u                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" H: y4 _/ o2 M  v! L7 V; ]( U        }
3 S' ?: b; N3 I/ P: T2 `; m- w}// end of class ProgramCompareMenu
7 q- Y9 e$ B  }4 k8 S" d$ e- |- ?6 J/ W  s1 d) Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************% F9 H/ |. }, Z8 ?" p$ w/ R
//          AuthorisedUsers.java          Provided by: DRS
- S9 t9 }, u' |  x- L* C//               
( C' D7 q( m, V//         Program shell for Assignment 2
3 U  b* b' c/ g: r' j+ f6 E/ O: E//
5 S8 _$ L$ [7 z" j9 j( x//         Represents facts about an AuthorisedUser1 U2 s  h5 H# t; R9 i+ R! j( q
//********************************************************************9 O8 W# W9 ?  Z/ z8 s

- q2 N# t5 O' @) B) ?public class AuthorisedUsers
/ g2 @( i- F; R3 q3 C7 r    {
. g) Q  N- E* q1 j+ j
3 d3 N+ b( n  b6 J1 k; u+ y5 E        //-----------------------------------------------------------------( [5 X' |7 Q; _/ h$ g4 Z' ?* X! L
        // Constructor
0 r/ ]3 b: _2 M% Q3 f        //-----------------------------------------------------------------( ]2 N4 y" `  U& Z1 g& j- {" D/ ?

- ~8 Z8 g0 o2 \! g        public AuthorisedUsers()
3 f" n6 q& V; w, }: q% n: R                {9 g* N& i" {& T# m% c. Q
                }
- G% A7 u6 i, ?& n# a. p; ^2 o' g9 a/ I% n5 v$ w' {7 N
        //-----------------------------------------------------------------
9 ^0 u" m2 u3 |+ X5 n9 l        // Method for testing that class has been reached
+ h1 A) ~- F9 b3 P; G        //-----------------------------------------------------------------       
; b' T$ F, V; ~: R% V# j        public boolean AuthorisedUsersReached(), d7 `: u2 _. j$ _0 Z
                {- X0 V) @' _6 Y2 m2 E1 G3 C0 j" Y& D* E
                        return true;                       
- C5 `& R$ q0 n- Q0 E1 U                }
9 z4 ~( m% X" C( |9 r, m                " d: a5 E5 y( Y) k; D0 k' g
    } // end of class AuthorisedUsers, m& c, `3 W( v  m4 u$ `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming- Z* Q) ~8 W, C# x- `
Shanghai - 20075 K/ L) S  z2 j1 J
Assignment 2
3 }9 q5 ?2 l- p; Z' |; vDeadline 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)4 X  d: B, ^& s  U% l' w
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.* o6 F0 Y7 t0 H7 g4 l
The staff must be able to:$ P5 @" N% R. o* T, E2 f! N
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 P, R* ?' s, N7 i7 Q1. 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.5 F' l: R, s3 R2 t! r
 The interface should provide a menu so that the staff can:, }+ z% `0 K) u: b5 `& o6 n) L
a) Enter the names of the two Java program files to be compared
  e& r! n/ F% O! c For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ W; m( v8 V6 M6 K2 E  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).
7 r0 H$ l. ~2 b0 c! a: I  BBSA104 Business Programming – 2007: Assignment 2# `6 b/ Q/ Q( \5 ~% ~% B) X6 T
Page 2 of 5+ H- N6 }3 p4 i# W0 M. z1 [
b) Print out to the screen all the lines of code that are the same% S/ a( X1 h: l  t7 Q, i' ?4 Q
 Include the name of the file and the line number of the code being printed for each of the two files$ u9 K1 C% s; j6 ~5 q# y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# }( r+ B+ a5 E6 _$ j7 B
 the name, username and department of the user
( ~( J2 u) D2 z) _" E1 b the statistics of the comparison
+ H& ?7 K% S" D! a- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# h% D' X3 n! S+ {
 the recommendation for further checking
& m3 n7 P0 O; p7 _5 [3 ]- 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
, H' g9 d2 H' I' k6 r6 Q the names of the two files compared  E; z( b& ^) E# `8 w- n( U
d) Leave the program (exit)
. q, h/ m) m% W2 J! Q8 ?6 |The ProgramCompare class: (Total maximum 20 marks available)) P3 z5 E8 }6 s% H% a$ R* I# h
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)
" B+ \* Z, i% h! ha) provide an error message if the files are not found or there is a problem opening them/ q+ V) m% s% l
b) compare each line of code
& S. B2 L* r) i( W* p1 b5 C6 Lc) print out the lines that are the same
3 G; Q" ?! ]4 f* {d) count the number of lines compared / lines the same7 c, p* A  Z) N, o2 i; L7 k
The AuthorisedUsers class: (Total maximum 20 marks available)7 h  G* J2 O1 V3 `( Y" H' 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)( h6 _" p0 V) j3 n2 y
4. Provide methods to:
; B8 w" G/ w2 g" m4 n9 z! \- C7 Ra) 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
3 O! Y+ w! L* u5 u! gb) return the name of the authorised user% Z% @6 B* K! S; a; i- Q
c) return the name of the department of the authorised user
) Z$ J6 ~3 Y6 RIndividual Data (Maximum 20 marks available)
8 y1 S' K) {) O5. 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.
# b4 m, v+ A9 P" l, qDocumentation (Maximum 10 marks available)
7 a( X. ~# b- z, O3 A. Q6. 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.
+ {; Q: G; u+ a- N+ s, y9 Y, e& ~BSA104 Business Programming – 2007: Assignment 27 E& Y6 r! a! U0 V/ s
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 k5 u  x5 B; y/ d& W) g. A! n( k5 V不过你要翻JAVA的类库说明。你有下载没有?
- m2 p" X* z; w查询关于对比的函数。貌似关键字是contrast,还有compare- y4 q0 ~9 V' L* e8 `
1 S; h* W1 `2 V$ {. P; k
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% [1 v# Y3 ?' s% L* i
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 j* ]5 _3 V! M2 e
可以下载到的 是 jdk-1_X_0-doc
) ?2 t/ }/ b# t' T
0 \" b- {8 D4 [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-21 14:37

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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