找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1527|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) a" p# A% o! {/ K1 W 7 M: H7 z! x" F* U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************# z  P; w! B, A& E  P4 ?$ Y
//  ProgramCompare.java         Provided by: DRS: x5 K* C# W+ c* T+ R5 Z9 [
//
+ V, n& K  A# W1 w% s" o7 ]- u//  Program shell for Assignment 2) P) ]# h3 y3 X7 S" d& Q
//! \' N7 _, e8 r* ]& \( v
//  Compares two text files line by line
2 K4 _7 ^% ^+ H" g' H" n* O//*********************************************************************
: ]: x2 A- j: Y2 h) w9 }1 m
! |$ k# a( ^# H% I) e. Simport java.io.*;; J5 D& w) f  B& h) M) J! J
- ?& c6 R% C2 U( ]9 w5 r
public class ProgramCompare+ \0 G% s9 n' F
{
2 v1 R* c1 k0 c* D: @        //-----------------------------------------------------------------
$ n, H/ U) K- O  f5 O+ P1 G        // Constructor  w& A% D2 d- k
        //-----------------------------------------------------------------( Z2 @- l, u4 C/ h' I$ W1 N
        public ProgramCompare()2 x" m1 E8 A% v
        {
8 ?" A5 k6 |  p! \$ P7 a        }' l% P4 ^' E& C. T6 `7 D
0 b) D2 p9 I) }  }
        //-----------------------------------------------------------------
6 f2 d) m- o& U: N' v        // Method for testing that class has been reached! s; }6 o) H/ J) v* O6 J- \; Q
        //-----------------------------------------------------------------        4 j* i% Y# ^! ~1 k8 m; {7 X
