找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1682|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 o* ~% R) {; v ) p. l3 P) @2 K: m
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************( H0 g$ F0 R: ]3 [5 K
//  ProgramCompare.java         Provided by: DRS7 Y  D" u! O9 k/ I8 c
//0 h( j# g+ p) p: l0 @7 n, S9 C
//  Program shell for Assignment 2
: g- Y$ K2 @+ ?* ~/ N; W6 I//7 }# W9 x/ l) |
//  Compares two text files line by line. O: D5 n' F' h' d, h4 g
//*********************************************************************9 \0 g6 M  I. T% q0 W1 K2 ^8 r2 A- P
7 x' A9 N; A$ E+ R. J
import java.io.*;8 @5 v; P" o  |# E4 w

3 b1 o& Y( X4 |' L5 Bpublic class ProgramCompare
$ @  C2 d4 N; B* {! L{& t8 J5 |% a1 ^( R
        //-----------------------------------------------------------------
" p3 t  z  e: T4 Q# M8 r2 \2 p8 f        // Constructor9 S2 T/ c0 Q" S8 S# X# G2 w: q
        //-----------------------------------------------------------------
6 k% ~0 w' }" p; `        public ProgramCompare()5 I/ H8 @' F" ?) ?" D
        {4 S7 x/ \) I3 \& ~: y
        }4 @: l+ N% i. L' M/ }

! w  Q. m* ]2 ?$ E        //-----------------------------------------------------------------7 Q+ \: E( V- q) h3 I7 S( H6 T! }$ x
        // Method for testing that class has been reached/ q+ |; `) k4 q& ?* @+ K
        //-----------------------------------------------------------------        " B" o4 H9 |8 N; v2 G" i
4 F/ [( J, x: }) R1 x6 q1 [: i5 z
        public boolean ProgramCompareReached()         $ b1 c2 K  Y0 ?' E& m
        {
* j' e1 S9 P1 L; s5 X      try 3 b7 S2 y2 p/ E5 d5 y; n$ P
   {        
. }3 P9 z% Q1 q6 m- C% Y                       
2 v3 s7 u7 l, A                //********************************************************************  p5 F; Q9 M+ r' W7 F4 d% u
                // Try-Catch Statement is used to handle exceptions - such as file not found : b& @5 y4 W3 x7 O- N
                // Reading the files will need to be placed inside a Try-Catch - just like this one!2 y* m- i5 W1 S5 h
                // For more information see page 534 of the textbook3 k9 O. G% X9 Z9 e! n; ]( F) n
                //********************************************************************* [, K- Y+ B$ I# F
                    
& Y( S  h% u- k( f  N2 D5 I" E        }
" H0 o. m- G/ v) i5 F9 ]             catch (Exception ex) // Exception caught here and message displayed to the screen
# o& G6 N" W8 {. f& N8 [0 L1 ]          {
6 K* L9 D% R7 u) i                    ex.printStackTrace (System.err);$ x$ \9 o9 N, U# k: N
           System.out.println ("Error message goes here"); // Replace this error message with your own          ' u- P3 i, S( _8 Q' Q/ C
        }
( k1 p- k, \0 _8 k4 d                return true;
$ I6 t0 \1 X9 L& M6 ~        }
2 m8 ~5 k" ]# O0 Z  H$ _- B1 L
& Y& J9 v4 a( R6 S} // end of class ProgramCompare( [2 N( j+ `$ }0 M2 D0 }3 M8 d
' _$ _6 w0 \, W1 t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 k# s+ ~  D1 z. Y+ e! l+ a, `" a//  ProgramCompareMenu.java    Provided by: DRS2 t* F. Z4 \- J2 o$ C
//! T% B4 w2 u7 P- I* A! }7 y$ a
//  Calls AuthorisedUsers.java and ProgramCompare.java
  s! r" B. `, n//' s7 h6 B7 M/ _
//  Driver shell for Assignment 2.
0 J" d1 P' w/ ^( o3 e2 h) v//********************************************************************) T( T  R$ H& q

# d* A% t, X, E* T( \class ProgramCompareMenu
1 R! P; j4 p7 _0 s/ w( x3 s* ^1 V{# L3 p( T' m, i" N
    public static void main (String[] args)
" y$ K0 G8 A  k( ~8 F" Y7 |8 S            {
3 c$ x& K5 a" Y6 I/ ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) X' x# F$ v- b' b& v. M                ProgramCompare reached1 = new ProgramCompare();
) I1 ]8 r2 T* |: b                AuthorisedUsers reached2 = new AuthorisedUsers();        - _. D7 b, L, A; N
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. b' {* I5 z; C+ M0 w. v) \( P* A                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 |" v  N/ ~: O! R. b
        }  b8 v3 k, U5 j- G# |/ n3 J6 p" L& @0 `
}// end of class ProgramCompareMenu
: k  q0 W! U5 U! e  w) b! i4 d. }* x' [& K- t. ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 u# {7 D! P* w' M
//          AuthorisedUsers.java          Provided by: DRS
% s* z$ {' P5 w* t& c0 x//               
' J7 }+ |8 u: s7 W//         Program shell for Assignment 2' e; B* T% m. h% _. Y/ N
//7 b. `# e: f4 k- o
//         Represents facts about an AuthorisedUser0 ?, ?. D- }7 _4 \6 \
//********************************************************************
" m& D" n, A  G# |$ |' X0 A/ f# \4 Q9 A
public class AuthorisedUsers
+ X. g2 L2 z  [1 i; n7 ^$ |    {$ m  x; z8 r% G8 T& K

. x5 {1 ?/ l. a0 ?        //-----------------------------------------------------------------" e8 V7 s3 Q% _% W8 Q9 G
        // Constructor; \4 |: M! H0 N
        //-----------------------------------------------------------------1 M$ L5 ^/ C" k- A2 K' L" x

; Y, H! Y' c8 ]% j6 J. b        public AuthorisedUsers()
  X/ a$ t) t& O2 Z& p# o                {
/ J/ e* [$ S* g6 Q! Q0 [! e                }. h, [* u5 U* p, r+ n# d6 S

9 n- B  L( N$ s( j        //-----------------------------------------------------------------
0 _  O: H$ V4 L. Y: ~) i0 G" k1 W4 i        // Method for testing that class has been reached
, B' h1 G6 N) Z        //-----------------------------------------------------------------        ' w7 e2 {! h" @" n* }
        public boolean AuthorisedUsersReached()
* I* u8 v& L3 y5 d                {" S, t1 I8 B6 {0 d) t1 b0 w  f
                        return true;                        . q0 I7 j4 W% h" ^7 B, M* B
                }
* R: t, Y( \1 A# ^9 z6 |) J- W+ x3 k$ l               
' G0 n% s4 |0 c% ]5 d& d2 ?    } // end of class AuthorisedUsers
: N" I+ `2 X3 l1 {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
) Q5 F1 y, C6 s- E, b* }, ^Shanghai - 2007
( J$ w2 W( E! c$ c. iAssignment 29 U- a+ G9 r+ b
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); b& r; y0 \) C. U8 }: P
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 }, _9 h7 a1 x% k# i2 P2 q
The staff must be able to:( z, J. h/ j, Z: v
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
; T% E/ N0 f7 B3 C& V, t! j1. 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.% R. H: T! {2 a4 p5 K! X
 The interface should provide a menu so that the staff can:
1 C1 r0 y" v8 [/ K8 Ka) Enter the names of the two Java program files to be compared
! y1 E/ }" N) n# H* d. E, Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% K/ ^% o$ W8 f
** 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 }5 X: r* I# A' {% Z- @0 N9 L6 X
BSA104 Business Programming – 2007: Assignment 2
$ K# b2 x& Z1 C7 a- c( mPage 2 of 5, O# T. x+ K' _& K% ?4 ~5 I$ q
b) Print out to the screen all the lines of code that are the same- ~& m7 @/ l0 k" H9 V/ F7 j$ u- ?
 Include the name of the file and the line number of the code being printed for each of the two files& _: _; z$ z8 r) u4 B
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" z" N' N3 _% {0 ? the name, username and department of the user
+ J0 y: o2 t) n3 D/ y3 [ the statistics of the comparison
/ ^, G/ j& D8 M* C3 S- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" ~; A  t& S1 w" X$ h7 \8 O% o& z
 the recommendation for further checking. @+ W! a% ^: j5 K% x1 q
- 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 closely3 M" x/ K: \# w% q% W- l" H* p) @
 the names of the two files compared' P8 a: ^+ M. K% m0 K) W" j5 S
d) Leave the program (exit)$ P* H; c1 h- b# J: B; m3 Q  U2 X* a
The ProgramCompare class: (Total maximum 20 marks available)
/ j7 P) U0 h, ~0 T2. 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)
, H6 f8 C2 n' U1 U4 za) provide an error message if the files are not found or there is a problem opening them  N$ [+ L. n" h! P5 e) B9 ?+ S6 R
b) compare each line of code
# ^1 H4 H) U9 W5 k1 s7 h& i$ nc) print out the lines that are the same4 B$ Q# @9 o: y0 I5 C
d) count the number of lines compared / lines the same, ~/ e; u: w) a1 q2 l% N
The AuthorisedUsers class: (Total maximum 20 marks available)' _9 K9 D; A7 @" e7 C1 p
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)7 R# w/ k1 Z8 {1 M7 O9 b% I
4. Provide methods to:
/ S7 r4 D) P+ I; za) 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+ [5 U. \6 q2 c$ ^# W* l
b) return the name of the authorised user; h+ O3 }  {! P+ p& A
c) return the name of the department of the authorised user5 \1 R- T4 P( O2 m* v+ s
Individual Data (Maximum 20 marks available)7 K) f1 x0 Z3 y! R
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.
" X! R. l8 E! F  F3 x0 Y* tDocumentation (Maximum 10 marks available)# ^; s, w2 O1 Q; P3 }% c5 U4 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.
* _+ O+ p" Z( I$ tBSA104 Business Programming – 2007: Assignment 2! V% o  m, S% L$ O, K
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. @$ T6 O. \- q/ k! U  m, \, r
不过你要翻JAVA的类库说明。你有下载没有?1 `) P  P0 P" e9 m1 K/ G
查询关于对比的函数。貌似关键字是contrast,还有compare2 F9 b1 d- h, T9 @1 p0 o

! C9 p6 d: M/ s3 E8 q, \8 d5 w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ t8 I$ E0 J' r5 H/ c' C& s痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' @  a& z% C  ?6 ^" [, X6 h
可以下载到的 是 jdk-1_X_0-doc" n1 [5 r" [9 m" u2 [% R

7 F7 z, E  P2 x  Y& n1 d2 j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-29 18:07

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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