找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1858|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: ]3 d" r" z7 R4 c- W0 t% w; j 2 `* N/ i, G" z7 a* g
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
+ O7 s2 e& x! f( W3 Z; o//  ProgramCompare.java         Provided by: DRS
2 m1 _2 C; W- ~2 w% r! z  b4 T$ D//2 h# d! W3 l  B% M5 l
//  Program shell for Assignment 2
7 ?- g# _& C; H, n. l//
" j% A" A, o5 Y- U7 }8 Z  d//  Compares two text files line by line
- b$ f8 m, H8 k* p//*********************************************************************
9 {1 m! f4 p/ i: V9 k1 s: `4 h2 t2 k& _7 r% ]3 Z. w8 v# A
import java.io.*;
$ L/ b8 F. V, i1 f# [* G9 W0 A
, J. e; @' f$ _* ?  D* B0 o. ipublic class ProgramCompare9 Y+ a. s7 o& d! M
{2 \* `) h/ m/ Q1 n
        //-----------------------------------------------------------------: Z1 Y& h/ s5 w0 k4 X
        // Constructor
& z! \" s9 a. x1 r6 z        //-----------------------------------------------------------------8 P0 \6 |3 ]0 ^/ b* L' p
        public ProgramCompare()- N! G: V+ L% P6 Q$ D$ v
        {( f1 q1 ~& q# E" \( T
        }
  b8 }( {' _0 r' G9 _6 l5 s/ ~* N. ]' a
        //-----------------------------------------------------------------: _) _* r5 [3 R# ^* ]; v' f
        // Method for testing that class has been reached
3 `4 c( o# _$ e4 F        //-----------------------------------------------------------------       
5 K& f9 b+ }' ~0 X- D
* W( H: C3 Q8 W8 a# @" C        public boolean ProgramCompareReached()         - G! k& S9 E4 N
        {
  t* D1 |6 K4 \3 Q* W% P      try ! _7 `0 e  w1 x' v( J
   {         1 z8 ~7 I% o* k) |9 _, h
                       
) p( l; W' z& X                //********************************************************************% }8 K% H7 B/ C8 @) F
                // Try-Catch Statement is used to handle exceptions - such as file not found
: S$ Z. o* v( U% }                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ J6 z3 o) I! ]. n& |0 }0 J( T
                // For more information see page 534 of the textbook
# n# C% S) C# k0 x) d& ^; y                //********************************************************************# t8 J1 y+ O1 b0 d- p# B
                     + }9 X# o) S1 F9 ?3 h+ o% \" e
        }% [9 O) \. ^2 N# V
             catch (Exception ex) // Exception caught here and message displayed to the screen
% z5 q4 y+ w- ]( C          {
0 Y: ~! ]5 Y' _: n                    ex.printStackTrace (System.err);
, V2 w0 B) D: p% Y8 }( @, l0 {           System.out.println ("Error message goes here"); // Replace this error message with your own          5 I" b  m! \2 V% |( [  E5 M
        }, f5 [* m; z9 V/ [
                return true;
; {; }. _! P  Z$ W        }
" u, y4 M0 E$ W4 a5 y
  e0 r/ N) W+ w$ F9 t- N: j: Q} // end of class ProgramCompare
) V+ l2 F7 e7 A  g$ ~" [! `4 ^' l* q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 [- [$ R# e" ^
//  ProgramCompareMenu.java    Provided by: DRS7 V! @' J. `) u$ b) n% f
//
4 Y5 y( D1 G; B7 b, G$ P//  Calls AuthorisedUsers.java and ProgramCompare.java6 e/ R* m- u+ p+ T) l% x/ g( f* H( R
//
1 K! i% F0 X  A3 n1 C/ |) P% V//  Driver shell for Assignment 2.0 {  K; F) e* I. H
//********************************************************************
. r% X2 |8 U9 [% S3 u/ o
( S8 B+ u6 Q' [4 ~class ProgramCompareMenu
1 n& D2 X; `7 }# t1 M5 f, o  J1 X# t{
7 |; Q9 o, z2 x/ p/ S2 W    public static void main (String[] args)
4 [  |" i( K9 v. k            {6 `+ g% [& ~  J0 y' s. L: P. U  f6 o
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 T! n6 _( E5 z6 [
                ProgramCompare reached1 = new ProgramCompare(); 0 k6 v% Z( J1 q
                AuthorisedUsers reached2 = new AuthorisedUsers();        : K2 n& d8 E! |% M0 {5 w  L. N- z; |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 r! P3 k! U2 M; V' f9 A9 O* i
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / e6 F7 N7 L" B
        }& @$ _0 y* X- S/ ?% g
}// end of class ProgramCompareMenu# P. G, m7 w; m( I

' J7 B- h$ \1 _0 g2 t8 x, d  k& F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: l" ~+ [0 k( A  q, k//          AuthorisedUsers.java          Provided by: DRS
' q% F$ d6 F* b% @//               
3 _& p' }3 _$ Y6 J( s//         Program shell for Assignment 2- s/ e6 @3 f! D, y$ _" t% r
//
( @' v7 {9 P4 i! [9 K//         Represents facts about an AuthorisedUser( _# h) L8 _3 W- s( s- Y
//********************************************************************0 j* d1 ^& A9 Q: D/ E% l! `

) m: D0 I3 C; x! |  Ppublic class AuthorisedUsers
0 F8 A1 m8 @3 h' i6 O. i& n    {
1 @# a7 T2 q3 T3 w8 F  [$ g4 S) r6 e- K5 N
        //-----------------------------------------------------------------
3 o+ P; x' P% O6 O+ P- G: T: U        // Constructor3 \4 u5 e. [1 l& \5 k% y/ {
        //-----------------------------------------------------------------+ u! z# a9 E) Y% u
; ]* u" N" ~$ \& x1 k
        public AuthorisedUsers()
- W9 J( K6 P) F1 T# \                {
3 h+ Y- k: @" L                }
# L: t6 Q6 U5 o
% G* R. j3 y5 O1 U( `        //-----------------------------------------------------------------
, W1 Q; r! b, r- K        // Method for testing that class has been reached
" U( t& c; w# u        //-----------------------------------------------------------------       
: p3 z9 c2 x$ S+ z        public boolean AuthorisedUsersReached()
5 e$ S; l3 i9 y/ `                {; [. @# q, H& q2 z0 j5 U, f" r
                        return true;                       
1 n9 r# R3 k' E+ X; V6 ~( I                }
5 W) b9 C% i  @' X/ {2 [               
! x% N: @( k% L    } // end of class AuthorisedUsers
2 i0 ^, l, G* K6 n6 ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
7 d6 X% U8 |* C$ vShanghai - 2007
7 U: J  f  n/ n$ t1 u$ a+ Z7 fAssignment 2
- s/ ^! l1 |6 w; YDeadline 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)2 n0 X- V) S% P0 D1 u2 v1 g: e
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.5 ~5 ?  ^& d: o) t' \8 D! ~/ O
The staff must be able to:/ d; i7 I1 U# X" K' z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **." I* Z: v! K# J$ ]1 N. y3 M
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.+ n$ L2 Q7 Q# o
 The interface should provide a menu so that the staff can:2 c# l& c& T4 a: Y" Z' H5 e' f/ N
a) Enter the names of the two Java program files to be compared3 k+ ^' {5 Z6 Q9 I- s
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 V2 f8 u7 C7 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).8 [* ^9 R- `! H% a  |
BSA104 Business Programming – 2007: Assignment 2
6 O9 A/ V" c6 \& nPage 2 of 5
( W4 l( U, K1 ?# f9 pb) Print out to the screen all the lines of code that are the same
% E* |# ]7 Z, R) D9 c Include the name of the file and the line number of the code being printed for each of the two files3 N# @' w- G9 _" ^5 i0 \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
  [" O% x" t) u! Y; q( F the name, username and department of the user
* p5 y& Q& b( C0 Y( y the statistics of the comparison
' f. x) j4 |+ [+ d- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
2 \7 ]6 y* n# z( X the recommendation for further checking
7 k  k/ p7 P, r, q7 M% }1 f- 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
% E' U7 D5 e4 d9 d: N  }) h8 R the names of the two files compared: `& p* U. i; ?3 X9 v
d) Leave the program (exit)
) L* w6 ^2 l$ \, zThe ProgramCompare class: (Total maximum 20 marks available)
, y, S; k8 y7 e( e' g2. 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)
6 G: ]3 X; l8 G0 Z- A6 m6 wa) provide an error message if the files are not found or there is a problem opening them
8 |4 N2 _2 s, y" `# hb) compare each line of code
1 ]; h) w% c8 y: C/ T# Y, f& Oc) print out the lines that are the same
0 s8 P) ^5 A: S$ ]7 g" p: y9 Td) count the number of lines compared / lines the same/ g% F5 R" |  J$ r' N
The AuthorisedUsers class: (Total maximum 20 marks available)- \+ P( X$ e! {) e* Q
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)# ?9 B+ Y# V  B, T
4. Provide methods to:
5 ?# z5 z' u% ?/ x* ^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( N5 f; x& |& e1 Y: A% q5 Q; i- m
b) return the name of the authorised user$ }/ t+ G7 Y8 ^0 \
c) return the name of the department of the authorised user, \  x0 ~" @% i) ]8 ^! L( S$ r
Individual Data (Maximum 20 marks available)0 {, y+ m. r$ e3 K, m7 @, G
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.; ^4 f7 P, Z9 I/ N) ~/ {# V
Documentation (Maximum 10 marks available)' S5 h' o' ]$ p' Y3 ?  b
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.
  K; d+ s- Y/ j, K# S6 ?BSA104 Business Programming – 2007: Assignment 24 H# @3 S4 m( R0 M
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ i: ^, w/ p0 M3 {, g
不过你要翻JAVA的类库说明。你有下载没有?1 S# W/ F; ~9 I7 X! L
查询关于对比的函数。貌似关键字是contrast,还有compare4 `, S( M4 ]. e8 [
) z# g  j. p# ?3 S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -- |+ M* q! x4 `8 b3 I8 _8 i
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
2 F3 D4 V' P$ l* ^  W' h可以下载到的 是 jdk-1_X_0-doc
$ T; F! u0 {1 ~: G+ \$ p9 M% ]' \' @' P3 m+ ^: Y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-26 19:09

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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