, f' W! o* S! z# w: s: ]
        public boolean ProgramCompareReached()         : |! v! D/ U7 q/ i+ f0 V
        {; C& H8 t( z9 D" q: U
      try
/ d6 p* Q7 `" X5 V) W7 ^2 h& g   {        
2 b7 d( X6 E2 B                        1 N9 i! D: q+ s8 v6 @, S4 F
                //********************************************************************; M' D/ n8 b9 [5 P9 a9 ?) p6 ?
                // Try-Catch Statement is used to handle exceptions - such as file not found
7 |' s/ v% F* o( r: r. a5 W. [                // Reading the files will need to be placed inside a Try-Catch - just like this one!* H8 _$ R8 _! i. ]1 h4 ^) F3 Z
                // For more information see page 534 of the textbook
7 N3 W, y7 v- ^4 v" v  m7 X4 A! t                //********************************************************************
) B' f- {/ l! A1 z- a, T/ B$ |! u                    
6 H2 _9 V5 V6 Q8 \        }5 d% ^5 k+ l  F' I! W% L
             catch (Exception ex) // Exception caught here and message displayed to the screen
$ q. a. w' b2 w( T) S/ g          {& W* C* @9 R# t. S
                    ex.printStackTrace (System.err);* f3 @# M1 h+ r
           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 @2 j8 w& V7 w2 }+ n2 Z        }
+ \% G. s/ Z- u: Q+ |9 C% A                return true;- u# t, l  C1 q# t' r
        }
6 L; c  a# I0 M% u1 C" \* o8 t7 k
) ^( a9 K  |# j} // end of class ProgramCompare3 W! ?9 ~7 c& e7 |
4 {9 u( p! N* Q7 F( M1 `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! r  c7 a  x! _7 `# {# T: E4 g
//  ProgramCompareMenu.java    Provided by: DRS$ p- V+ J) L' P' I2 c% M
//1 d1 R/ _& |- ^
//  Calls AuthorisedUsers.java and ProgramCompare.java# e; z3 M& m4 u
//
/ `  `, m  B% P' h//  Driver shell for Assignment 2.+ f1 m& S4 w& I
//********************************************************************+ x! V: Q* ^$ Q) n
( p- @2 ^8 T% V
class ProgramCompareMenu( Y" u5 n: S4 u! v" [# m) T
{( ~9 K3 ]6 g6 }: c! Y) z) V
    public static void main (String[] args)
/ E/ ~( b1 z7 T9 ^9 b) `( l            {* U3 h7 H8 }# G+ c1 K
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* t1 }0 f$ R! {+ ^2 d5 h+ `8 Y6 }                ProgramCompare reached1 = new ProgramCompare();   \' ^+ t* v" i- K$ n( |
                AuthorisedUsers reached2 = new AuthorisedUsers();        , c; J# L% _" |" n7 n( N
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());; x% @1 z  _/ e: C  }7 [! l8 H
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" q8 v8 o" T* o. g        }# I9 U1 K; y8 v( S
}// end of class ProgramCompareMenu
! N0 f+ p5 f/ j2 _5 J
8 G" ~# a$ M# Y! r1 J# a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 t/ M- p% ]( o8 }* h//          AuthorisedUsers.java          Provided by: DRS
8 m! H. S* ~( G! o% M//               
8 o3 i/ l5 d( ^- T  A8 D//         Program shell for Assignment 2
5 C) T# j& t0 D//
" p1 D/ J/ U/ h! D" f* a+ y7 y//         Represents facts about an AuthorisedUser
6 `, r% E8 l; S0 B* v/ u//********************************************************************9 m4 M  O4 p  Q

) l0 z* ^; k! [+ B$ b" x4 Bpublic class AuthorisedUsers; H$ k3 R6 ]6 |) m% o0 W, @) @6 i
    {3 B6 r0 U( V7 `% Q2 ]
9 q. k; z8 X6 V7 l. b# }. p
        //-----------------------------------------------------------------
7 h1 ?) Q( ?9 \$ m: ?; V+ F; e        // Constructor( t; ]9 t, N3 {2 P3 j
        //-----------------------------------------------------------------
- Q5 |8 W! z% f; P1 M* u# f% L( A6 F% U$ D$ A
        public AuthorisedUsers()6 j5 W, P* J4 b* ?
                {
' X1 n5 |* q. f5 d                }
6 i* k6 e( U- |3 M. ~; H- n. a: O9 o' o: h" W( G
        //-----------------------------------------------------------------  U. S9 G# W8 D9 d# q) |
        // Method for testing that class has been reached2 Z- w5 C  z& }8 N6 q& O
        //-----------------------------------------------------------------          r5 [8 Q3 q. }( J
        public boolean AuthorisedUsersReached()! i8 P$ d: V& e+ A$ ^# S
                {0 T* m; A+ i  N
                        return true;                        ! |4 h! |7 H0 P) ~
                }
4 y3 R8 a3 o1 f" V+ I/ v4 f  L                0 J% J) d" q# r7 z/ g
    } // end of class AuthorisedUsers5 f2 A0 ]! ]) p, W8 T. u0 o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" V7 ?; r6 T: \3 BShanghai - 2007' F. ]8 ?2 p& J% L; @
Assignment 2
  F: Y) o5 Y& r) h3 V1 jDeadline 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 H7 S5 S% Q- t' w5 Q3 t1. 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.
/ q: [+ Z; h' C$ T2 A8 `The staff must be able to:& s) W: c- G- q' y/ u. q0 N! ^- R
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.' L& B  h* d6 ~
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.9 G1 ]2 m' m2 y  E( L: G0 q
 The interface should provide a menu so that the staff can:
% N# j, ~' C4 F; T- `8 m0 ja) Enter the names of the two Java program files to be compared
# R; g* _$ m6 [7 ~" t& i0 w8 h For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% y; W1 Y: `0 c& x3 N
** 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).# t. S+ O3 p9 z% g  x9 g
BSA104 Business Programming – 2007: Assignment 2
9 q% P+ L& l/ cPage 2 of 5. w( P, B8 E, n( m5 `, X$ Y3 J
b) Print out to the screen all the lines of code that are the same
8 A3 Q- R6 M0 |5 w Include the name of the file and the line number of the code being printed for each of the two files
+ Y; o3 ^+ h& yc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 w0 R; M; H* |. J! T. ?
 the name, username and department of the user
" }% O% r1 C+ c; R the statistics of the comparison
9 `( h9 I1 r' Y) o- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
5 i9 j+ s/ ]' x: x( @/ P2 A the recommendation for further checking. I+ M  s. ]3 U; V% z# Q' {# C
- 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
! |0 s& S, b0 _- g: v the names of the two files compared
) R8 l% ^: U  o% jd) Leave the program (exit)
! X0 j  E' u( B9 IThe ProgramCompare class: (Total maximum 20 marks available)
6 i# s. A5 b" L/ x: G: Z2. 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)
# k% y- R( T  v$ Fa) provide an error message if the files are not found or there is a problem opening them. }( J* H/ V) G  O$ \2 R8 T: G
b) compare each line of code
5 T/ Q5 K5 t) D* L! ?& Y0 Tc) print out the lines that are the same. N, X4 p& M/ f% w  l/ r% z
d) count the number of lines compared / lines the same3 N0 D: s2 Y: O% E4 W! v0 Y
The AuthorisedUsers class: (Total maximum 20 marks available); h4 T, E/ s: Y7 o
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)! a9 z3 r' Y9 D6 L# v7 u
4. Provide methods to:
* t  q! |& _( \; ]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$ G$ `7 m4 [7 e
b) return the name of the authorised user
" o! D& r& W4 ]% nc) return the name of the department of the authorised user
. P. ?$ c+ L7 m; g# d- LIndividual Data (Maximum 20 marks available)
/ a8 d+ o3 f' i$ U- g; b0 P, @: f3 P5. 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.0 Y) h9 a6 i6 y
Documentation (Maximum 10 marks available)) r5 P0 v# V4 ?6 s, |! Y
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.
) G/ \( S6 \$ e' IBSA104 Business Programming – 2007: Assignment 2
! E! i* e2 ^, [Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了6 [' U8 a* U' d8 L( j  h/ s9 C
不过你要翻JAVA的类库说明。你有下载没有?" W, Y' B% z; H/ C
查询关于对比的函数。貌似关键字是contrast,还有compare! T% s* |" d; j3 `4 t+ w1 l

: @! E3 Y8 I% s+ L( {) x" J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -: M9 y: i' L) t
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" A/ r, B! }+ h5 ~* [% A可以下载到的 是 jdk-1_X_0-doc& Z% u/ v+ n' W5 d  B- J, F- v
- L% A; B; Q) i; ]# Z3 H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-8 13:25

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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