找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1760|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 K; d% f/ B g% i & K: N6 l+ E7 ?* C2 S5 z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
6 o3 V  ~- b/ [5 j+ h1 s( {//  ProgramCompare.java         Provided by: DRS
8 d# w& ^$ w' l) z//
+ q; u) l* T" e7 }* x//  Program shell for Assignment 2) ~& l, E& S! Q' T+ S2 d. L
//
: h; b! I$ z, D( U5 E//  Compares two text files line by line
# s3 v, d. w' U. }5 J//*********************************************************************
3 }' o0 j6 s& E  O# i7 R# }
, d/ K3 p6 z5 R; p8 K3 Bimport java.io.*;& K2 d6 r/ M. R# p6 J

8 H/ s& h* S* I" U9 }# [public class ProgramCompare$ l3 B+ I5 e+ R( V, P
{. ?) L% ]0 s! j- W+ i
        //-----------------------------------------------------------------
) R7 L  }; F! z) Y$ @  B        // Constructor+ }/ y( c% M/ \2 p
        //-----------------------------------------------------------------" N! L' J$ x& {8 H
        public ProgramCompare()
0 u* M  W* V/ y: V! d9 T# P$ N        {
+ N; G& y: w4 R* Z) f  d        }$ `) Z  |7 V! @! l1 R: |( s
) w% G( j2 `* O$ g4 Z% T' Z0 w
        //-----------------------------------------------------------------) C2 p. v2 f. Q
        // Method for testing that class has been reached
# C+ q2 U7 [6 y3 ^% q& [4 y4 P        //-----------------------------------------------------------------        0 J2 f4 X6 m, q9 g

