找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1068|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 ]! p: |- T- X5 E & q3 f9 ~, ^ T& ` G
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************+ ]. Q* t7 b+ c# H& _3 k" `
//  ProgramCompare.java         Provided by: DRS
& _8 b1 l# O0 C3 R- d//
0 p- p7 N  J2 W1 ]//  Program shell for Assignment 23 V$ S0 ], k: E: C. `9 v
//& K8 J  _  \" ]# H, i6 F. J0 p
//  Compares two text files line by line
. p7 `& s4 D& `. s1 l//*********************************************************************# Q4 h  L. @7 l9 W1 _3 B+ e

5 L: ^/ j( q  y* ^, pimport java.io.*;6 c  I& K; |' F

, _; {( y0 Y3 tpublic class ProgramCompare
! R+ J" w/ N+ j9 T1 K7 G4 Y7 U{( S+ l- ?. m/ {) }
        //-----------------------------------------------------------------2 e, j% i0 ?+ t! O. m8 H) s4 U2 ^3 I. }) _
        // Constructor$ g$ D/ e0 @  r( W; ^
        //-----------------------------------------------------------------: r* f+ I# l% v7 l9 @4 v
        public ProgramCompare()
4 p/ N3 I  Z8 ^) P" {8 b        {" P2 w' D# V2 R; ]& K
        }
/ _! W% i. Z* q5 ^4 \; ^5 A7 f# n7 e- I0 y# M( _9 {; s
        //-----------------------------------------------------------------/ G% L2 E& D: z! P9 y/ I' d) c7 U
        // Method for testing that class has been reached
0 i  B, W+ [( [        //-----------------------------------------------------------------        ( c. l( h; Q( T' k* P

! {2 m: |; o7 H+ y. e7 J        public boolean ProgramCompareReached()         1 K+ Q) |0 Q& _( e1 I  A1 |7 l
        {
8 T6 o5 R9 W: G. h3 @/ T& [4 [3 ^      try
5 }0 X" l0 m- q1 E5 q& B   {        
& J$ f% ]& S$ j$ k/ ~                       
- S2 ]6 k0 Q# O- t* h                //********************************************************************
0 p3 |% r9 M4 Y% P, \                // Try-Catch Statement is used to handle exceptions - such as file not found
* E5 `" R7 q1 m3 F* N! Q                // Reading the files will need to be placed inside a Try-Catch - just like this one!
2 ^) Y4 M* E- B% E$ X& w                // For more information see page 534 of the textbook4 p- r- X: \7 D' f) ]
                //********************************************************************
/ I# r$ p% m; d0 x3 Z9 Z                     9 V5 D* R2 }' s4 f: E9 w0 O
        }0 J/ f  [9 Z  D& j" `
             catch (Exception ex) // Exception caught here and message displayed to the screen
: \7 Q* P8 K. l" e  C3 \          {; Y  R% @4 |, Z2 @0 x
                    ex.printStackTrace (System.err);
! _  P! |- `+ \% f           System.out.println ("Error message goes here"); // Replace this error message with your own          7 n# |, y7 O8 R/ m% }: Y  `7 y% q
        }
, I( f/ q0 `9 }9 m, _5 I& a" ~' o9 n                return true;
  M& J' L: o4 g, d2 s; |! S        }0 p; p" \5 N3 {

9 _( Y# u# j+ k4 Q% V1 f7 Z} // end of class ProgramCompare
& V1 W4 ~  c0 {3 Z6 `. l9 p
; o/ V8 E0 X# Q  W6 P+ }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( A9 @( {+ N4 L& I5 S# r//  ProgramCompareMenu.java    Provided by: DRS3 S8 E0 [$ l% P8 P) V9 C
//
) p! k4 N9 F* Y, Z//  Calls AuthorisedUsers.java and ProgramCompare.java! Y5 V" ~3 ~$ X/ ?7 c( C) {! T
//
. S# F) G0 |1 `# J. N+ k$ N//  Driver shell for Assignment 2.) J7 c7 P* l% A, R3 C6 z
//********************************************************************
# p! U5 z# e5 z- c& \- e" {" v# m* l6 d3 p0 s! f# r& T' D2 @# @# m
class ProgramCompareMenu' D4 a6 R  y2 o# J4 [
{% l) h) _8 t  ]3 [
    public static void main (String[] args)! _" d, s0 @" d
            {
% ?( n" v: E5 f- B9 D% W, }                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 r7 Y- Y# P0 {
                ProgramCompare reached1 = new ProgramCompare(); ( [8 D3 s1 P8 b2 i
                AuthorisedUsers reached2 = new AuthorisedUsers();        1 _: o7 Z0 ~& C; j$ ~
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. D7 W' ]  R. t6 d
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
+ T7 X/ r) I8 G/ T% N        }
% V; y" X: |0 T5 P+ Y! c$ r; F}// end of class ProgramCompareMenu
) O- z. H( e3 B* T2 l- ?, g% Q" b4 p3 E8 b$ D; H0 x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
0 b. M1 z8 Q3 z. Z, E2 h4 o* m//          AuthorisedUsers.java          Provided by: DRS  G0 P: @9 b; ]4 |
//                ! I3 a$ D3 O8 b; c5 A9 b- }9 Q
//         Program shell for Assignment 2  r+ Z3 r, j: l1 u% b% T& L! ?
//
( o( \# O% F$ i! M$ R7 b9 {! b//         Represents facts about an AuthorisedUser
9 X/ n* _% D( x. `" v//********************************************************************2 w% x) N5 P* W7 G, V3 K8 h* Q

: F* V3 d/ E( q: f( D$ x  Ppublic class AuthorisedUsers0 F0 u( e5 A$ }  r$ `% H: i* c% `- V
    {* Q5 X2 F# ?1 Y

" o, K7 ^" H4 R* w; e  i' @        //-----------------------------------------------------------------5 m0 x6 N! Z8 {% P" o9 r
        // Constructor
& ?, \8 T: Y2 }0 J$ C, Z2 Y        //-----------------------------------------------------------------  W& t& ^4 d& P4 z$ M6 X+ _

, I% ]+ n3 N  a6 T) L( U        public AuthorisedUsers()
( P: C8 r3 [/ e' K+ ^                {# C7 `) C9 b, J8 {1 |, w
                }7 t( T7 {  @8 G4 E3 w$ R, A
4 ]4 L. a3 H3 B. C9 h& E% Y  N
        //-----------------------------------------------------------------  V" g: Y  N2 n5 b  r, ~& c
        // Method for testing that class has been reached5 N5 B( C3 Q" j( p8 _( ?
        //-----------------------------------------------------------------       
: P: Q! R" ^( N& ]0 j$ @8 g        public boolean AuthorisedUsersReached()- x6 e( ]. [- E5 A
                {
$ Z% ~$ T3 G, g: l7 j                        return true;                        ! u2 C2 z2 D" y* b2 e0 v
                }8 Y# Z, l' b$ k8 f3 t
                4 T  i* Q  m0 z: W4 W
    } // end of class AuthorisedUsers
8 g* [% U! B2 I  [2 F0 L6 }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  O# Z9 y9 _+ c! E
Shanghai - 2007. _" V( |# `$ U2 G
Assignment 2* W6 x" ?- W' r3 z
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)
9 X9 k! ]  V" R. s1. 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.% |2 U* b$ B3 _  M: P! V* c- B
The staff must be able to:
* x% ~/ t/ K& u9 g8 a- V; y2 u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.1 l2 k5 O* m3 V
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./ S# E' ^$ V  |+ Y* ]
 The interface should provide a menu so that the staff can:$ P! C: A# k- S" @* U& ?' f
a) Enter the names of the two Java program files to be compared
1 k1 `, O# X6 s; P! d% A) v For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- G& H/ _3 K6 V( y: [** 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).
$ W3 Y' x% N" D, N3 }BSA104 Business Programming – 2007: Assignment 2
$ d4 C: g3 @7 YPage 2 of 56 a6 [6 Q! \, ^$ z' T3 x
b) Print out to the screen all the lines of code that are the same- ^; m3 W; k) a/ ?
 Include the name of the file and the line number of the code being printed for each of the two files1 O0 i! D9 Q+ M- x6 [/ s8 b/ b
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" E2 ^' _+ g6 u  |; Z$ {: J4 S7 ^
 the name, username and department of the user
& T$ J5 T5 B0 a: h  r1 a the statistics of the comparison# H% E- L! K) V$ J! p
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! i+ y0 H8 [- O9 s+ a( Y  z; Q/ y8 A
 the recommendation for further checking
8 F/ o5 L) m9 O3 l! L. K- _8 b( K- 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
: s! ?: E1 |! K6 A the names of the two files compared* E, }6 x/ I& x' O( m
d) Leave the program (exit)
+ {; p. f% }  S4 T) V# iThe ProgramCompare class: (Total maximum 20 marks available)% o( i& C7 d3 I6 w. p; T, B
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)
# Z8 L; i7 E* P0 s" l& q0 va) provide an error message if the files are not found or there is a problem opening them- o' j% {9 ^' E, u/ z7 G) F
b) compare each line of code- j/ Q7 i" q8 W4 _: x
c) print out the lines that are the same" e! o1 H* z* [4 L8 k" F
d) count the number of lines compared / lines the same
$ |0 c" @9 e, u  C" i2 t% A6 rThe AuthorisedUsers class: (Total maximum 20 marks available)
5 w: [, @. W9 `' }0 ^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)
8 F& D$ \6 |- A5 P* ?4 X4 z4. Provide methods to:' d: [% Y& y$ j; l& m# s+ l
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 match7 {  u" [  [, N2 q$ p' o, p# O4 P
b) return the name of the authorised user8 k, @0 O8 k+ P& _: N" _& }
c) return the name of the department of the authorised user
) @  J( X8 ^$ W: M" G6 P. E, kIndividual Data (Maximum 20 marks available)" K- `/ {" E) Y* t. Z
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 [1 R( K: @6 FDocumentation (Maximum 10 marks available)) C5 ~" ]7 O& X$ v, c7 M
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." N+ R$ f9 |( c: M$ a0 b
BSA104 Business Programming – 2007: Assignment 2; [4 O' m# Q7 W" A* }2 q" I6 q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- j) W7 J# r) {" z  g不过你要翻JAVA的类库说明。你有下载没有?
- z3 L% _% O  @查询关于对比的函数。貌似关键字是contrast,还有compare1 G; c' T( t, G9 U0 [

# W7 y$ z. K0 Q7 `4 |* h/ e[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, {" z' q7 `5 k: e$ ]! n( _  ?痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。- s+ R5 E  T4 x  e7 U) W
可以下载到的 是 jdk-1_X_0-doc
4 Y2 l' p& D1 H1 S; Z4 R& J5 s6 k9 L8 a8 {. F0 }! B# t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-20 06:22

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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