找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1484|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 b: ^) w' F# ~" n . x- M! h0 [, |: Q- X6 n( 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 | 显示全部楼层
//*********************************************************************
" p7 m+ W: D" Z7 y& n8 W2 V//  ProgramCompare.java         Provided by: DRS( z) }8 ?3 H( F& \3 |  N$ x
//
# i8 Q2 |" t3 O0 x  C- [9 h3 t//  Program shell for Assignment 2
5 o) W! s3 X2 f' C9 N# B//
9 K+ e9 H6 z: U7 P: x//  Compares two text files line by line
5 x/ t0 M5 H. H; {  H//*********************************************************************
# L( _. i8 k  l
2 I" }; X# H* {" F, F) himport java.io.*;; b6 m" ^  z  I: _0 ]# M, ]

) f) I7 D+ G. jpublic class ProgramCompare; ?; }' g; g; m. z* v, t$ y
{6 x- e4 L1 \1 e. U! w- T4 i
        //-----------------------------------------------------------------
) r4 \  n( T# |" F0 K$ E$ Y        // Constructor$ [2 k# q; `- P* Z6 F6 w
        //-----------------------------------------------------------------! ?: s& H4 c% U1 e; s
        public ProgramCompare()
$ j6 R) R2 @! O2 w5 f        {+ |$ \! ^- v( B( c$ ~+ {
        }
2 s, F  P- I. n" {4 t( V
' ]* [  E  D: h: n4 y; j, E        //------------------------------------------------------------------ \" h0 a3 E: E$ Y! P
        // Method for testing that class has been reached% z" {! R3 \2 w
        //-----------------------------------------------------------------       
" ^1 G6 ^2 y4 M: t
2 ~* f! V0 W. ]: {+ S. l        public boolean ProgramCompareReached()        
2 A5 r2 w$ ]# ]+ K0 u; F' k        {& v) ], ^' `* c
      try
. _# D* f7 n3 J+ U; D+ l   {        
0 B. [- Y) l1 R# ~" ~$ i+ o                        7 _' ]* D- M0 x- @$ ?- D5 A
                //********************************************************************# ~8 r# X3 o3 P$ z# C" @8 t( c
                // Try-Catch Statement is used to handle exceptions - such as file not found
6 r) ^1 }& x) e! s+ }# Z                // Reading the files will need to be placed inside a Try-Catch - just like this one!# `. Q4 D3 ]& g/ ~  S
                // For more information see page 534 of the textbook, i3 E: }% `4 s
                //********************************************************************
* h$ r- m- W+ [7 l                     ) Y. T) O8 @7 Q: ?3 ]
        }% {/ g; }7 W) N! O
             catch (Exception ex) // Exception caught here and message displayed to the screen & U9 ?5 m1 [1 P) n6 V& T: t) c
          {8 _$ J: w5 p  Z' y; Z: k6 b- i
                    ex.printStackTrace (System.err);
0 f, X, [/ }0 p2 E# w           System.out.println ("Error message goes here"); // Replace this error message with your own         
: q8 y* I& ^4 }5 \9 o  S        }$ U9 W1 Y/ o- O& r' w9 g  q
                return true;) X' E6 H: P: u
        }
, b  H2 Z5 ^* ?: v9 b5 p
% T. g& C- {0 }2 u; J" i} // end of class ProgramCompare
* C* S( H" T( v: g
3 x  X2 l# M  \6 u& P/ y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( P9 ]5 Q2 X3 ~" o# R# I3 }! c//  ProgramCompareMenu.java    Provided by: DRS+ u3 q/ O$ j/ ~: \
//
# F: u, B4 ~  E- u//  Calls AuthorisedUsers.java and ProgramCompare.java, r0 E% }( J9 T3 P: |
//
1 Y0 }0 {, Y/ V7 C/ F8 `//  Driver shell for Assignment 2.
, A7 t4 }$ [& o7 Q9 w2 |//********************************************************************$ P* ^: b' U& V: O
" W$ t+ _5 W: Y/ m+ H
class ProgramCompareMenu# l7 u, z$ u9 T7 V3 H8 E3 y
{: M- Q! r2 l$ y, @$ k- R
    public static void main (String[] args)  t" U* K* N. r' u
            {) z" Q, n: n! F  t2 f
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) `# ?& V/ a2 A# p( S" i                ProgramCompare reached1 = new ProgramCompare();   J0 d1 d, N9 R& [5 |  e4 I- F0 o
                AuthorisedUsers reached2 = new AuthorisedUsers();       
4 x) j" b1 V6 g: a                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 y) ]8 S! t% k9 X/ ~4 Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) _- h+ e0 C; n0 m1 F        }* X$ J. a( w; h9 }9 _
}// end of class ProgramCompareMenu) p% c( {& _) U% o8 j

  |1 {. G% h, T) U+ H& z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
