找回密码
 注册

QQ登录

只需一步,快速开始

查看: 940|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: y8 B& ]. r4 [1 s3 Q 0 f2 b/ R9 r8 z/ e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************, A+ |* c* ~0 V( O4 c$ E
//  ProgramCompare.java         Provided by: DRS
( k. D, z1 V5 E* o//
% @$ z) Y6 [* a1 x//  Program shell for Assignment 20 C4 d7 d$ p% b9 v( e
//
0 D. n: r  X5 m& M+ h//  Compares two text files line by line4 h7 k- C$ u" ?; p1 [4 s; U
//*********************************************************************
7 r" Y( y, z& B) e4 ^( w
' x9 l3 a8 C6 e5 t# ?0 Q( ^- W! mimport java.io.*;
7 I$ v" J' T* i- E  X) t8 M0 ~& |' [9 v# q
public class ProgramCompare- v% l* z! T' n' M: ~
{4 m2 b- p; V3 V0 p" j4 R
        //-----------------------------------------------------------------  ?3 r+ ]  ?3 I- a& K
        // Constructor7 d7 j7 n0 {- i: A; R
        //-----------------------------------------------------------------
) }9 E) o) S6 Z        public ProgramCompare()
7 y' v+ ^  d  [  W) o+ x        {; q: d' T7 J3 n5 l5 d! l$ c0 E
        }
5 u3 V) A) K: b1 V8 o8 F1 `* X6 p6 \. {% w% x9 J2 C
        //-----------------------------------------------------------------
- l1 G* q7 c  K: A4 O        // Method for testing that class has been reached( {; J8 Z9 y4 F: d! ]! A
        //-----------------------------------------------------------------       
1 U8 ~& b9 r* Q. e
% E* R/ y, f$ l        public boolean ProgramCompareReached()        
* l. ^" v8 C6 e; R8 s        {0 @" x- i( A4 Y8 z  n
      try
( m! P0 i: o) }  T( }/ I- y! S0 ~) v   {         " A- ]$ p" B  T% y& p! G0 p9 S( ]+ f
                        0 _0 o5 x" P8 e- E( z' A
                //********************************************************************2 Y9 ~% i# M3 T3 K; Q, b3 V; D
                // Try-Catch Statement is used to handle exceptions - such as file not found 9 x; f0 v. W" D4 ^8 v4 q2 B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ |9 T+ P% H4 {) n- C& ^/ {0 l5 |1 y                // For more information see page 534 of the textbook8 j$ I' u3 f8 y' x
                //********************************************************************
: e, U$ e; W4 f4 Z. c, C! v                     0 [* C+ S0 H) q0 z
        }0 M, d5 F. S/ J' a* z& b
             catch (Exception ex) // Exception caught here and message displayed to the screen
6 ^% u4 m- {! O& z7 E3 v' L7 N9 ~6 M          {
+ o/ A% i: ?( \% S: }                    ex.printStackTrace (System.err);
3 U. N2 x% Y. T0 N# E* w, O* L" w           System.out.println ("Error message goes here"); // Replace this error message with your own          . _/ `8 k- @' t4 ]
        }; m, y1 y- g- a/ _/ P" Y1 d; C
                return true;+ j$ f9 E& I  O& p
        }" P" u. B. |+ J' Z8 p8 O  @3 ^

