找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1719|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 j9 u' b3 K: m `- W4 S 0 K' Z! ]% {, d4 o2 o, 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 a7 @0 U1 p6 D- g) k4 @
//  ProgramCompare.java         Provided by: DRS
( x7 c7 W5 j* g8 N1 [//) e  l/ b: M9 d3 g
//  Program shell for Assignment 2. K( ~8 o: p& _/ Z& k- C7 x2 @
//
7 X: r/ u5 l% e' ~) @% o//  Compares two text files line by line
2 U: H9 k( O' Y& X) o//*********************************************************************
. l/ c# Z; g, |: O6 P- x
( N' X; r8 e* ]" U, P5 Simport java.io.*;
( @& |0 }9 k) P( a" Q: r. U2 t4 y1 l& d
public class ProgramCompare* s' Y6 ^* g% I' x
{5 s5 \; P5 Q# |4 r
        //-----------------------------------------------------------------
$ P# ]& i1 F& ~1 d; {        // Constructor& a1 y" K& v) r* e6 Y/ h
        //-----------------------------------------------------------------
8 F+ M$ [$ G' ^/ B) `) P8 Q        public ProgramCompare()
( I0 c$ o6 E9 T4 `! r5 o) g, i        {  ~: N) p/ `2 A+ F/ @
        }
. ]0 v4 S' S; r* F, }" F
& P* @: ~1 _( ~6 w* X5 q  O        //-----------------------------------------------------------------
& M- @0 l' \4 O1 E+ M" l0 ?$ C        // Method for testing that class has been reached6 s: w3 G; L: x" P9 @  d, ~
        //-----------------------------------------------------------------        . c$ `; v8 _6 I/ Q& ^- U6 [* S

' t9 k! e; c6 e3 t4 v+ M3 U        public boolean ProgramCompareReached()        
; I: n7 n1 s; S, ^" \* P9 {5 y        {
2 F) k) A2 p) v( y: c      try 7 H6 _) a" I6 f( C- b$ x4 L
   {        
1 A8 N% F. Q- t                       
, `5 I( K9 Z& L2 _                //********************************************************************
+ ^% G+ k+ s. u; {, }5 y9 a                // Try-Catch Statement is used to handle exceptions - such as file not found
/ @% q  {& a8 I5 z2 W. C                // Reading the files will need to be placed inside a Try-Catch - just like this one!
5 {; ^- }: S% J3 T                // For more information see page 534 of the textbook
& f6 \' S- F. k                //********************************************************************8 j# ?- p1 ~0 D: n8 L6 c) m
                     ) D( D4 Q. P' {3 l8 m
        }
% f6 z' r4 _7 T% b5 N" d' m             catch (Exception ex) // Exception caught here and message displayed to the screen 9 ~# _" F2 s% K% @
          {8 C" Z# M; [& }) d4 E* ]
                    ex.printStackTrace (System.err);
/ U0 C1 S6 F2 P# H9 O9 J  n  x           System.out.println ("Error message goes here"); // Replace this error message with your own          # ]' c' ^' q0 v( ^+ @. C
        }
3 K6 m% T2 n, t* G7 y  r6 O                return true;# i6 |) V4 V8 M; j1 J4 g, E
        }  h+ p* n2 E: z# ]3 K0 p5 S

8 l. N: {- {( v& ?5 A( p} // end of class ProgramCompare" C) m0 z8 r3 f

4 t! C1 P! y$ t' s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" [- m( t* G, {& R% B* Q' c
//  ProgramCompareMenu.java    Provided by: DRS# R3 g" }+ B3 [* n
//
! C: H1 Z- w- y' `1 c6 Z//  Calls AuthorisedUsers.java and ProgramCompare.java
8 S, T5 u% I9 _5 p1 O+ ]6 D/ K//
: K9 @/ ~0 c" f//  Driver shell for Assignment 2.
+ \0 L  _* O" q3 V' P1 F8 y  A- @% u//********************************************************************
- L. t# ^. I1 I) `8 C1 c( O( x# E8 C8 w7 Y, w) W+ u
class ProgramCompareMenu
" a1 X  A. g* F1 f& K0 _7 F4 ^( e$ k{; o* d/ h$ f' T3 K/ u9 y
    public static void main (String[] args), \  m$ H4 ?4 h9 A* M8 L$ ~
            {; Q& E: p7 f* R4 S1 t: v( S$ h7 c
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 O/ d9 x. d* B+ w" s6 H
                ProgramCompare reached1 = new ProgramCompare();
3 |8 q6 l3 @5 R% Q1 |9 g% I+ R3 [$ X                AuthorisedUsers reached2 = new AuthorisedUsers();       
& R+ p( a* `8 q  _5 v                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 g3 z3 q% _& l+ B4 L
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
* D& I8 M4 j. i  Y) m* r) J* Y4 }9 d        }
( Z4 Q- `+ y" w}// end of class ProgramCompareMenu' u% H1 l* C! l  D- s
' O8 ?0 c; D+ V3 Z3 o1 S
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************1 o& u7 A0 x2 C! G1 Y& p
//          AuthorisedUsers.java          Provided by: DRS4 @' J! \3 c6 P) }/ N
//               
! _/ e# |' Z2 ?3 `! [//         Program shell for Assignment 2
1 `3 t, ^( P+ `//" t  N3 J( P" y  ]& L) H# d: N
//         Represents facts about an AuthorisedUser
$ V% q) B7 N: W4 f; s& {//********************************************************************
( ~, C$ {% y: h# @5 R" Y# \$ q7 R
+ T! j- d. w" R) I# i9 A  xpublic class AuthorisedUsers
* c* v" V% E3 S0 d    {
1 t$ v; P/ L& H5 r1 z3 R! B
/ ]( v  _* V3 M7 O        //-----------------------------------------------------------------
! ]* k" e% e1 l3 E8 _5 K        // Constructor  h: M8 V9 V: V% z  ?9 q
        //-----------------------------------------------------------------, m4 l# N4 _" k: V" m( }
7 b) B' M; ]# A% g0 z9 `' {; ~9 c! i
        public AuthorisedUsers()
0 ]$ t, X% y' b                {& J8 t! l8 O/ j* w  d( {3 B
                }
& r0 s7 p2 Q3 Y- W1 W1 }4 N: R* \5 p7 g0 {0 k  y7 q/ Q& W2 S* b+ ^
        //-----------------------------------------------------------------& ]* c) p, E/ O2 M1 q, D
        // Method for testing that class has been reached
# M1 K3 u. N5 l        //-----------------------------------------------------------------       
: p) j& Z: Y: [        public boolean AuthorisedUsersReached()
  l% m, C+ s$ u: u# V                {5 h+ E# w( C! Z" r: A
                        return true;                        7 b) O! z/ ]- E, I
                }
3 }% v5 T6 a7 o$ b                ! E" m# B% n& t. [
    } // end of class AuthorisedUsers
, [5 [4 D" w" s! L/ K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# Z- V) A4 M  k8 v
Shanghai - 2007- c, l7 a0 R9 x& u5 b
Assignment 2; [9 W$ Y' |1 P+ [1 Y5 k0 @
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)
% {( h" R5 g' _9 W7 F6 L1. 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.
8 z: E4 k/ Y0 l7 s$ G  h* n4 `% FThe staff must be able to:
6 O! V$ n8 p7 H8 x: V Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
) q. Z0 p, k& W: r( u1. 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.
+ O: ]9 ^+ M9 {6 [' v The interface should provide a menu so that the staff can:3 \% u) D# u5 _5 _
a) Enter the names of the two Java program files to be compared' F8 e) G' a' s& m3 U
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# Z2 {: m! R$ x' [+ ]: |** 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).$ u4 s( X6 S: |8 j3 F! _" b
BSA104 Business Programming – 2007: Assignment 2
8 [7 e! k" i. k& d& \Page 2 of 5
* F* ^! J9 J+ _. H/ c6 T0 t. J  \b) Print out to the screen all the lines of code that are the same
9 O/ m- r6 a4 d1 g Include the name of the file and the line number of the code being printed for each of the two files
3 z4 U; y! k4 U- F! ^c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 s: Q' u3 j+ |/ ?) ]. @
 the name, username and department of the user
5 U# j) i. {# {2 U: _ the statistics of the comparison
; v( \2 P. T2 O- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 H$ a2 R% n/ Q' |  D; u" I, V
 the recommendation for further checking- T  Q; U% B/ S7 j9 U: }! W) 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 closely4 i3 F- \* y/ P! q4 i. l4 \# E* m& E
 the names of the two files compared, T2 h+ H$ w5 i8 e
d) Leave the program (exit)
3 |- J& i" M  M9 _' FThe ProgramCompare class: (Total maximum 20 marks available)% `7 j+ a' L' F+ x
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); `. O$ z& L8 i9 k. w. G6 d; a: ?
a) provide an error message if the files are not found or there is a problem opening them0 f' l8 Q9 j/ v, o) }) t
b) compare each line of code
$ e" [8 @% l; v) q, qc) print out the lines that are the same2 f2 y# I$ H+ r+ ]
d) count the number of lines compared / lines the same  p: @; B, S5 e5 i% |; X1 D$ M9 d
The AuthorisedUsers class: (Total maximum 20 marks available)7 b, z3 M' J4 C5 A& f+ I0 X6 Q
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): f2 l  z& t; \
4. Provide methods to:  [4 p8 S' v, Z+ s+ d( p) J  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 match3 S1 \1 H8 D1 J
b) return the name of the authorised user4 ^4 p$ @' |2 @) C: B) \4 n
c) return the name of the department of the authorised user1 L. X. ^! I# L  A/ E
Individual Data (Maximum 20 marks available)
2 K  b- A, \8 \$ S( E) }. Y# V. o5. 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.5 z# i# ^. L! n  b! u* k4 d( c
Documentation (Maximum 10 marks available)
. F* L0 L) b, P4 `  e6. 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." w: ~! a5 X" o
BSA104 Business Programming – 2007: Assignment 2
1 [" ^2 F5 Q- q1 m0 D7 tPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ v7 Q% i! J6 I* k- W不过你要翻JAVA的类库说明。你有下载没有?9 s! A: h, _' V/ Q) S0 Q
查询关于对比的函数。貌似关键字是contrast,还有compare) H6 y' Q: H" w# H6 l+ _

0 C# e  w- t8 a2 d" M: |[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) u0 |/ N! m5 K0 Q4 K" y痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ U( Q/ P6 r  ?& }2 l可以下载到的 是 jdk-1_X_0-doc  t! ?$ u- r; S

7 q8 _) T8 X5 s. B, Z% |2 `6 o[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-11 12:08

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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