找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1462|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 X- m4 m1 l' d' E& n6 m" ^ j9 O4 w5 j7 T
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************+ T" ?' |& _9 [. v- `& W+ T" b
//  ProgramCompare.java         Provided by: DRS
& G8 \% x, v- l' F- F& b//8 L. R) {. ~! x/ J% |; r+ z
//  Program shell for Assignment 2% ?+ @& Z0 ?/ h& [5 {' |1 _
//5 m9 {) }7 J2 G: T" {! [0 [
//  Compares two text files line by line
, W5 Y4 H6 ]7 |& Q. q//*********************************************************************! @6 X0 f/ w  l7 {% b

) Q: e) t0 u7 M+ M& j' \  l5 nimport java.io.*;" g: l$ w3 ]+ b  U! K

: e. T3 n& L( Npublic class ProgramCompare
6 |$ ?4 S: o7 y{, ]% k; Z  A  S, i
        //-----------------------------------------------------------------0 |( Y& f% @6 y* _( q# |# X0 F: ^
        // Constructor& Y& j0 G2 z* [9 t- M' H) n- f
        //-----------------------------------------------------------------
" D7 f  x7 Z8 [7 u# |, ?/ x        public ProgramCompare()
' k( O. g* I9 I% r6 u4 Z# g        {. x* h# W7 \' P& b
        }8 p4 Y+ [8 X, x/ s' t- u
& s( A7 J5 F+ |7 {/ v
        //-----------------------------------------------------------------8 d, [& g5 P8 ~. w& J: w
        // Method for testing that class has been reached! J# Q+ H( |; F
        //-----------------------------------------------------------------        - W: `- _5 l& g
. F3 }+ y+ |$ C  `6 I0 Z
        public boolean ProgramCompareReached()        
1 x8 E! ~' ]$ }5 Y. H+ K  f        {6 E4 _( w  m" e8 C- e7 b: C
      try 4 L  W% O2 B( T0 b9 }
   {         * V, W% ^) C) Q$ H. G
                       
! \/ Z) S4 ^4 d: j                //********************************************************************
' W0 D: C% |: Q2 ^6 o                // Try-Catch Statement is used to handle exceptions - such as file not found ( N' ~5 y' z( c- [( B8 V- r+ n6 K
                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 E/ F, U* F& p8 X
                // For more information see page 534 of the textbook" C* _* q' d* K8 w
                //********************************************************************1 L* ]2 ~% y; x7 Y6 k6 k3 f3 R
                    
& O; f$ _+ H0 I# Y( T% {0 K        }% d! n% r# `; W6 ~9 y0 F9 H9 O2 u; E
             catch (Exception ex) // Exception caught here and message displayed to the screen
0 ?1 A, D! {. ~2 `# [          {& o8 d% O5 t1 F
                    ex.printStackTrace (System.err);
2 M6 v! {' T; m  H( e           System.out.println ("Error message goes here"); // Replace this error message with your own          1 c9 s. S$ W1 r
        }6 R8 G# |1 m8 I& V
                return true;
2 [( g3 D! g8 X& V- Z" t        }
1 T$ ~1 u- ]* ?* Q; l/ P( Y: [5 d5 L! l. |7 A, E
} // end of class ProgramCompare
& ~' w& \) U5 a) Z4 w
0 y8 Z) ~( t: Q) A2 a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************3 S+ A& m' p- j5 d9 H& S% b. g
//  ProgramCompareMenu.java    Provided by: DRS1 m& ^8 o( P3 L/ p5 [7 y& D
//
  t7 M1 w( ~9 E; e, t//  Calls AuthorisedUsers.java and ProgramCompare.java
/ ^! K/ g9 P& r, K) s# a//
* |/ O8 t! y$ P$ l( `! c% s9 n//  Driver shell for Assignment 2.
7 @( |  f# x, ~//********************************************************************
  m$ ^% ?/ a3 b# ?9 M9 s% O+ s; k7 c
- `9 p) M& u4 _$ b$ Y" E! G% c  }class ProgramCompareMenu/ @# L/ j+ R" ]* w' T( }; j& a2 d
{- y" d& `1 ?- ^7 Y; u4 X
    public static void main (String[] args)- L! J) o/ P, s: E
            {+ W9 G8 {( R; T
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, V+ l; ]( F+ n- V+ z$ x5 e                ProgramCompare reached1 = new ProgramCompare();
1 F4 Y7 l) E; T% f" x0 `                AuthorisedUsers reached2 = new AuthorisedUsers();        ( u# @, P; K1 P
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
4 h! a! ?  T8 e1 u+ l1 J                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
* e1 r+ y9 _  m, X. d# x        }. Q6 g" Q% {5 V! R
}// end of class ProgramCompareMenu# ^: N. {  }$ ]8 F" E

' i& H* s" N8 M" P/ W: C, J0 x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- S: y( A' e" E//          AuthorisedUsers.java          Provided by: DRS4 J8 i$ S0 f4 o
//                ' y' U/ O2 G3 T7 f' M
//         Program shell for Assignment 2/ k2 r# e" G0 q, U
//
0 n% m9 y3 f( @1 Y3 B9 c//         Represents facts about an AuthorisedUser2 s8 n: A, i1 u$ r! P( Y; d
//********************************************************************
, a3 f% b8 }+ ?  c
$ g- @1 Y4 W- a( J8 s9 }' }# Zpublic class AuthorisedUsers' q9 g+ ]* _" [; N: y
    {9 ^- S# e% J& W

* N( ?5 e, r; L; o$ F$ s4 O! |        //-----------------------------------------------------------------: g( X: [; P+ h4 D; H5 C
        // Constructor
& s  h% ?/ ?+ n0 u. j        //-----------------------------------------------------------------% r& r) W  ]! b9 L$ L6 u

& ^# U2 s7 T3 Z8 a        public AuthorisedUsers()
0 Z& U) Y9 W2 I, A5 `                {
4 w5 Y9 n" `, P3 j9 j                }1 N5 N& U; H4 |! w6 P( l

- B5 _- e' z6 V, v( @/ |9 b/ i        //-----------------------------------------------------------------
' k9 N9 @) w: q. L( P        // Method for testing that class has been reached6 j) b% x, o+ x$ t5 r4 z+ U
        //-----------------------------------------------------------------        5 y# Y, ]/ F* O; P# ?+ a
        public boolean AuthorisedUsersReached()! k; _5 J( M& Z
                {8 w% o4 Q4 C& i5 B0 T/ N$ t
                        return true;                        $ A. O! H4 w; v2 d
                }5 I$ P0 Z* C6 |: b. b5 X% M3 }# @% l
               
) C: }+ @0 ~, a    } // end of class AuthorisedUsers
8 y5 }" K5 m' x) |4 ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming7 Q1 p. {" [6 T$ r2 D: a
Shanghai - 2007
7 h% {% W4 S, X0 ~7 y6 M. y0 X$ KAssignment 2% E% V8 N' X4 `0 q$ g; S
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)
2 I0 E# J9 Q% j/ l- p' O1. 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./ u, ?8 l; u9 O& h8 ]4 v
The staff must be able to:5 j  b! c( }1 l# I# g2 x) `
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' K+ {0 J1 Y) F1. 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.
$ b9 w" p' ~* z The interface should provide a menu so that the staff can:; B6 L! U; m, M. g# f0 d
a) Enter the names of the two Java program files to be compared
' y! b& R% L3 x  v. }# e For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
; r  w3 v, ^! C) w- b, }0 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).: d4 W1 c' f1 h3 J/ y$ [! @/ b
BSA104 Business Programming – 2007: Assignment 2
4 o  z: R  i9 ?1 C5 a( DPage 2 of 5
! U. \& o8 D5 P: ^b) Print out to the screen all the lines of code that are the same
  i9 o) n' W' l4 o Include the name of the file and the line number of the code being printed for each of the two files$ \# X3 W) ^! f' r: j
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared: _# s$ ~/ z! `" ~' @( \
 the name, username and department of the user- v1 R; G" t. _0 e4 V1 u- r- Y
 the statistics of the comparison