2 v* r# B% M2 U& z& S9 l) a( a} // end of class ProgramCompare# e, A8 O) j  A3 {
3 h* L. R3 L* l9 s  F' c) N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************/ P! W, b: K" \) o2 h7 F/ J
//  ProgramCompareMenu.java    Provided by: DRS
# h, a! E, }/ C) i//
7 [' |& a% v& l% s//  Calls AuthorisedUsers.java and ProgramCompare.java
1 Y6 O- ?) Q& x5 ?; E8 g  p, K//
3 x7 d* c! O2 o: K: Y//  Driver shell for Assignment 2.% J+ e# J' G* o/ k6 O
//********************************************************************
# X6 J, S9 H  \. N4 Z  o1 j" u6 P, h# c  C6 J( d/ [. b4 a" q
class ProgramCompareMenu
  [7 {+ Z! A! a9 R{# K, @  j  W' |
    public static void main (String[] args)/ Z: T6 G& }+ w$ p1 _
            {
4 D- q3 K, S( q1 Y: n. T; x+ ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable' h7 \* q6 F: E/ c1 L+ d! z
                ProgramCompare reached1 = new ProgramCompare();
( y2 M' Q4 i9 o7 ?2 B4 A                AuthorisedUsers reached2 = new AuthorisedUsers();        , Y# C2 [' c" @& A" p
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 D1 P, {9 j' s2 b& g1 E
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 [4 |+ x+ L% ~/ E/ b
        }) ?2 j+ V6 M9 U5 K7 p1 i, Z0 F
}// end of class ProgramCompareMenu. r2 @. C0 w, ?

- Y$ c, o0 d. }( u- Z$ ~! q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
% ]8 C0 v4 B1 Q8 M//          AuthorisedUsers.java          Provided by: DRS. |" z, y( c4 F: G7 Q7 b
//                5 ]" S5 d* Z' H
//         Program shell for Assignment 2
4 ]: Y3 p! e$ q& F$ n. K  B//
/ d8 ~1 H3 a# e//         Represents facts about an AuthorisedUser& x4 u! @0 Z, }& b5 R* j
//********************************************************************
4 w; k/ I: |" a! j% \5 i% p- d' S$ W& I+ T+ B
public class AuthorisedUsers) ?2 W( _+ t0 ]' u( k( s" D
    {
, X* w1 I: g9 s# \( I7 p$ i) K9 X% y7 ^1 q9 L
        //-----------------------------------------------------------------
. T1 r0 h  e4 ?' h8 V) p        // Constructor( e  e5 W4 i( ]5 w# T: [
        //-----------------------------------------------------------------
$ F# k- {; Q0 X. V; |+ w( j! h: C# m$ m$ u# O5 I
        public AuthorisedUsers()' R5 _# x! g: Q+ W2 ?/ B/ w- C
                {
8 F( d+ f! l7 _$ O: T' A- `                }8 X$ h) X! I6 t' O0 ^- ^
; U1 ~8 a) F$ m" L! I9 G
        //-----------------------------------------------------------------& R8 S+ @; x: ^  K- ]9 {
        // Method for testing that class has been reached& M( |* B. x7 n1 W% J" [$ k1 }
        //-----------------------------------------------------------------       
: @2 H- C2 G+ t9 m9 o- W        public boolean AuthorisedUsersReached(): B7 T. b0 P# s
                {, G* \' E" R+ ~/ o: S: T# k
                        return true;                        7 E1 U; C# E1 B8 f. e: T
                }2 ]8 T: c( O5 |' s
               
" A0 R" g5 a3 W& n# t    } // end of class AuthorisedUsers, p  r7 r9 T3 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
2 ^/ i. u  ?( t" F$ k9 HShanghai - 20077 k1 ]$ S2 ?. Q* |' M6 ?, r
Assignment 2
8 L$ z" r% O) @  ]Deadline 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)
  E" u- I/ P* }3 @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.+ D+ }9 v" M0 G6 @
The staff must be able to:9 K; D0 T5 O" L' V7 S
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.5 r2 f% f' u' W. R* L7 Q: H- R
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.
4 x" J6 t' P) @" v9 C  F3 p The interface should provide a menu so that the staff can:8 Z% t: j' g4 W9 }. W
a) Enter the names of the two Java program files to be compared* Q7 e* K% Z  Q5 r% s5 ]: d/ M. D
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
) C. z: _/ u# E$ z9 u9 I** 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).' Q: A- k" D* N6 G" e  j
BSA104 Business Programming – 2007: Assignment 27 ?. c: @( Z3 u1 K# }9 @
Page 2 of 5
& u$ r" U8 E* M- K) l7 ?2 p+ Fb) Print out to the screen all the lines of code that are the same
" [1 a  U! g3 R Include the name of the file and the line number of the code being printed for each of the two files2 o9 Y2 F' X% |
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 y1 \0 [7 n; h6 \" X the name, username and department of the user0 I) T0 Q7 N+ V5 h& P6 t
 the statistics of the comparison
2 _! o6 ^% o- _7 b+ s2 T- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ D; X1 A2 A- o! V5 E
 the recommendation for further checking
4 W5 [3 N: r; j2 ^- 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 closely2 C2 }$ z6 Z+ S# Q
 the names of the two files compared
. ], _/ I* D* v+ ^d) Leave the program (exit)
; ]: T1 S% t( h9 uThe ProgramCompare class: (Total maximum 20 marks available)
7 @+ J4 I# H! k& s) _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)
  Y0 i" P7 o4 J. ~9 B2 P& {/ @4 Ca) provide an error message if the files are not found or there is a problem opening them
$ l5 r! ~/ n' \7 bb) compare each line of code% i% H9 E# U" l/ J5 Y. q
c) print out the lines that are the same# L8 d3 ]6 r7 W; E3 h
d) count the number of lines compared / lines the same
. m  `, L" N4 q/ f# x6 ]The AuthorisedUsers class: (Total maximum 20 marks available): T9 a& x4 u! _
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)0 v8 o  J. [% q" }6 L- S
4. Provide methods to:! [9 a- H8 r+ O( j
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
- ^5 S( M" D$ H6 M4 D  N( ~. j( n& s0 Ib) return the name of the authorised user
0 P, D/ c' o# e" b5 Lc) return the name of the department of the authorised user
. R3 P8 r' I6 @  O# TIndividual Data (Maximum 20 marks available)! E! }. @8 x% K4 i' q& S5 x1 `
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.  [/ |6 X: ^2 w
Documentation (Maximum 10 marks available)
! f, U9 t2 @% O* A. b# F, ^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.3 J# }9 g* k2 ?: F
BSA104 Business Programming – 2007: Assignment 2
3 \" q7 \/ e/ O0 @- x- P& CPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# s3 }# Z2 S4 o( E7 `
不过你要翻JAVA的类库说明。你有下载没有?
( h, @* U  Q% t$ X查询关于对比的函数。貌似关键字是contrast,还有compare
/ P( _0 N* m% l* T4 {) A
/ v1 w  s( @+ T$ P6 H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# |6 B" l1 |8 \, \: J8 ^痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。# |* P( \9 ]7 Y" `. R& f
可以下载到的 是 jdk-1_X_0-doc
7 N, H3 M1 M% V1 `1 e. X) _; ]  z& N0 u5 U. U* ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 09:57

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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