找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1031|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 G( U0 y! P" b; _/ Q4 k' l0 X$ X+ B& h s( W5 A5 r
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
" Y$ M2 A- q& D  _+ Q7 N  t4 D//  ProgramCompare.java         Provided by: DRS" {7 i' E, F; I9 S6 t
//
/ z, _- R$ ?$ W# {' Y//  Program shell for Assignment 2
, f* g3 \1 G* [* i//
4 m7 d6 P( T0 o4 ~# c# n' x* A, T//  Compares two text files line by line
; L$ d. v4 I3 |' K' K/ `- C//*********************************************************************1 K6 f* S+ `% h" X( V
, T: W, `5 ~- w) g) f1 V. i, y
import java.io.*;
; V! K. E' a* w. ]' ]6 t& H
" j& R! C+ ~1 Q) Q; h  Tpublic class ProgramCompare) ~# V$ v; |7 A2 w! Z1 G" H
{
* ]* Y) V: a: o        //-----------------------------------------------------------------; j+ B2 Z% j" k
        // Constructor9 ?  L" S) u) C1 T2 F' n" V# e
        //-----------------------------------------------------------------
2 `$ O* v( n, p. Q' R7 K- c        public ProgramCompare()
8 C- ]+ q, N/ s! X/ ^) l        {- f" j6 S$ O' r, r( w
        }% j+ H; J  @- P' S# B5 T4 s$ ~& w

9 E; v! g; r5 K. ]( y4 X: c% v        //-----------------------------------------------------------------
& H1 {! T8 H" o& v. |% W4 V        // Method for testing that class has been reached$ P( p% M! {( b1 A  S3 x9 K
        //-----------------------------------------------------------------       
9 @, V7 U4 I$ r) ?6 s# i% c* @2 f/ t2 ?
        public boolean ProgramCompareReached()        
" P+ w7 }# U; V( ~/ ^  J2 @* F' a        {
3 N8 c/ y' v  W+ V* L8 S- [6 ?      try
8 U4 I4 R7 R! U. R   {        
$ h4 e0 x% N* [7 A6 ]2 k  [" G                       
. o! o' \) M! a3 k9 P) g  @                //********************************************************************' H3 S/ m1 v9 U9 U3 T
                // Try-Catch Statement is used to handle exceptions - such as file not found 5 K& W/ D, L6 q% v& ~. K' w: k
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- c6 T0 t- R/ \7 _& z0 X
                // For more information see page 534 of the textbook2 w0 T& d* D* \4 W6 b) L" v
                //********************************************************************
! j0 W0 ]+ A3 M                     : I6 ~7 c4 C3 L! ]* P
        }$ e( {1 z5 m# H9 Q$ K
             catch (Exception ex) // Exception caught here and message displayed to the screen
/ I/ x( d) C& h          {
! b  E6 X" J; B& X* z                    ex.printStackTrace (System.err);8 D3 B( C6 O# I2 z
           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 i& ]0 ^; p& n, J        }( [" r; z- `; O+ o' T
                return true;
5 W) w" a2 h  s- i8 Y        }
; y4 F+ W) p, N/ h: B
) r5 K/ T1 W1 Y$ b2 f% d) C" a} // end of class ProgramCompare) z1 _0 Y- n, G6 X8 u9 {+ x: T
$ a( N" S* L: V% d" f+ t; k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" a! L1 H4 e+ |9 }
//  ProgramCompareMenu.java    Provided by: DRS8 n+ H- {0 i, \1 f/ z1 S; e6 P
//
( _) u- \! H8 c//  Calls AuthorisedUsers.java and ProgramCompare.java+ f9 s  ]7 O6 V7 y2 B1 Z& x4 l
//& ~9 ?5 A% B5 Y: ~
//  Driver shell for Assignment 2.+ @' Q8 `9 j4 f! C( N. {& l
//********************************************************************
( J/ r1 C, J+ a0 n, _7 j0 [4 V* E* [! u, Z! j4 @# n* y4 m9 K& u
class ProgramCompareMenu
) r- d' _7 X, _, z4 B/ \; R{
. R# J. j3 u8 H  Y    public static void main (String[] args)
% x1 C2 F; o+ S! ~1 [* N: R3 j" C  Y% [            {: c" ^* n6 Y. t* s) r8 \2 F5 C. Q5 H
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! T/ Z; u6 p. ^2 l) Q0 s: c, Q, X
                ProgramCompare reached1 = new ProgramCompare();
& i6 y. L" q) G0 C0 f  ^& m4 ]                AuthorisedUsers reached2 = new AuthorisedUsers();        3 R/ L6 O+ S% O3 }: N" k5 G4 B
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());  ?0 I3 s, h" r/ s% h
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' _6 s3 `' T+ V# ]2 A$ J        }9 D' A) f" J1 ]
}// end of class ProgramCompareMenu
7 p8 n, T9 J2 L" U0 V$ W' b2 G' |7 E+ ]9 z$ \9 i* _% C  y! Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) K. f0 n& h' `
//          AuthorisedUsers.java          Provided by: DRS" A" ^5 T! d5 Y/ _
//               
* o' s- S" X* v! H* v' }, ~//         Program shell for Assignment 2$ [9 P) J) c3 |( r5 C2 O2 ?
//4 L' f5 ?, l. E4 s
//         Represents facts about an AuthorisedUser, }3 r4 ]+ R, m& {
//********************************************************************$ n3 X5 h4 b7 b1 D: k

