找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1430|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& m" v2 P5 {3 N , ^# R5 X: M, r+ c( Q+ }5 |. b* U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************; q0 M! h* p0 ~" o. ]  B
//  ProgramCompare.java         Provided by: DRS
( F/ T+ |4 g6 E; U- `- S//3 l1 c$ P$ p1 z0 H
//  Program shell for Assignment 20 }. A4 o  ~1 ?
//; H) j( t" \! k/ B* U3 [) I: _8 X
//  Compares two text files line by line
0 I' E$ J8 D8 b; `* I: r9 u) F//*********************************************************************
/ G% _, R$ u* f# |4 i
3 A" h( K4 ]3 ^1 I) H- yimport java.io.*;* _0 |% U: D! @' W$ \$ u- |& x. o

7 q1 W3 X. r. I+ spublic class ProgramCompare
$ L# z( o) J& i: r1 j- A{8 A" G+ T% B( |0 `. b9 D
        //-----------------------------------------------------------------6 X! z! K0 Y: i$ h6 |3 Y
        // Constructor
. O# ~; o' s+ k        //-----------------------------------------------------------------
3 u$ }  w, B; Q        public ProgramCompare()
& {4 {1 |+ A! l: _; h) k        {+ T* F* A! ?1 ?# h* A) {1 G9 X/ D9 N
        }! n5 B9 ~- v# C, t* V) o
& s! U4 D: _% c
        //-----------------------------------------------------------------6 F2 ]9 D& R- h& r0 D1 t" t# O# ~
        // Method for testing that class has been reached
$ J9 I3 U9 d6 a* d+ |4 L) v% Z; o        //-----------------------------------------------------------------        8 R9 M7 C1 u( s+ u1 I, N- ^( r
4 `$ h6 E7 C7 q" [5 ^
        public boolean ProgramCompareReached()         3 D. q/ Z6 @0 o( {# X4 ^( {
        {
% l! H" v; p* [4 ~: C8 v3 L0 C      try
4 X4 Y4 A' |& C  _. v' ]2 @   {        
) o2 r0 |) Y  F* o! V                       
( F; z" r2 L* ~+ ~                //********************************************************************
$ `; x9 _1 \: w& d/ ~* ?3 }% D                // Try-Catch Statement is used to handle exceptions - such as file not found
/ ~% ?/ K2 M7 P2 @, n* c" B( `                // Reading the files will need to be placed inside a Try-Catch - just like this one!3 p9 C' c/ R6 _" v
                // For more information see page 534 of the textbook
; {6 B+ E" d# a# _                //********************************************************************6 U6 ~  t% w, W; f+ E" ]$ o7 u5 f
                    
