找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1169|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 ]' D% ]! A! x3 N [ 0 j2 X4 ]% r% U/ R2 B
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************7 a  ^) f  x: a! `5 @1 F( u: j; N
//  ProgramCompare.java         Provided by: DRS# U4 ], W' I% {2 p" i, a3 {
//* I0 ~( M1 z# n, ?* }
//  Program shell for Assignment 2
1 L; e$ U8 e; I9 Y//& R( }- c" I) E; J' h
//  Compares two text files line by line" P9 M$ n) R7 X
//*********************************************************************6 N4 ]/ \3 _1 P/ S! U) @

2 o% n* l  i2 k! eimport java.io.*;! N0 p1 F- T! L. K+ H7 e

$ a% m# S! M8 p# e% w/ W0 d$ vpublic class ProgramCompare
' D2 {* ?" j1 h! c( |{
* \8 G) v( T) j. i0 O        //-----------------------------------------------------------------
9 x) R. O5 i% Z" l. g, x        // Constructor' }8 G) G2 F0 q: f
        //-----------------------------------------------------------------
2 f" E8 s; u* t/ V8 @6 u        public ProgramCompare()$ M( x) N" w$ ~( E9 B
        {
" b* Y! E: L" M/ b        }8 B* O! n7 P& @, \

1 u4 |, E8 q/ ?3 N2 v" z/ B6 o        //-----------------------------------------------------------------
, G9 a* M* |& H2 n        // Method for testing that class has been reached& r( f6 i- Z# M. a+ r
        //-----------------------------------------------------------------       
6 {7 {# o2 i8 u* `( `
% ?0 u3 B, M5 [! V        public boolean ProgramCompareReached()        
; x% Z9 i; q. g# \6 E        {; |8 |+ p7 b7 w
      try ; o, j! \' }/ S0 z. o! g( l8 {/ q# R
   {        
2 T2 N2 ^# u5 N7 B" X/ i. x. M1 H# v                        " ]0 u3 P1 @7 F# @7 R# m
                //********************************************************************4 V7 D& p! \$ P' W" C( O  t
                // Try-Catch Statement is used to handle exceptions - such as file not found - N; h" S5 A+ F) a* p
                // Reading the files will need to be placed inside a Try-Catch - just like this one!$ J( @7 O$ Y0 p2 Q, N- W! B
                // For more information see page 534 of the textbook8 ^" m9 k# O$ ]. \+ v; Y' n
                //********************************************************************
( F* x* D# I6 {3 h                    
% U2 Y- Y: @$ }        }6 _7 W( r* y1 ~% h
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 j7 w2 K& G1 d( s3 {
          {
" I& w: S% U8 q* c6 K; \, A                    ex.printStackTrace (System.err);
0 Z7 d4 _( z! t9 t  R0 |           System.out.println ("Error message goes here"); // Replace this error message with your own         
& N/ c6 n1 v0 P" b, x        }
3 F8 ]1 r1 {3 a/ q5 |" q: @  P( C                return true;# J* B% e* g% [- s% H
        }
% N% l, i' W, W/ p0 y& @( m3 I7 x: a' o. c8 q+ Q6 u
} // end of class ProgramCompare) J; M/ g% H2 B- W; e1 _: G# e( T

" }" \9 @5 X/ f: w: j* T( p/ k, p3 ]+ b; f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) R( n/ {, t, ?0 B" J3 N
//  ProgramCompareMenu.java    Provided by: DRS
" \- q: \& p/ T' N. z' P, |; k% Y* ?//
* d+ o0 b2 `8 C  v# r- u9 W) c//  Calls AuthorisedUsers.java and ProgramCompare.java  l% V* C# R" S# m0 A% H, R+ J
//0 b/ O+ h0 i) U0 c2 B, u
//  Driver shell for Assignment 2.( g; q; t0 L7 X6 u
//********************************************************************
& N1 ?7 i) {3 o' `# e" p4 n- Q% J
6 h0 W: H# P& p/ F- S  _( [( xclass ProgramCompareMenu
8 @- ^+ w- V- N5 @" A{
) c" Q9 j; `! O. V* o' R    public static void main (String[] args)
. \6 n! ?$ D6 n5 A* F9 [            {
8 G, [( _2 [9 y' E* N/ N, l                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 k& h/ t: ~: F% F9 \9 U3 i
                ProgramCompare reached1 = new ProgramCompare(); # _: N2 y' G- j% S7 K
                AuthorisedUsers reached2 = new AuthorisedUsers();       
: P! V# [1 ~7 w/ [% S                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 M* N  t0 V8 w0 @  M" a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        " [" X, o0 c+ w
        }8 A( z& s7 W: B$ r/ e3 s
}// end of class ProgramCompareMenu4 f! P( }$ Z. O& h+ T3 B

. @3 Q  ^& e$ M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 t: z2 w1 t. S& w% z" x- @: A# w7 \
//          AuthorisedUsers.java          Provided by: DRS$ D/ X& ^3 e( _: S' `; p
//               
5 G5 y' F* A. s( G/ w//         Program shell for Assignment 28 P4 @9 r0 u4 m% Z/ _: U* W
//
+ `. u/ r- D. l' x/ a$ \) G+ I//         Represents facts about an AuthorisedUser! j6 k- t8 U& T
//********************************************************************/ A0 i! D* e+ t

7 E" {% a' n" u6 Kpublic class AuthorisedUsers
# _9 l) S, R: V: s    {
" y( c1 m# q: _7 x( i5 c- h
  J( s4 G% L8 m9 Q* D. Y' f        //-----------------------------------------------------------------
3 P1 ]/ |3 f* E  U$ L        // Constructor
6 z' B: [! }. L" a8 x, O        //-----------------------------------------------------------------
/ b+ N6 V& f7 E7 w! ?6 }0 d" I, s* f$ E
        public AuthorisedUsers()% ^5 T! q5 t8 v- ?# `& z( ?
                {
+ b3 [4 t! ~+ j5 E+ i                }
4 M5 s! Y7 A$ m) q" _5 S; D
! Q# w. b$ y( B8 D% ^) @' L* N        //-----------------------------------------------------------------4 Q4 p7 F4 R: L" R1 k' k
        // Method for testing that class has been reached
, Q. [* h9 Y4 i1 b9 x& H        //-----------------------------------------------------------------       
8 \. X" l) `0 D! o        public boolean AuthorisedUsersReached()
: a$ ]' K; r) _8 q: O7 e9 P( D                {
2 z7 `4 q. |" f                        return true;                       
0 z! W8 U! O( w                }+ F  b- B  L) E! `. r! r- m9 \
                ! p3 B9 {$ A4 ~7 |
    } // end of class AuthorisedUsers
1 _+ C. l2 M/ y' A# I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: g* c& A% x3 P; s/ O3 p/ r
Shanghai - 2007
9 D# B/ d2 W) X7 A8 QAssignment 2
& U3 N+ }1 p+ q8 B4 c& ^8 vDeadline 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)! Q- P3 ?5 I; i1 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.; t# i, F- H' Q, Q. \: o* r9 W
The staff must be able to:! M4 t# y1 c0 g7 I5 T
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
$ M6 F, i( F! {$ {* X6 j3 }) [0 M1. 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.
$ W) J9 ?8 ?1 e2 m The interface should provide a menu so that the staff can:- B) z3 Q2 H6 y1 S
a) Enter the names of the two Java program files to be compared5 W1 p# j4 S% J
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 C; ^, Z6 U# k1 _' M* S: t) d** 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).
, B- r; L2 r$ l( I) ~" x0 `BSA104 Business Programming – 2007: Assignment 2
) ^6 z* X/ s1 r9 V% MPage 2 of 5
4 W8 ?. a! h+ r9 \  [  A5 Z/ H% hb) Print out to the screen all the lines of code that are the same
! X& J1 s7 y# o  ` Include the name of the file and the line number of the code being printed for each of the two files! x/ ]5 W; q# q4 z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 o; [8 f- C- F6 G, r! a/ F( n the name, username and department of the user# v& T7 i5 \/ \: m( Z3 I6 t: b% o
 the statistics of the comparison( I  _$ h4 b5 E' Q$ s% u% T
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* f' }% V8 H( ?8 R& S$ L, D the recommendation for further checking( f( x( w+ c  H7 z
- 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 closely6 q. g6 m: B6 U. }
 the names of the two files compared( z6 a$ n% n. I7 H$ X% O. O
d) Leave the program (exit)
! e& L# i1 c( {, r9 d- x0 x/ JThe ProgramCompare class: (Total maximum 20 marks available)6 o; l" a6 t6 r8 a( N
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)3 C  ], ^3 Q4 ~0 G& P
a) provide an error message if the files are not found or there is a problem opening them4 [2 K, w" {/ G+ E- W, Z. O
b) compare each line of code
& t, B# |2 q* X2 f% H. u$ y7 Y# xc) print out the lines that are the same
# E( {2 @  O0 y5 n" e5 N6 P& f8 wd) count the number of lines compared / lines the same
) ?  d4 i( Q1 i4 B/ Q0 j/ T% PThe AuthorisedUsers class: (Total maximum 20 marks available)
0 M, \; V5 D. }; N3 N" \. k1 f3. 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): Z/ Y9 p+ ?2 |, u
4. Provide methods to:
1 {$ x  P: K* y7 a) b0 A) Da) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match4 @4 O3 v  b- U+ O0 c% g: ^; u
b) return the name of the authorised user
+ U% t% o3 k  a6 ic) return the name of the department of the authorised user8 [) }. Z  v. t7 A# w
Individual Data (Maximum 20 marks available)) N- f  |3 L0 }2 i% r2 R
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 k2 T# S' D: {; jDocumentation (Maximum 10 marks available)* R7 G3 i+ J0 ^) P' O) G
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.0 a! b% e0 O0 ^" q, S+ J
BSA104 Business Programming – 2007: Assignment 2
( N% u, h; l! X; n# Y3 DPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
9 l" t: J3 ~4 U4 _+ o# V7 W不过你要翻JAVA的类库说明。你有下载没有?
: M) C8 `0 D  u8 k$ c0 a查询关于对比的函数。貌似关键字是contrast,还有compare. S( J0 q3 G  I% M
; \: |+ Y3 q7 [
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -$ N2 u- N2 I$ g* M9 |% q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 h8 e- B* a! L# a
可以下载到的 是 jdk-1_X_0-doc
) ]2 {# X- _" V! ?
4 }- }7 I5 N9 y* l9 k. P1 t: F[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-8 10:50

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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