找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1095|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 x" ~ w+ ^+ }; l, Y % }' }6 W) r0 V
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************/ Z9 w' y8 w0 o2 p
//  ProgramCompare.java         Provided by: DRS7 n* Q1 V, n7 d5 l& U# v) f" H
//
) r' `; ^' P: s& B# |//  Program shell for Assignment 2
! Y2 u6 l6 h/ ~8 r0 u//, P3 C4 M: q+ V4 O: P; U
//  Compares two text files line by line' d  N  h* [) C5 u' N" @# K
//*********************************************************************& q' W" H/ Q5 @$ |; h, V2 U

- B. E) V+ v0 [) U- O0 Himport java.io.*;
0 J% }4 ^$ l8 n9 V0 D7 N+ `9 Z: n1 K, _/ F
public class ProgramCompare; F" g( p9 g* x$ A  j, s4 l
{& N( \9 b7 T: L' ~3 @" i
        //-----------------------------------------------------------------3 [3 }( H* d! y0 c3 {: t
        // Constructor
; Q- Q6 [4 \' ]& e' R        //-----------------------------------------------------------------, H  |; @. H6 c& o- ~
        public ProgramCompare()7 ]* |- t, t1 _% h6 N- [" l
        {! J+ l# G; |3 [
        }( s( O7 Q7 ?3 Z5 A5 G1 s
/ t+ i9 \" E. h: D6 V6 S
        //-----------------------------------------------------------------( |0 X/ E) c/ V4 n3 }. I: T  D
        // Method for testing that class has been reached
4 V# ~5 R9 ~- `  a        //-----------------------------------------------------------------        - F2 k( B  n: u0 M

. T+ A1 `1 T7 P% x; q        public boolean ProgramCompareReached()         1 t- X, [5 x& z
        {
% y4 k2 o& K2 F8 K% Y/ w2 O      try   I6 E4 {8 B$ h  r, B: x' F+ i
   {         0 V$ E1 |$ _( r4 v, }
                       
0 e9 E& C/ }, }9 m4 x' F9 u3 H* L                //********************************************************************
( {: q0 z  X; T* `4 I                // Try-Catch Statement is used to handle exceptions - such as file not found 3 c$ s5 \# o+ f$ B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!  T0 L0 S1 S$ o
                // For more information see page 534 of the textbook( e$ D- X8 y. h+ Q9 T4 S! R
                //********************************************************************' |6 u4 W) Z/ I/ Y9 E% Z  C" d' v( `
                       t' e7 A9 {  C
        }
! G9 o: F: Q& x, U& ?6 g! ]: a) l             catch (Exception ex) // Exception caught here and message displayed to the screen
; Q4 _2 a% n: A1 P          {
9 H/ \# }! u! E6 p3 L                    ex.printStackTrace (System.err);5 X6 P1 f9 J  a- p9 L  F2 C* |# A
           System.out.println ("Error message goes here"); // Replace this error message with your own          0 ]1 l: k1 t! d" ]/ b! m) d
        }* X3 c, V/ ^% k, T
                return true;
) E+ X  |8 t: y& L% \( U( p        }
, w, y+ _/ M, j/ @% Z+ t
" z* i/ M( s; g# M} // end of class ProgramCompare
, }- F( x5 ~* z1 V- |# S$ h6 i5 j  b! K; Q% x$ q6 j- U+ z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ B* ]/ L7 R+ P# F/ W//  ProgramCompareMenu.java    Provided by: DRS
% G5 h. v8 f0 b//: V* _4 @# ?1 W4 W- e) ]4 u6 T
//  Calls AuthorisedUsers.java and ProgramCompare.java
) |+ Q; ?5 I! d; _0 M; i0 V//0 ~5 X) J+ i/ [
//  Driver shell for Assignment 2.4 z: X9 L! p0 Z4 [! l
//********************************************************************$ d; g4 K+ Y6 w4 t& r; e* q
* j: s0 a' f/ C
class ProgramCompareMenu
  m8 \% L' u2 j2 R6 q{9 [" o. s7 k3 C6 D" e
    public static void main (String[] args)% k' R) D7 M* \6 S/ X+ T: X! a
            {
0 X4 T1 q" b: f" ^8 A) }                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable. k& d' t  p# `2 ~+ M, j
                ProgramCompare reached1 = new ProgramCompare();