& P8 K' R2 u# T& e* b$ S        }
1 T' {5 G. ]4 O1 ^+ @             catch (Exception ex) // Exception caught here and message displayed to the screen . v' v, \/ _0 A( C& _! y
          {7 j* Z' S+ P9 ]  }. l: Y- U! ]
                    ex.printStackTrace (System.err);
) Q; V, w- p: m           System.out.println ("Error message goes here"); // Replace this error message with your own          + W" I/ Z. o4 s! B+ D
        }9 {: {  s; i1 V$ ~1 Y% N0 q
                return true;
% P2 ?; |. I+ R& b        }
! i) R+ u. n! j; {& t4 T
% b, n; C' y. `# o! T* w} // end of class ProgramCompare5 b/ o1 O; d/ z+ C! a
$ z' C* ?- r+ b8 {$ h; s! q4 K& O- m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- ?  j0 m& }% s9 y$ i# x) B3 T//  ProgramCompareMenu.java    Provided by: DRS- F" O) W- q. J& y! O& g
//) i) u2 }# B+ ^8 |
//  Calls AuthorisedUsers.java and ProgramCompare.java
7 L# L) P" E0 l6 P7 `$ ^: p: Q//9 _$ D) k/ X; i# O1 e" i
//  Driver shell for Assignment 2.# B! _% R- w! U3 X& P
//********************************************************************4 f/ c, }) p5 _& A, J$ S
* a, N& L1 w# S5 U5 J. J1 K4 M! e
class ProgramCompareMenu4 J& t/ Q% K4 p/ ^1 e2 c# g
{
; P5 E* |4 l* b0 o% c# g/ h; _( n: j    public static void main (String[] args)% ~' p6 Y1 A& P, u5 F, d1 _
            {/ \# J! B1 y7 t* V! ?% }4 q# W4 k% O
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 M3 T! ]3 d) j: C% z                ProgramCompare reached1 = new ProgramCompare();
' s+ [/ H+ A& W' j& g                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 f4 W3 h* p9 {2 T% ^: g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, J3 N. B# L/ o0 S  B                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
: |; p3 Y( q1 x3 p1 O. @" w- }7 i        }
' R& P7 }+ I! F5 `}// end of class ProgramCompareMenu" G. Z" ~. `0 s+ w) ?, m

. E5 i6 t+ G( \2 a0 I3 g; N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************0 {3 E' w, |: @% e8 I1 p' R
//          AuthorisedUsers.java          Provided by: DRS
& ~9 \9 `7 V0 `: ^' k//               
9 i$ n& Q0 o! ]+ e8 d3 H//         Program shell for Assignment 2
- i' ^1 t' }! c% V2 x& z% c//
6 K. q. ^+ o, D//         Represents facts about an AuthorisedUser
5 T+ j3 L) A' N) y) o/ d//********************************************************************
2 J  z/ p" ]* e; \, c% F+ O, V% E8 \0 Y6 O6 P: u- i
public class AuthorisedUsers
/ w. ]! w0 I0 V  Z( |. a& [    {/ h- V+ |/ @. i

% l+ K& C6 G7 M" C$ v5 B+ ~. D        //-----------------------------------------------------------------
- f! w. f: o) @; P; o' @        // Constructor
7 v0 g5 X4 }6 H' z' i* y% i        //-----------------------------------------------------------------+ {  v: Q. y" D: x% G" y1 t
8 B( ~" c- V9 d3 r3 P. j4 Y! M
        public AuthorisedUsers()
" V) S& v% u# _  I                {3 i; q- _6 Z* R4 C5 O
                }
2 M- p4 r1 Y0 F% F, Z( k$ k& `% C' n. E& U" O/ z# I
        //-----------------------------------------------------------------
1 ~5 C0 q# Y; C5 ?& h: S        // Method for testing that class has been reached& f9 Y2 N9 N  a: P4 R4 U- g0 Z2 K
        //-----------------------------------------------------------------        . e/ a9 d- P( w. L+ }" N3 j. G# x
        public boolean AuthorisedUsersReached()/ T4 `; e$ A0 W- {( E* M
                {) e( f) R! U: t8 X: Z3 K: N
                        return true;                       
- U- j7 j' L9 |8 Z                }
2 v( u1 Q+ K7 {; j  P7 O9 ~+ y/ i                4 n* J- W+ F1 m& M% F
    } // end of class AuthorisedUsers
. ^& X& }  h: K3 P4 w# X& J7 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
  H% e: o1 U# R! c4 uShanghai - 2007
- H) H: @$ R5 R, O8 uAssignment 2
6 Q; v( }3 g) o4 E9 d+ TDeadline 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)' y% L. ~+ J+ Q* h+ X
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./ s' B! i5 L3 {  B; @
The staff must be able to:
8 [! R8 c  x  L2 e: d# }, f5 } Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
. @, p0 g$ H6 T7 Z8 u  {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.6 P# o) {9 o( h+ y0 u
 The interface should provide a menu so that the staff can:' @+ I) Z! o1 X: j7 q
a) Enter the names of the two Java program files to be compared
' V6 y2 S9 ]+ G/ S9 Q* O For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# i. A, |6 D6 _" o9 U: w  X  s** 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).
% `3 z, D7 l3 I, |BSA104 Business Programming – 2007: Assignment 2  Z/ _; t  @+ Z) G% K8 _
Page 2 of 5* u! S& Q! G: u$ A
b) Print out to the screen all the lines of code that are the same
7 ^7 s  z2 w+ s% e Include the name of the file and the line number of the code being printed for each of the two files
. X7 k; _: T0 j5 ec) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 I/ I5 W! I6 |5 {8 k. w% t
 the name, username and department of the user
+ W$ F  a4 x# _+ n+ ?) Y the statistics of the comparison
# s- h* B# m+ m( B/ o7 X. e9 p- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 y" z; A1 X% u1 P+ Q# Z$ ?
 the recommendation for further checking: I5 ?3 y5 [% U- R" J1 B
- 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% ?& d8 j" e' v" Z2 d; ]
 the names of the two files compared- Q  M8 d. m" Z/ D4 S
d) Leave the program (exit)0 T- O0 P7 W# K& A- t0 Z
The ProgramCompare class: (Total maximum 20 marks available)
) C2 h! \9 f. D  J# m. z2. 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): |+ f: @7 ~4 g$ {
a) provide an error message if the files are not found or there is a problem opening them4 ?% P& j0 y( G$ R+ j7 w7 U
b) compare each line of code7 E6 F; N0 j: C9 c2 _* z
c) print out the lines that are the same
2 q0 E# @/ J. p: M6 Ed) count the number of lines compared / lines the same) J  e7 S% k! l- e- b) C5 r( {
The AuthorisedUsers class: (Total maximum 20 marks available); b; @2 R2 n, {
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)
: h) ~& P; t5 I+ @" H4. Provide methods to:
& I" p' M2 E& w6 B3 t2 ~% J9 s1 `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 match
6 B! R$ }3 Y* U1 B: Db) return the name of the authorised user
  C% k8 Q9 r$ d3 u5 u/ W3 z4 s* lc) return the name of the department of the authorised user
! M& ?+ x  u) V% S% g) }$ p; o  M$ CIndividual Data (Maximum 20 marks available)
# N) W8 h. g: m1 s, m( u, o. v5. 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.
& `& h; @+ i# e5 x$ Y' v7 MDocumentation (Maximum 10 marks available)2 `% B4 s$ z4 x
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.
4 y8 u# a; l" WBSA104 Business Programming – 2007: Assignment 2
. i* ^1 P6 c, k) N! [7 nPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ W; B6 `9 U: s' v5 ~' ?( H
不过你要翻JAVA的类库说明。你有下载没有?1 B- T! u  X$ A- e
查询关于对比的函数。貌似关键字是contrast,还有compare
4 d) T2 a7 `* o: `1 ^3 e) E! t9 U# @& c( K! r! @7 j- {
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 R/ V  A( ?& P6 H0 I9 G0 N' n痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。& L, w1 E' `5 v# p7 j* ]
可以下载到的 是 jdk-1_X_0-doc
7 u1 ^' D4 b9 H* e
+ f/ H- p; I  E) o6 y5 C[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-1 21:15

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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