找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1362|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 I6 U7 [7 c; U, r: i% R $ V; i% w- P4 S2 P" ]6 F
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
+ @" i, ~7 A! p) K//  ProgramCompare.java         Provided by: DRS
, p7 R: Z0 ]' d! u//
% y/ k4 ~1 r/ C5 _: P4 l# Z0 w//  Program shell for Assignment 20 l2 g2 b) U" f8 r
//
' {- S* f" j1 G$ Y9 k//  Compares two text files line by line
4 `/ v2 t; M6 O3 h# z) H, n# I$ @//*********************************************************************
! r2 C$ T9 x% Z; a: X9 O
& }% G4 m: t& M% J/ m" }import java.io.*;# B( M. w7 j: E9 y8 T
5 t. Y$ n. l( H3 L
public class ProgramCompare
* y% H8 `4 T, l) _- j{! ?4 f( \3 h5 N, V. D( V) L( o" t
        //-----------------------------------------------------------------* |2 v2 t( |+ D; }8 X3 s
        // Constructor; V5 Z7 v1 G) c0 x* V
        //-----------------------------------------------------------------! H) F5 W. f9 ]# U) S! b
        public ProgramCompare()5 G% j8 Y4 k8 D& P$ n& ]0 g3 m2 _
        {
& i. Z" k4 v) z  {4 f5 ?: W        }* M, {  v* J* P; a  A7 N0 l+ O
% L" j2 z7 }/ o+ z. d
        //-----------------------------------------------------------------
3 L% j* N( u) E/ n6 u9 D4 G        // Method for testing that class has been reached! E; n( l" k4 j  K
        //-----------------------------------------------------------------       
2 n) i6 y& |- A5 Y9 M
8 [, y. {8 }& m9 p/ E1 o        public boolean ProgramCompareReached()        
% ]9 c. M$ X8 y' N0 u+ M        {8 k7 g3 J+ a6 j4 x+ F
      try
& u4 M) f" I1 l* G+ `% u4 ]   {        
9 \& L- z4 S. H                        / m' w  u3 N8 z: d+ h) F& z  Y
                //********************************************************************; U% T3 w( j! Z" j! k% e( g" K" B
                // Try-Catch Statement is used to handle exceptions - such as file not found
7 c' ~3 N. G9 H% z! m. d                // Reading the files will need to be placed inside a Try-Catch - just like this one!" J' n/ G7 _) H( k: _* r
                // For more information see page 534 of the textbook
0 J- H5 R& ^0 w& C2 m                //********************************************************************
1 E! x- F" f( n3 O# v3 e( {                     8 p# g; I! D! w2 O% Q1 t
        }  d: y6 R/ \  i1 M! Q( Y, L
             catch (Exception ex) // Exception caught here and message displayed to the screen , G( f% u, s! G$ v( O
          {
0 F) s  g9 x( z  z0 ^: F# ^                    ex.printStackTrace (System.err);
" ~, y, m2 v3 h           System.out.println ("Error message goes here"); // Replace this error message with your own          : {5 b1 D' p! ]
        }1 W1 f" [, g% ]
                return true;
7 C) `+ u0 K0 E2 d3 [# G! U, P        }! H! B9 P+ p  j/ q

% P. B, L) K! ?/ x% C3 X} // end of class ProgramCompare& w  A- o; a4 {" T& L! [2 V
; [5 e: }0 `+ L, B. J) ?, ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# o1 w4 A% o$ }; }% G" s/ Q+ R$ i
//  ProgramCompareMenu.java    Provided by: DRS
" [* ?, Z0 R6 k1 \+ B//) o' b. I( M- ~( Z* L; p1 F& G( _3 o
//  Calls AuthorisedUsers.java and ProgramCompare.java
9 M3 H. M0 G2 j6 ?- S//
# v) t& C7 I9 m6 I" f0 F9 e//  Driver shell for Assignment 2.5 F" W& N" d1 s0 D& U* l
//********************************************************************7 p) R, Y- n  ^9 v+ r4 V% @4 {

: ]. y3 V9 R. R2 Nclass ProgramCompareMenu0 p$ O2 q6 i' H& n) d1 K
{
7 h  P8 U% ~3 r9 R9 t8 c& o: _: s6 m    public static void main (String[] args)
3 e% c; y$ v0 j# n5 h+ g$ N; a+ N            {( }  F) Y* @4 d1 ^. G1 }* [
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, G  a. y7 n7 h$ f1 e' v$ x, N                ProgramCompare reached1 = new ProgramCompare(); + {* v$ y3 ~$ p/ X" f" E
                AuthorisedUsers reached2 = new AuthorisedUsers();        . o* e0 R1 k7 V, M" p5 ^& z8 P
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 f$ r* K2 m8 Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        3 {+ V2 ?- j& U1 ]( x( m
        }
( h/ |" s2 W4 S* [0 }. x}// end of class ProgramCompareMenu
/ G6 o" g2 G0 T/ g& z+ z. d4 b  Q0 H% c! h, m5 y, _+ U
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 z: [, t& ~. X- x) R( F) ]
//          AuthorisedUsers.java          Provided by: DRS
  P* h7 g4 C! |//               
1 m+ r7 K' p7 W% ^//         Program shell for Assignment 2
/ C  B7 v3 G( i& W- L//# E, j* R' t! M% h$ K1 t2 v
//         Represents facts about an AuthorisedUser
3 l. v7 _0 @# d" o$ z& ~//********************************************************************
8 G) V/ Z: X0 e7 _) @1 t9 e4 w" P% X* D: L
public class AuthorisedUsers
3 Y+ |. q. O. }* L" D( w  X* v    {
$ `1 w0 j1 R5 F; X4 }
4 D4 B6 ~3 A: k3 d& S        //-----------------------------------------------------------------
8 y$ `: Q! n; n! e- Q1 ~% g        // Constructor2 G, i2 y5 h$ G' }2 o
        //-----------------------------------------------------------------
