找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1809|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) T. U; r8 D, k. x/ z# y5 H$ a* H$ P; ]1 W* G) n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 }6 r2 ?6 P+ {2 p7 [0 y5 [9 q//  ProgramCompare.java         Provided by: DRS2 o1 {. Z6 U- Y/ @
//
' k! C7 }5 c) K* g7 Y9 s2 I//  Program shell for Assignment 2
3 j3 L; e: H3 a( A- ~3 ?//
, v% H" z! F; T2 s3 L9 c//  Compares two text files line by line
, J/ P6 X2 w% V//*********************************************************************; g( R- A0 E1 Q7 @1 ?( l

! K+ D( S! R& [9 Simport java.io.*;0 o7 I3 C6 o% x/ Q) k' Q/ K

: H/ r! b4 X$ w; tpublic class ProgramCompare; s( `! g* J6 H6 q& q
{5 h9 [- p8 T7 h* `1 [" v, {& v5 v5 Q
        //-----------------------------------------------------------------8 W( B. T' G" D
        // Constructor
  \/ E( j8 H. n# T% X        //-----------------------------------------------------------------
: ]5 r/ m0 G8 F+ [8 T1 z        public ProgramCompare()  ]. `4 t0 S4 x" |
        {
2 H- w/ J: m9 f! f$ L) ?  S# ~; w/ C        }
8 V; [5 X, i1 j: C- j' _. l2 [& p: t
. {- w/ X/ W! T( [7 [6 q        //-----------------------------------------------------------------' B% s# A4 F9 _) C
        // Method for testing that class has been reached0 r/ |5 k' V. I3 Z9 w' S
        //-----------------------------------------------------------------        % m: \( O. z5 K, n7 Z; K
* W3 S8 u7 x8 Z5 a* l& }7 _. }
        public boolean ProgramCompareReached()        
+ s( a4 a4 i# T- ^        {
# M3 l2 R; o: m: x  d% H% M# O      try ' `9 R3 d; ~1 f  S/ k
   {         ) E# _! O* t7 p: p' j1 _/ c
                       
, S( L. \; w) V: B                //********************************************************************5 J8 n$ l3 L& q$ ]" d$ f
                // Try-Catch Statement is used to handle exceptions - such as file not found , {5 U# ~! N' C0 E5 O. E: j
                // Reading the files will need to be placed inside a Try-Catch - just like this one!! `2 ]# E" m9 ~+ }! E  Q1 |
                // For more information see page 534 of the textbook' T1 s! ?& P8 ~0 O) n$ [6 h+ V
                //********************************************************************; v5 x+ |' N. b1 ~
                    
- R" Z6 z# }3 _" C: P        }
5 c! n+ _5 V* |+ D             catch (Exception ex) // Exception caught here and message displayed to the screen
& i+ v1 p; p. S" X, M          {
- F" o$ Q# y# Q4 K  Q6 G                    ex.printStackTrace (System.err);
' _# K; Y6 m% ?1 z  ^           System.out.println ("Error message goes here"); // Replace this error message with your own          ! V; x) A" ^* r: }3 {
        }( P' q0 C; ]( _, u
                return true;
# C0 d' b! ~9 s4 w% F        }- V( g5 w; i: }# S  p- w
( a! z$ W8 Q; ~2 B+ D
} // end of class ProgramCompare, e2 v2 g% `- v3 k

# A' V+ G6 l$ u; z7 l8 [2 g, y% ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- j) O! |! Z+ t1 |' F* k- R7 ^
//  ProgramCompareMenu.java    Provided by: DRS
2 T4 A; u7 k/ X$ I3 Q4 x, k; |//
7 O% U# ]# D% y- M2 Z//  Calls AuthorisedUsers.java and ProgramCompare.java% v2 p8 N: ?! ?' Z9 }
//
" x- @( r3 ~& I2 u8 Z# \: P//  Driver shell for Assignment 2." B- C9 \* e! Z, G
//********************************************************************
! Q1 @# i1 v; U- m: E
. j  s0 t$ {' A/ c2 `, Qclass ProgramCompareMenu
$ C# H: k3 a  @{6 t5 R3 D8 L$ a; i1 M
    public static void main (String[] args)
! w) u+ E+ @* C/ K( G7 \  z            {
4 X. L0 D4 p) g% G- \                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 S! e4 ^- V1 L' {; M: I, Y* V5 s                ProgramCompare reached1 = new ProgramCompare(); . ?7 P5 M! S* H. U3 s
                AuthorisedUsers reached2 = new AuthorisedUsers();        : S+ C- n5 P8 u: D
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' }* D( o! |* E$ L
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        3 b8 k2 C: E$ s. {  y8 U
        }7 Z* w. M, Z! u5 j% E+ k
}// end of class ProgramCompareMenu( ?5 G1 x) t4 \3 J0 m4 c
$ X3 e& B' ~% K! K4 ~% S% O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
+ ^: ?5 b  X; i1 d. w//          AuthorisedUsers.java          Provided by: DRS* g5 N$ v5 p/ ]
//               
: {1 S" L# j' g* m; T! g' |//         Program shell for Assignment 29 W: G" V" n3 a/ f/ M2 Z% \
//
1 v8 A7 P' c9 Y! a//         Represents facts about an AuthorisedUser. y9 |3 Y2 E4 f5 F- S: s" P
//********************************************************************, ~  D! a! x# _7 L
- `9 q' b8 M7 B. B& D; f5 l
public class AuthorisedUsers
/ c, h0 y/ {5 @% {& k  K7 z    {$ l" F3 K( Z5 V7 z2 L! e# n
! c( c1 p+ s" ]/ K9 v$ w% ?
        //-----------------------------------------------------------------
. }: L9 ^# J3 s8 Q        // Constructor
+ U& O2 z' ?/ ^        //-----------------------------------------------------------------9 n3 F! l: q( |# O3 R# z4 r
$ |: c0 Z+ P' K$ ?" d4 J
        public AuthorisedUsers()
: n5 P! o) H* H4 K                {
0 o; o2 M' I. F2 S" ]5 S7 N* h, s                }! M/ j* p' e: ?" l1 T1 }, ?3 t

/ b9 h5 `* ^8 D" e$ Q        //-----------------------------------------------------------------. J, o; q- q6 W
        // Method for testing that class has been reached6 E! P' y  v: Y  R
        //-----------------------------------------------------------------        ( N: Q- H  e  c! F; r
        public boolean AuthorisedUsersReached()
$ m, O5 `) ~0 r/ K6 i                {* z3 X6 y7 j9 i, @# J7 \( f
                        return true;                       
2 K' I' v4 T; Z! {4 _5 w                }$ t# d2 Z6 k( n2 Q
                # B7 S6 d" a+ p
    } // end of class AuthorisedUsers
+ s/ {. U5 G6 P- ^, F" M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 c. p/ R; u; u6 B; u* `5 A# o
Shanghai - 2007: G6 u6 ^9 d8 f7 A7 |+ O: ]
Assignment 2
  i* T3 G7 \: n$ 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)! i  e* h8 F& M) B- H) a4 u
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.) m# P$ z; u$ _6 _3 J; M
The staff must be able to:# Y% R0 X& P+ ^4 v6 \% K
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& t, Z9 ]% x# z1. 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.* b( S6 E3 M$ [* n
 The interface should provide a menu so that the staff can:& G7 J, o8 T; `5 X  a
a) Enter the names of the two Java program files to be compared  Y9 M) A- W$ s! ^6 s
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 ^, z& j2 |  r$ J8 }+ g) Z/ 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).
9 H' u( K% o! D1 W9 ?$ UBSA104 Business Programming – 2007: Assignment 20 P/ Y8 H( q1 s0 H! e
Page 2 of 5
' }. b) ]" Z3 K& z  Xb) Print out to the screen all the lines of code that are the same. i+ a5 O, O. A6 j5 z9 h! j! y  @
 Include the name of the file and the line number of the code being printed for each of the two files  B+ S* w! g( s& P* P, [
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 Y6 c2 G5 s, M' f$ [
 the name, username and department of the user
0 C+ `0 w2 R2 @/ u4 q" k9 P. q the statistics of the comparison
, h+ ^- t1 q# y) K- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! s3 X# `) G& q( l
 the recommendation for further checking