. ~2 z3 J! V4 R7 d7 p% G' e+ o" p                AuthorisedUsers reached2 = new AuthorisedUsers();        7 p" O& }  d  k' d; G# N- D
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) ^) ?. V9 A. [. Z/ S8 I                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        6 Z. c, W2 s# Z4 {0 F
        }9 O7 Y  [0 w: L
}// end of class ProgramCompareMenu- D+ Y3 r# f7 t2 \6 b+ l
( R6 E' X% i3 X0 Q4 h
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" I: d1 i6 n4 e. d
//          AuthorisedUsers.java          Provided by: DRS
  c5 w0 B9 G/ l: Y//                ) Q+ [* r: W) Q0 C  V; a
//         Program shell for Assignment 2) v/ O/ _) N- n2 H6 J
//
/ Z" ?+ ]! H, g: {: @% k//         Represents facts about an AuthorisedUser2 N3 c9 ~- U; m$ L9 v2 Q7 Z4 `, h3 R9 Q
//********************************************************************* c* @* r/ p" b. }3 @. H
8 d% E7 o( g& D' k, m& w
public class AuthorisedUsers+ j  v3 Y2 q+ A6 C' F
    {
$ j8 M& }: }5 a4 a+ @% c5 W, _5 U# M, Y; v
        //-----------------------------------------------------------------
% ~0 }$ j* o5 D& `4 b0 f        // Constructor3 `4 D5 X, O* {  k2 g( q
        //-----------------------------------------------------------------
7 X+ s  Z% Q7 \9 y+ x0 K- j( C4 B2 A+ w% x
        public AuthorisedUsers()
7 \9 o! k6 H: T- r, q                {
/ f" N* N( U2 I4 _                }' i: H, G0 u- e4 P. k

) W4 h5 ^( Y& f* A        //-----------------------------------------------------------------
9 `  ^! `5 r* C" y+ R3 p        // Method for testing that class has been reached
0 F( N1 F: O; m$ w; K( }: B  K. Z        //-----------------------------------------------------------------       
' C) G( p. q/ E( d        public boolean AuthorisedUsersReached()# m7 z& V1 i- i" D4 A- M) l
                {9 {8 n% f5 Q$ ]' X5 f. {- A
                        return true;                       
9 k$ ], e& U& G1 f+ m7 s                }
; t! S7 z, R4 d# {                # f) R1 @/ k0 Y3 I$ ^, A+ ~2 D4 v
    } // end of class AuthorisedUsers
6 k( k" ^* N3 A0 v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 h  d* V% L7 VShanghai - 2007
# p+ X4 _' Z& `1 @1 S+ p+ @Assignment 2
# e6 m6 E$ Q8 a( h0 b6 kDeadline 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)- H& M' E& N' ?' g$ @, ^- 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.
* l- q: {( o% U0 j1 `; c  FThe staff must be able to:+ l3 N' c2 S3 [! B5 H: x) r8 k
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 t2 q5 x, {2 k. D# D
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.+ ?8 j" P: r- m8 A* g
 The interface should provide a menu so that the staff can:
9 N8 P; n" h7 u. |+ S- ?* S) La) Enter the names of the two Java program files to be compared, I9 M) D3 E+ W
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 V$ A0 y  R- ]4 U; w8 A9 y% q9 \** 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).
4 Q+ R6 ^$ t0 x. p; ABSA104 Business Programming – 2007: Assignment 2
2 f7 ~8 }8 V+ H% [/ fPage 2 of 5
2 _6 {: e& F) k$ |b) Print out to the screen all the lines of code that are the same  v, [5 i! a" z* ?
 Include the name of the file and the line number of the code being printed for each of the two files
, Z, G9 y9 n/ M8 `6 l9 s6 O; yc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 C/ j  a# n* P) j8 a7 P
 the name, username and department of the user) N4 ~! P! o6 X) d# u( s
 the statistics of the comparison
. l& @2 \$ f$ Q7 ~; y% q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ d, p) Q' h0 e  @! m9 H& ]
 the recommendation for further checking/ r+ v2 x/ A4 B" j! E# j, F
- 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 M1 D( j6 l
 the names of the two files compared! g7 o) x, E4 q; i
d) Leave the program (exit)
9 i$ v7 c+ v/ D, j. rThe ProgramCompare class: (Total maximum 20 marks available)8 f6 b! X8 H- m: n3 e
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)
+ X2 T/ n# H  r: xa) provide an error message if the files are not found or there is a problem opening them3 x+ G; b! }2 h7 _9 x
b) compare each line of code4 y, |( r9 @1 |: v; k9 M- d- o
c) print out the lines that are the same+ h( Q" u3 k. w1 Q& A' t$ J
d) count the number of lines compared / lines the same* J4 M: p6 `/ m8 f% h* t
The AuthorisedUsers class: (Total maximum 20 marks available)
* F+ D7 X3 E% X" Y, Z8 k7 c1 r# 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). K: H" Y$ v$ o" ?) g1 N
4. Provide methods to:" q% O" S! Y' H* m
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 match4 H2 T" G. k+ h" C
b) return the name of the authorised user0 U. j4 d0 G, I; R# }
c) return the name of the department of the authorised user
; M% x" o3 b, `3 i) t2 EIndividual Data (Maximum 20 marks available)# P. U) j6 o3 a2 T* f: y/ g5 _
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.
* K* w# m- Z  f! A# yDocumentation (Maximum 10 marks available)$ ^1 y% b' w: c. |6 c: U, ?
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.
! B! V4 ]" P% O  e* Q: VBSA104 Business Programming – 2007: Assignment 2
3 M, H( U% G0 o4 rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 o' U4 C0 D' A+ q) C6 |' l2 |不过你要翻JAVA的类库说明。你有下载没有?
: `2 T7 x$ P8 G) ]& `查询关于对比的函数。貌似关键字是contrast,还有compare* r" g8 D6 P0 s4 g

" ?/ _( U  G, c/ s# H4 u! _8 l3 `% D[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 [/ i# l5 M- C3 @& E8 ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) I% V" P5 J6 w0 q4 \1 Y2 @! G. z' R5 x
可以下载到的 是 jdk-1_X_0-doc
. c! q! K( j6 M5 @# Y' B. f: {- C* X' y. W
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-5 10:30

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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