9 H( l5 e* Z: Z! R: T* |        public boolean ProgramCompareReached()         ) u8 }, U' h, N# p* H2 R  `) g7 z
        {3 ?3 b$ F* m" h$ a
      try / b9 N+ \1 h3 a# h
   {        
# g8 K3 r) Y7 L* ]# ~* y! z                        0 b! I7 o$ o9 P; t' H
                //********************************************************************% C  Z  f* k# d( m/ i/ ~& @* W
                // Try-Catch Statement is used to handle exceptions - such as file not found
, ~+ B+ @4 [/ |/ r- b% O9 D                // Reading the files will need to be placed inside a Try-Catch - just like this one!# a" q3 C( C2 q. B4 o
                // For more information see page 534 of the textbook
4 l/ ]: U2 i1 @. c                //********************************************************************2 S& R( x( h  D' m
                     : D% b7 `' y$ O) s
        }- ]# o/ A6 _4 A; Q# [: N
             catch (Exception ex) // Exception caught here and message displayed to the screen ' h; ?7 k. @# i7 L' g3 m5 R
          {+ e+ P0 U9 J/ {; j
                    ex.printStackTrace (System.err);# N! I! `8 {" L- T
           System.out.println ("Error message goes here"); // Replace this error message with your own          / G# J! C. C1 O# h( Q
        }
# F% A/ n' Z0 c: {                return true;( o9 J! F4 h' w0 ]/ K# [$ n
        }
, l: O- E- S  |  v+ F! @/ V4 I& @7 D) V1 N
} // end of class ProgramCompare  T6 s$ s+ O6 O4 c+ K/ U# v7 ?6 x1 M
8 l$ O2 ?" u6 C, p( c  O4 b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 h) j; j5 z# w/ N1 `//  ProgramCompareMenu.java    Provided by: DRS1 S  i6 E4 U' k9 L  ^6 m: r( l( E
//& N( o! ]; T3 J7 Y1 `5 w: p- g7 ^
//  Calls AuthorisedUsers.java and ProgramCompare.java
2 V7 A9 H; W! R+ g0 I2 N//
( B. |, p, h7 H- V//  Driver shell for Assignment 2.
) H& ]4 K# W% y' k( u//********************************************************************
% }' z6 \4 E; y
6 a2 B' R6 b1 a& n- Lclass ProgramCompareMenu$ ?! i3 ~8 s+ Y- Z5 T8 W; P8 W% ]
{3 Z& a: M: X, s: V$ a- h6 Y1 n' o
    public static void main (String[] args)
! T3 }' ~$ S2 I/ t' T  k            {  y1 Y9 A- k3 E3 g
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
$ _5 b( \3 z/ g) E" A) z+ i                ProgramCompare reached1 = new ProgramCompare();
5 D! [' n, O0 p$ v                AuthorisedUsers reached2 = new AuthorisedUsers();        , O7 Q  y, `9 h$ e
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
' H: w; J6 [/ G/ M                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ ?0 X+ w+ ^2 G( \3 _
        }1 b( {( I$ t+ r
}// end of class ProgramCompareMenu
7 A6 ?# i( _) a$ X) B. a' ?( ]+ [! }. k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  E% o5 Z2 L* ?( c! I2 n4 A//          AuthorisedUsers.java          Provided by: DRS
' d1 W* @5 t2 y& k5 q2 X//                8 j/ F& L& u$ \+ Z0 f
//         Program shell for Assignment 2$ d1 |' t+ |+ `1 Q9 `. l
//
+ R& m: ?- o: C- X% G//         Represents facts about an AuthorisedUser
% j, R; p& s5 v1 c7 [' }6 A& X1 {; q//********************************************************************$ p# B7 N/ Y& `9 n

; w- k/ U  n5 R# w7 ypublic class AuthorisedUsers3 a$ D% Z5 {% N7 p
    {1 F, B7 Q) [, E+ v* x

) B2 K% k0 D' o* G/ R8 D        //-----------------------------------------------------------------* Q: E4 M6 z6 Y* ~' ?: z! O( v- d$ R
        // Constructor
3 s0 I8 j/ h3 S! p/ Y0 H5 f) w: g        //-----------------------------------------------------------------
  v2 _- ?' X) j- v3 s- m; x  x$ P' a; X8 u
        public AuthorisedUsers()
0 |9 _0 d4 F8 q5 {4 |4 I$ {' q                {
( |9 W5 ], M6 I0 k# ]* P                }; F8 a* z9 n# a% ~' l) I
& D% J/ j2 ?/ U6 M7 ?5 V
        //-----------------------------------------------------------------. R5 C( f& f2 g( U
        // Method for testing that class has been reached: q, d9 v$ e8 Y& }8 |, g1 G
        //-----------------------------------------------------------------        1 H" s$ z2 C8 N
        public boolean AuthorisedUsersReached()$ j. O) Q5 I, {/ b8 f4 Y% h
                {
5 y7 W5 r0 v- A  c4 O% [: @                        return true;                       
7 e: ~5 ^- v6 Q# n                }4 f. _) A% M" c2 T
                7 R1 }$ M7 {! b% l
    } // end of class AuthorisedUsers( j7 j; P2 T0 {& t  S0 |/ d" c
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( m# h5 i3 S+ V- I) A$ ?. XShanghai - 2007* s% C+ x, V9 \% D! |# D
Assignment 2
. m; `* Z6 x' N1 }) MDeadline 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)4 Z5 ^$ j/ P3 t3 I  G
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.$ @4 u9 T8 I1 M+ p+ T
The staff must be able to:
) b2 r) d6 X/ q+ i0 { Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% C: C# C) ^1 I3 o8 _+ N0 C* P4 n/ T
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.
. O9 y- h4 a8 r) `5 ?/ k# x The interface should provide a menu so that the staff can:" }. T  o, j: T8 x3 S
a) Enter the names of the two Java program files to be compared/ Q% }/ |: N3 U1 G: P! P4 l
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
; Q" d) a# h8 s4 }** 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).
/ i& w$ t2 |5 m$ `6 |& D8 D3 i9 EBSA104 Business Programming – 2007: Assignment 20 o- o4 q( e; `- A) ~' Y
Page 2 of 5
1 s0 t+ h  L- M- T: f% U, zb) Print out to the screen all the lines of code that are the same
0 i# t5 R$ v+ Q- A. { Include the name of the file and the line number of the code being printed for each of the two files
, D) V* a  V% u! R4 Ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 ?7 z! {) A% y; H1 [" U" a6 g# z
 the name, username and department of the user- r5 z! R! t9 n& X# f
 the statistics of the comparison" T/ ?) ?" L: m% ], t# a4 r, q( w
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 M5 c( `2 G" |, }( f4 l- v8 j/ }
 the recommendation for further checking
7 A# C% k" ]" R" Z; q, Z* h# \- 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$ ?) f! }; d" Z% r
 the names of the two files compared
# f, @5 _* W4 U) d" H1 n  g! od) Leave the program (exit)# ~! G; e4 L: k1 z) \
The ProgramCompare class: (Total maximum 20 marks available)3 }- R) k* i8 Y8 S+ 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)( A7 o: a' M% k2 y
a) provide an error message if the files are not found or there is a problem opening them
4 I+ g& R0 v- k' {- f. Qb) compare each line of code* r" \9 ?  }( m9 t* T' f5 b: m
c) print out the lines that are the same
3 u+ o- R' X1 E" i2 g. m/ Q2 ]d) count the number of lines compared / lines the same) W8 T1 M) r$ r8 R1 a: c. e
The AuthorisedUsers class: (Total maximum 20 marks available)5 t1 }, c  _& G! |  }5 v
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); v1 w. c. ?$ S- A8 K! {( H/ ?
4. Provide methods to:
/ u, u8 N, c: I+ D7 _% q1 Ja) 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" j3 \, N! v% f/ F$ u; b3 F, r2 D
b) return the name of the authorised user9 _& B& ]: g, i1 w5 G. M4 ^, [
c) return the name of the department of the authorised user
) H" P5 ]6 D. ~4 XIndividual Data (Maximum 20 marks available)! p5 R* o: V: f1 `
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.$ l( C4 u: w3 g' [. g
Documentation (Maximum 10 marks available); S1 {( D: c$ n# z8 t
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.
* ^& E4 [% I+ [: g0 EBSA104 Business Programming – 2007: Assignment 2
) f6 H9 f9 Z1 A. I0 T3 |, `! tPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了% L& s* k1 R1 X' A2 q
不过你要翻JAVA的类库说明。你有下载没有?
* P) J+ e$ C$ p+ u6 @查询关于对比的函数。貌似关键字是contrast,还有compare+ f) G0 @6 f% h- q

- o- h! j1 B8 K7 b, X[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 G! A1 g- R2 `7 ~& u% L
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 E( v0 o" ~) `- L; f! T0 Z# m# @6 ^- d
可以下载到的 是 jdk-1_X_0-doc
4 Q) A6 |' k4 e4 A+ }  n+ D) o1 R/ @( R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-25 08:01

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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