找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1090|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 T5 o7 U8 j e7 P# K9 o/ |; p% ]6 E- S0 B5 K, u0 y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************5 k: }4 l* c3 z+ s; y9 `9 {/ l
//  ProgramCompare.java         Provided by: DRS: [. l3 |$ |: {8 T5 G0 z6 B- n7 o; y
//
" {. h6 m6 W; m4 f" _- k7 @3 _//  Program shell for Assignment 2
& _: x$ M7 U; R( t0 m* Q9 k5 ^//6 Y- u8 E" ?& F5 B" i" o
//  Compares two text files line by line
# G* z: [, h+ s3 o//*********************************************************************/ O, a1 ^4 d9 ^  S! Y

" @9 O+ j) P. A7 ^/ c& Iimport java.io.*;1 u$ D" a+ g% H  }) x7 O; P% Q) z

# ^! @1 [8 u3 H# h- k4 s" k9 bpublic class ProgramCompare7 e( M! B" X& {$ t+ c
{
" E$ D5 J6 {: f, i0 \9 U1 X        //-----------------------------------------------------------------
, ^9 m+ r# j% Z+ ^8 t        // Constructor9 @- e0 Z" f9 h; H* C
        //-----------------------------------------------------------------0 v' T3 W# @8 ^7 T! p9 `* c
        public ProgramCompare()
7 D+ ]7 G( j/ |/ o        {
" |% S4 j! }8 j/ X9 f        }$ t! t/ O% u) z7 o: }/ d  L# D- ?
$ a$ u+ Y  Z+ D' q
        //-----------------------------------------------------------------
, |6 N$ _+ Y5 J* Y8 ^% `5 U        // Method for testing that class has been reached1 g7 `# d$ y# g" s' W
        //-----------------------------------------------------------------       
3 P1 ~3 |7 L5 p1 K
' C6 {/ u3 j) O5 G* R        public boolean ProgramCompareReached()         3 L% I$ q2 [! b* G5 I
        {
9 e5 x/ l- S+ \. U4 `      try
4 x2 D5 g7 ?+ L* r" t; j   {         $ s$ @- \% c' u4 J) a& k) \
                        : r- K& g% x: i" P* c, {- B6 \
                //********************************************************************
2 s8 z' j! t9 H6 ~# y0 K                // Try-Catch Statement is used to handle exceptions - such as file not found
$ _# Y$ M! M4 L5 m. g% z; |                // Reading the files will need to be placed inside a Try-Catch - just like this one!' r# W4 ]  M7 j2 {) k: a  `/ e
                // For more information see page 534 of the textbook
# L+ ^* q! n, P# P" p! C                //********************************************************************3 X2 @+ K2 A* Q, K# D1 R$ _
                    
2 H' k+ J1 d2 j9 h% j, R/ ^        }7 f, T1 a$ B8 Z: O/ \0 f
             catch (Exception ex) // Exception caught here and message displayed to the screen 3 s' E1 B6 f2 L7 t9 D6 a
          {
. @4 X$ b% b, o& G+ G0 w; k1 s                    ex.printStackTrace (System.err);
4 n. m' e$ b! M" D# E2 U; {6 K7 o           System.out.println ("Error message goes here"); // Replace this error message with your own         
6 O# m3 i6 K- e- w2 x( o        }
) t5 R* s, G9 G+ |0 P# v                return true;7 D$ s/ k0 E: ]% ]- w  v
        }
6 e/ P- s! h& c& v' l2 q1 A! f# s9 b- k- p3 W- Q
} // end of class ProgramCompare
1 |  B0 P0 h  U, {% B+ V; m2 k) r0 S1 G# z1 j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 A% C! O  ~( Q1 |. l' y8 E//  ProgramCompareMenu.java    Provided by: DRS' b) M2 _1 w, j) U- g
//
" d! T$ }' t4 E! R+ b. [//  Calls AuthorisedUsers.java and ProgramCompare.java
+ {) f  q$ t6 E; |6 z7 C//5 N- M4 n/ ?0 m% J4 k1 u1 a8 @
//  Driver shell for Assignment 2.2 d- [# K* \5 V: s& a6 K# p
//********************************************************************
5 |" K$ Z( U% h* e" D
  U; G9 B3 q! o4 E5 Q  Cclass ProgramCompareMenu2 @- B( e# Z; N0 v- U( y9 S$ l
{8 |$ O9 c- i4 f% L: Q/ h! ~( B/ s$ V
    public static void main (String[] args)
. z: d% E! F3 |. @% A) w            {: Q* r+ ^; G& I" P0 L7 p
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 ~) C" I% d9 u8 A1 u9 W& p                ProgramCompare reached1 = new ProgramCompare(); 0 L% ?& o5 O* }& u3 y
                AuthorisedUsers reached2 = new AuthorisedUsers();       
# Q; @5 f' b8 ~6 c8 B7 S$ n' E0 l6 l                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. @) T2 g5 g$ ]! p7 @1 w. S                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  q6 D' O# F2 U  b9 R( B        }
- o* y* ?$ S! {4 A}// end of class ProgramCompareMenu
: m% v0 t; S& @  q
( H! m: z5 a% ^+ G7 N  c# w* o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 f) y+ a; Y+ O. p//          AuthorisedUsers.java          Provided by: DRS/ Y3 O/ J( x; @
//                0 h: Z; N  g" E2 B# M: {; N1 Q& }
//         Program shell for Assignment 2
, O# q: H( g, z9 w* D//) j1 K. M+ R) B6 g7 H6 J3 ^2 R
//         Represents facts about an AuthorisedUser
2 d" ~  P1 z& H% }5 _8 s) _//********************************************************************9 \- L9 q. h5 q& l) A

7 t  Z( C/ c* Jpublic class AuthorisedUsers0 Q* W; l' p' v! T: Q
    {, r: T5 a1 [. k
- n" K" {6 P) J1 `9 V' _( b
        //-----------------------------------------------------------------+ J! i: z7 {; l- p- [' o$ M
        // Constructor% D3 l7 J% m" K/ ?1 ~
        //-----------------------------------------------------------------
! X6 m/ R0 Q( W
' ^( G. y6 g+ U) W; _! ?        public AuthorisedUsers()7 c) D. y: z) T+ d! P
                {
* b# B2 ^! c1 C8 m                }* ~- O) M3 S, B/ q+ t

) G+ E7 ~: x; f; U$ ]1 N1 Y# ]        //-----------------------------------------------------------------& P, g/ T+ t6 W$ ]( l# t& `0 }
        // Method for testing that class has been reached
' ?+ P9 G' O  ]& a& F; T7 t        //-----------------------------------------------------------------        7 h7 x. ~4 R# F  o3 Z
        public boolean AuthorisedUsersReached()
8 F/ y. U% c" x                {& ]& F/ q: E+ n: d9 b$ y' a/ r: @
                        return true;                        4 x: g$ E8 k! ?
                }; ~- o8 E) k6 l3 k" r% f
               
+ c0 w, m' j/ ?$ J3 ~    } // end of class AuthorisedUsers
' l) ^% _" Y- K9 ~6 p5 {7 `7 A/ V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ @1 N, p: {2 [
Shanghai - 2007
7 I* q$ D8 c7 m5 [6 Z+ Z' ^Assignment 2
& n" C3 d# e  `! s; LDeadline 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)% F% I2 F4 x' U0 Z
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.3 D: b% }6 k4 T& U
The staff must be able to:  U8 i. w: h3 G6 _" i2 ?
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* N  W' m8 s% }# Z7 |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.
+ O# ~- s/ i$ D- B6 x/ m4 g" Q! U* ~ The interface should provide a menu so that the staff can:8 I9 ^9 z0 P% x' k+ G4 X
a) Enter the names of the two Java program files to be compared3 ]$ g8 e; Z0 g' g
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ S) _1 `0 x7 {6 h1 _** 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).7 m  w4 N9 n  o9 V2 A7 S4 \; |9 C* Y
BSA104 Business Programming – 2007: Assignment 21 L3 i1 S5 t# G5 u. u4 I/ f) O$ m
Page 2 of 5
$ R; B9 T0 J! C, f! i: Vb) Print out to the screen all the lines of code that are the same: n0 Q, }  i' |1 n2 e
 Include the name of the file and the line number of the code being printed for each of the two files4 ~! {5 R) y$ i# o. i" V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
/ v# N* k. F/ y3 v* Y1 H/ k the name, username and department of the user
; B2 U. o3 _" |* a the statistics of the comparison
) e' E/ @. F) s- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
: q6 E; m8 R4 y the recommendation for further checking
# T2 w5 o$ a4 r; w! j- 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 closely9 P$ K1 c* A. A; [5 n( A
 the names of the two files compared
; C8 @# s' J& w8 Z8 l9 td) Leave the program (exit)
0 C; k3 b1 B) V% c+ n; Y# `The ProgramCompare class: (Total maximum 20 marks available)
$ B1 g8 w8 N0 T2. 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)
  [# S% @3 p9 j/ X" `4 Qa) provide an error message if the files are not found or there is a problem opening them  _4 q; b( r+ S/ j
b) compare each line of code, W0 V% p( d% o$ o
c) print out the lines that are the same0 m; i& H8 r  t1 e
d) count the number of lines compared / lines the same
' v. H5 q! X( D$ s2 LThe AuthorisedUsers class: (Total maximum 20 marks available)
4 Y, ^/ A% s: N; w7 c3. 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)- T8 m6 V, F9 z+ b
4. Provide methods to:
5 H, T/ l) h2 r! i' L! e- Aa) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match3 u6 c2 W; v8 _9 s8 w4 {5 Z
b) return the name of the authorised user
, k! z' O$ m6 d5 O3 L) P* Zc) return the name of the department of the authorised user
4 L6 C$ k4 P5 U- L* I5 BIndividual Data (Maximum 20 marks available)
9 l% G# R! _2 I1 B9 ~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 ?# H& a8 q9 ~+ V" }$ tDocumentation (Maximum 10 marks available)9 N8 M) `, e/ w
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.
" C; M, c! r1 k. s6 l. H+ l, t/ Z+ {BSA104 Business Programming – 2007: Assignment 2% @/ [$ z) v, @: \
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& Q2 `8 v5 d5 X% q+ t6 c8 i& k' \不过你要翻JAVA的类库说明。你有下载没有?
1 k& b- l- z( I& u7 c查询关于对比的函数。貌似关键字是contrast,还有compare
6 r( p: W1 K8 ]
) n( N9 T4 z1 H5 \/ {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ b6 `/ f' J3 B" N/ X- p3 |* F痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
# Z) e; E; f/ m可以下载到的 是 jdk-1_X_0-doc
3 [" ]( r  k- v& ?( D4 j! l7 p
) j0 {6 X4 c- I: u[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-3 18:05

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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