6 e+ J8 Z# d6 Z//          AuthorisedUsers.java          Provided by: DRS
9 X4 s4 m4 q) ?( o3 c//                , _. G, l6 {. H' N- e
//         Program shell for Assignment 2
# w5 G! B# j+ y, T1 C6 q! U' I//+ V6 d% M" u3 c) D8 k
//         Represents facts about an AuthorisedUser6 |6 |% }7 }) k  e
//********************************************************************" [8 f$ G7 B! s) c1 S# j9 F

# `( R7 L2 m; ]public class AuthorisedUsers0 T- i% z- K6 U: L2 H9 x5 B( D0 c
    {
7 i6 ~$ B* L3 A2 i! J
* @; z5 p* o: n7 e        //-----------------------------------------------------------------
7 G$ {  m! R! S, P; U$ y& }        // Constructor$ h2 d% g% d* Z/ P( U' ~2 i, K
        //-----------------------------------------------------------------
# k" L6 s; t+ `& Z( b1 `% [  p$ B: b  M$ h) v' m
        public AuthorisedUsers()" f6 `- T% H: r8 M: c9 m
                {+ x, c5 b! [3 C1 W! Y
                }
" h: r% i2 Z" l. W1 n
- p. x7 j' u3 r4 D. v9 Q/ h9 @" s        //-----------------------------------------------------------------. c' N. I2 i' Z' ?- F; B3 X
        // Method for testing that class has been reached
# _5 r9 [6 a7 C, S( X: V        //-----------------------------------------------------------------       
5 W# b7 Z3 g! F        public boolean AuthorisedUsersReached()
1 t( ^$ L4 F" Y3 Q                {# \% I6 \% c' k
                        return true;                       
6 U' P2 v, F( \5 r$ v9 V                }
" u* M9 J; K2 w9 c4 A$ ]7 P                0 e2 T% R6 L0 k% F
    } // end of class AuthorisedUsers
2 i. i7 P' }7 C$ L* Z9 o/ Y# S4 A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, a# c3 s# k- R0 |, a) s+ aShanghai - 20072 r* g! o1 U' t) W" h& r' b
Assignment 27 Y( V# t' u3 @3 ?8 S3 u( T6 F
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)! A9 I! U; j% I  x  a# Q& ^  `4 y: \2 ]% X
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 q$ r7 {: Y0 `2 Y; t$ |& F
The staff must be able to:* A6 i1 ?6 c- b/ C  V. g# X
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ I2 i3 d. i! X2 ]- z/ E1. 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.0 c$ i5 s1 x3 I# Y( z9 _
 The interface should provide a menu so that the staff can:
3 R' s5 X4 R4 D% y6 Da) Enter the names of the two Java program files to be compared
* l- q& Q+ T! g/ d1 A# E1 ] For this assignment, it will be assumed that the two Java program files are in the same folder as your program., \& u: E* D$ y
** 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).
- j! W; }# D6 ^  x9 v5 tBSA104 Business Programming – 2007: Assignment 2
0 b  t/ @# R/ u; hPage 2 of 5* K3 {  ^9 D+ D! ~) z* O
b) Print out to the screen all the lines of code that are the same% A- }5 V+ _2 g. Z
 Include the name of the file and the line number of the code being printed for each of the two files
+ E+ D5 d/ R; J3 S5 r  t9 m, ?* uc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% Q7 y' }5 y# l+ z, z, j
 the name, username and department of the user
0 `; \  \9 ^/ B- z8 O the statistics of the comparison
3 N. ^0 i8 H1 @- J% A6 j- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
- O6 R2 ]# v! J3 v the recommendation for further checking
. B1 g2 [  v/ ]' l: w4 V; M/ W: z8 P- 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
. G  Z* v3 D1 m( f: y the names of the two files compared
/ l2 f" x4 [3 H) M7 t, Ed) Leave the program (exit)7 V0 m" \+ S1 b
The ProgramCompare class: (Total maximum 20 marks available)1 Y  e. e+ r0 S) d* P$ d7 \
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)* x1 z% m3 N6 p& \* u/ q1 P
a) provide an error message if the files are not found or there is a problem opening them! P' V* z  G9 n* L5 y8 {( B  X
b) compare each line of code
7 J3 S  U1 V- pc) print out the lines that are the same& i4 M, |& e7 Z$ U- y8 q
d) count the number of lines compared / lines the same# ~7 O4 n! P7 P* P8 p) v
The AuthorisedUsers class: (Total maximum 20 marks available)7 L! D9 k" k- b2 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)
. ~, x, K3 |/ f4. Provide methods to:) R5 H) |% c8 F, F
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( ?4 |8 f* O0 M  e
b) return the name of the authorised user6 M! Q, j6 ]0 ?2 W, a7 e
c) return the name of the department of the authorised user: M2 w1 |/ F  _$ m+ D  k
Individual Data (Maximum 20 marks available). k" h, C/ r8 e5 B4 ]( [7 P, C9 x
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.  j8 V8 @, r. D. b; C" D% w
Documentation (Maximum 10 marks available)  A+ a: u8 a: K9 o" Q: @! \
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.' {9 J6 o! V, B4 w( R, l7 \' y
BSA104 Business Programming – 2007: Assignment 2
& t% d; \. k) RPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
6 e, W: ~4 g) F8 E' g0 Y不过你要翻JAVA的类库说明。你有下载没有?% j( B' s% n) d& T0 N% I8 y
查询关于对比的函数。貌似关键字是contrast,还有compare
$ a6 d  E) Q- q) V
* D+ w" J* Q, R3 e  S[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) i- W  f4 P/ W& M' n7 q& b: M$ V+ ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& a' t/ A$ Y; p0 g$ d可以下载到的 是 jdk-1_X_0-doc
9 f* m3 V! ~1 m8 P- {( o: {, Y8 Z( O  l; }
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-24 23:57

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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