! D, U" |( {$ x5 O% x/ Gpublic class AuthorisedUsers/ J; O9 z& S+ M' ?8 M2 o, G
    {
2 p& Y4 H& m7 k! W2 F8 a; `0 O
& B: t) ~& i7 \7 t7 ^        //-----------------------------------------------------------------
" ~% Y' [) b& q7 e  W+ \* s5 c6 v        // Constructor- F- l+ v0 v7 {' K. R3 ~5 C
        //-----------------------------------------------------------------
9 y% D, M+ h4 o- V" l" k& W4 y, n" H$ g5 ]8 X4 o2 W
        public AuthorisedUsers()
8 x) ^, z6 n, `& Z                {
  s6 b( D' X7 g5 r# ^                }
" f+ L/ m' L/ ]; P1 v7 m% m: l, O7 m
        //-----------------------------------------------------------------, w5 u7 y8 N& e. g- c# X. B
        // Method for testing that class has been reached. }+ N/ S8 e+ u0 J9 m; u5 }/ \
        //-----------------------------------------------------------------        / a/ l5 z6 n1 v1 ^/ i* Q4 w3 J
        public boolean AuthorisedUsersReached()
8 I. b2 X% D  O/ W3 }                {! v. {# v0 T' i, U' h" Y& q$ U& F; [
                        return true;                       
6 `8 d. m) Q1 }1 `& F- R                }
) W% z/ |0 n! q3 z! P, |               
: L5 }- c9 e. {, R    } // end of class AuthorisedUsers
" T: \; U2 X. e$ X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 R  R: D1 s8 q+ q( C: \7 D: DShanghai - 2007  l+ N/ k1 U2 V
Assignment 2
/ F! c) X3 Q% [: d! ]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 C% Z2 N1 x, S5 r) Y7 A1. 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.( l$ S: Z# y! ~
The staff must be able to:
# f* y  R5 ?7 L3 x) g, W. { Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.) N8 G. y  V# P8 l2 ~* d" B8 r- n5 u
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.* F* O* r5 w9 o% z1 n" K4 G# `
 The interface should provide a menu so that the staff can:
+ \  ?$ c* |. b$ W5 L& ta) Enter the names of the two Java program files to be compared
6 x( I3 ?8 S9 y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 I3 L# E" S( ]  d7 I% {
** 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).
/ l- f0 L' s6 r; `7 x- JBSA104 Business Programming – 2007: Assignment 2
$ b5 g/ l% f3 X# F; B( x3 vPage 2 of 5
* }' j8 ?- U9 d) p5 tb) Print out to the screen all the lines of code that are the same! N4 x2 V' d" [& `, K) e* z, U% t- x
 Include the name of the file and the line number of the code being printed for each of the two files
. l# {. _- t2 ~c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ C# ^. D& d5 c- u  ` the name, username and department of the user  f; d$ z7 r, q3 n1 v" E
 the statistics of the comparison3 W9 F1 u3 R; y/ v1 x" ?7 A
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
5 @. }  \1 ]0 R" b, z the recommendation for further checking- {6 O8 j7 |3 y1 C8 s
- 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 closely0 l/ v* a" t- |' j$ N: V6 v3 s9 T
 the names of the two files compared0 a3 f% }; z4 U4 V- w5 t
d) Leave the program (exit)! B( D! A- i; {0 @$ \
The ProgramCompare class: (Total maximum 20 marks available)
! k# A  T- C: C/ J0 J: E5 b2. 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)  W1 |( Q9 `9 g4 A
a) provide an error message if the files are not found or there is a problem opening them
% b) J4 T5 j& fb) compare each line of code3 u: N; D2 g0 m/ _! ~* U# P2 B! B# e
c) print out the lines that are the same8 Z. \2 D$ ]! f' j8 q& k
d) count the number of lines compared / lines the same
& Q. G' a0 u3 b1 q, j) O% rThe AuthorisedUsers class: (Total maximum 20 marks available)
  L2 z  n$ D: a% E3. 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)' E0 W7 ]: L/ i- `; y7 m( d
4. Provide methods to:/ {$ w) `5 A% t' g
a) 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
6 X9 u+ ]: |2 o5 M6 c8 }b) return the name of the authorised user
( z% z2 y( T" G! m( y4 |  vc) return the name of the department of the authorised user
8 A! }9 z& m: F' B  WIndividual Data (Maximum 20 marks available)6 F; P/ w* V. e% M. i
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.5 J2 D) E9 R% ^& [) t; H5 b
Documentation (Maximum 10 marks available)  z. [: `  G7 A
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.  i# G; x7 g, v4 ^# K7 Q
BSA104 Business Programming – 2007: Assignment 2
4 K- w# U& J/ _/ i# A' }% IPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了, A! t0 D" G* {/ \- M- r1 l
不过你要翻JAVA的类库说明。你有下载没有?
; ^6 u1 t. c% l2 |7 X9 H5 K查询关于对比的函数。貌似关键字是contrast,还有compare9 ?& L; E# j( ~  _" g

$ v) K( P6 |( E6 J* |[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -* U/ Q& W* _+ [, P- o% {
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 Z# k- T0 \7 E5 _+ ?' i可以下载到的 是 jdk-1_X_0-doc+ F" _; S9 a* a" C

7 h0 @/ N& ?1 X) M: ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-10 04:07

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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