- H9 U: B8 n% t. y- 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( n. o, \  a6 L4 U: t
 the names of the two files compared
; s* F+ v/ Z8 Q7 G+ Wd) Leave the program (exit)
5 b; s4 E6 p+ WThe ProgramCompare class: (Total maximum 20 marks available); j5 t5 _( T, t/ W- |
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)) _; e, K; N% O& M/ [7 h7 \' O, `) ~
a) provide an error message if the files are not found or there is a problem opening them
. X7 s2 f. ]2 }* ~  z+ ^$ ~b) compare each line of code3 `$ i7 \$ ^5 {9 D; M9 X: x6 y
c) print out the lines that are the same' u7 D& b5 Z5 r* T1 w
d) count the number of lines compared / lines the same
  @4 [2 j: |0 L( t( jThe AuthorisedUsers class: (Total maximum 20 marks available)
; b* ]3 P& q6 [- d3. 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)
; s6 H# T% Q( s) ]+ {& z. t' A- w4. Provide methods to:' F2 O8 v6 T- ?% H2 B1 M" h8 G4 k
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
6 I! `, L5 z9 G4 f! ]9 fb) return the name of the authorised user3 Y: y' F1 J5 C4 g+ t
c) return the name of the department of the authorised user
5 M0 L5 K# z9 {+ S" x  f# yIndividual Data (Maximum 20 marks available)
. T  R* o5 D1 |' L5. 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.
3 @/ z- W1 O6 {" a0 s" ~* aDocumentation (Maximum 10 marks available)" n$ s) R5 b) N9 C, l9 m" x7 T) M0 h
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.
  f$ [+ b% U$ B: H( h* U* zBSA104 Business Programming – 2007: Assignment 2; r, U& r5 q1 |# h$ ]" S" U
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! B  b2 ^- W7 O) T3 v! H不过你要翻JAVA的类库说明。你有下载没有?/ C3 }# \4 G/ x3 W
查询关于对比的函数。貌似关键字是contrast,还有compare6 e. m7 C: S' _  c/ y  y& W3 O0 `

9 B  K3 q8 @6 s2 V0 b[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 h! j$ D: x3 Z; J, G4 H0 j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ G) W: _4 J( U- A4 J
可以下载到的 是 jdk-1_X_0-doc. Y. J! n7 p( n) w6 g' y3 p: p
9 J2 m* w* {3 E% N4 {+ n; N5 U
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-9 09:43

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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