; f4 P) D, x8 Y1 C+ P( L% E8 V/ q; {7 W# ~- _3 J
        public AuthorisedUsers(), V9 ]; F6 ?( L- y
                {( ^& U3 q; `9 v" h" i/ W& I
                }3 |" @" Q) A: k# d5 B; J* m0 Z/ l0 ?

: A' G1 R1 M8 s. S        //-----------------------------------------------------------------
/ o1 k9 N) F6 d5 v4 k; b* Y7 d7 f        // Method for testing that class has been reached
8 f0 Z( [+ e" K9 Y7 T% u9 s        //-----------------------------------------------------------------        1 i' b, {: i) v: O9 u! s0 L
        public boolean AuthorisedUsersReached()
+ m7 }. a7 e; A                {
' Q0 u6 x8 r( w, U                        return true;                        ! ^) N# }7 j1 O" m0 n
                }5 }8 c" G* M' h! z0 ?7 L
                ; S+ \' f0 K( r& ]
    } // end of class AuthorisedUsers( p3 @- w! r) j+ f0 F0 N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
+ `/ E3 `+ K- i! X) c: @' UShanghai - 2007, i8 Q: G9 x) K: v3 ~0 }) }7 b
Assignment 2
& E4 G1 b$ H# v" s, v0 A( ODeadline 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)# J  t! s, o$ n3 r9 n1 s/ L* a
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.
$ ?9 j- W" ]- G% m; Q2 pThe staff must be able to:! Y4 ?( g4 v' a$ B; B! J* F) p7 Z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 L; e8 ?# h1 h1. 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.
( g7 r/ M5 p# z2 x% [# }# J, X The interface should provide a menu so that the staff can:
: N/ x) M( G& `a) Enter the names of the two Java program files to be compared
1 p- W7 E6 w% Y, Y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.5 ^* g$ `: o& c
** 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).
' g. g  Q' r7 |( y! e6 ~1 f$ SBSA104 Business Programming – 2007: Assignment 2
! U5 f, H1 i; O/ s6 i3 l/ qPage 2 of 5
0 x+ V0 g5 k2 h9 j. v7 V/ n. tb) Print out to the screen all the lines of code that are the same
& Q% s$ g3 _% \9 \ Include the name of the file and the line number of the code being printed for each of the two files
, X7 F4 T" _/ G3 A' m1 p  Jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; p/ N1 m& F5 e( j* y
 the name, username and department of the user
, @" G: n0 u% U1 F( d& o the statistics of the comparison3 j& \4 f6 P5 r1 e7 W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different9 |: |; Z6 p. A2 Y  s
 the recommendation for further checking
% C7 S3 q5 Z; a* i1 c$ v- 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- Y6 `9 d0 h$ O( ^; S3 T$ k  D! q
 the names of the two files compared& W! T: j! u# B; @
d) Leave the program (exit)* _- y$ d+ {  @8 L2 o+ I, m
The ProgramCompare class: (Total maximum 20 marks available)
9 e: i' c2 U0 }, n7 k7 z- L2. 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)
2 E, p) T7 g9 A1 x; Va) provide an error message if the files are not found or there is a problem opening them
; @, {" m: m) l5 Z5 Pb) compare each line of code, u* t; {% R/ t" g4 |+ e
c) print out the lines that are the same
+ ]" d" y4 B5 ?, h1 ^$ ed) count the number of lines compared / lines the same
* i' Q2 N& _9 b5 ^: e0 w7 oThe AuthorisedUsers class: (Total maximum 20 marks available)% |/ o; ^5 L9 E- x' }- M
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)
* L7 }$ T7 F- w5 s: [4. Provide methods to:
7 g- e& C6 t/ J& h4 c: ba) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match5 M9 T* v; e" H1 c# K' H5 E- g
b) return the name of the authorised user
( ?) K& T: j9 M$ pc) return the name of the department of the authorised user  O5 h9 i1 N$ u$ t3 K
Individual Data (Maximum 20 marks available)2 b( l6 c( n$ Y' ^
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.. U/ L; t( w! p
Documentation (Maximum 10 marks available)
' m/ b6 R: f+ f" T) e5 _; m# 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.
- b5 ]( o: a, |8 b$ I) N! J5 k5 zBSA104 Business Programming – 2007: Assignment 2  b; @8 z1 n, ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( h2 F8 V5 g* g不过你要翻JAVA的类库说明。你有下载没有?
# Q$ H; q) G: H, U7 {; p3 M" n4 d0 C/ |查询关于对比的函数。貌似关键字是contrast,还有compare
2 [; _; I# s+ C/ o( L0 K  Z) d) {" V0 O5 o$ K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 P- q: z9 l/ {
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。6 u9 }) I' l8 \; `2 o8 k
可以下载到的 是 jdk-1_X_0-doc
0 R$ [2 ?9 g8 h+ ^3 u6 l# l1 Y. R5 }# i4 C( D( K; n. M" @* \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-7 17:12

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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