3 c1 z& e# F& T8 J5 f- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, I# H8 s& Z) X) P' z" e
 the recommendation for further checking8 r) y* q) D/ U; u
- 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& t" m$ ?: d1 \0 i2 s7 a; |$ B
 the names of the two files compared5 H- v# P$ D5 y
d) Leave the program (exit)
9 |+ }/ v+ `7 DThe ProgramCompare class: (Total maximum 20 marks available)2 F% V9 \4 j' J5 l1 C: c4 }/ [3 P
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)8 b, z+ j. a5 B- v2 Y1 r  P
a) provide an error message if the files are not found or there is a problem opening them+ i( o. Q& F( Z' w' O4 X0 p/ [3 J
b) compare each line of code
9 _2 s; b/ n' q0 O4 S. xc) print out the lines that are the same
# o* z, ~% B# w, fd) count the number of lines compared / lines the same
5 U- U0 z/ a, O  FThe AuthorisedUsers class: (Total maximum 20 marks available); [- C' g+ O1 x0 p+ `4 j
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)1 c9 [8 n* h: S5 H
4. Provide methods to:
) P$ t0 Y8 W  I1 d+ w0 Ca) 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  f, ~. X+ T1 p! }5 e8 I7 r
b) return the name of the authorised user
# Y! w) [& m# w4 u! q, c. |c) return the name of the department of the authorised user
6 ?$ b+ r0 s) e( j' nIndividual Data (Maximum 20 marks available)
. J. q) v# r4 _' E5. 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.
: @# f1 n( d& l# KDocumentation (Maximum 10 marks available)
2 J' y% e3 I% Y' ]" [* _4 i6. 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.
  z* F- \3 k0 MBSA104 Business Programming – 2007: Assignment 2
1 A# l0 W; H7 V5 rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 J7 _9 ^- d/ f" q
不过你要翻JAVA的类库说明。你有下载没有?
$ T6 R3 {7 b! u  P& [. u查询关于对比的函数。貌似关键字是contrast,还有compare/ K3 o5 H2 S& i# O! s* S" h
( y, B3 Z/ f, |3 H4 L$ c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
0 O+ ^7 \- F* L0 z5 s/ G  r痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。# T; _/ I0 |: ]
可以下载到的 是 jdk-1_X_0-doc
, m9 q2 ?$ r! V$ x/ F/ a4 z7 e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-17 09:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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