找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1077|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - |2 W% {7 D1 V, `3 S , |8 F8 ]9 p b" q' K2 g7 Z* l
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************" ?9 T7 _% T9 _1 A0 g
//  ProgramCompare.java         Provided by: DRS' T* v, W7 y  H. i) e, Z7 O% p3 U( k
//! L3 T9 B" G7 A, f3 {
//  Program shell for Assignment 2# }+ W: x5 T! `4 w- \0 U, V
//( P+ [7 o" Y6 j: _
//  Compares two text files line by line: A$ z# h. y7 S, w9 _9 T+ C
//*********************************************************************- r! i" w2 L# v& G. t

5 X2 J0 E& N8 E- s% m+ i+ b, Z/ limport java.io.*;, q1 e/ d- F/ ~3 X

* L$ C4 d: c4 lpublic class ProgramCompare
2 Y' r! K5 e* T& q+ l# t: \{
, |: d! i" J) W  ~. P. k, Q        //-----------------------------------------------------------------
! ~' s% a0 U* z2 K        // Constructor
1 u# W. x5 `6 l        //-----------------------------------------------------------------& G/ |& p) P6 {; n& h7 ]
        public ProgramCompare()
9 J! I1 ^$ x. m5 E/ i        {
5 d; k3 Y9 W: d! M        }
* K4 @2 N/ q. I% j: ~! j& m7 L# o7 t; \4 L/ R6 Z
        //-----------------------------------------------------------------
, u) j1 q& d4 Z/ C  \% j6 M! ]        // Method for testing that class has been reached
2 Z. _6 D3 Y7 S. c# @! v( c        //-----------------------------------------------------------------       
; c& P1 i) d5 D2 |* R2 ]' R, S& ^1 L! N7 C& Z
        public boolean ProgramCompareReached()         % E  p) H$ t$ {1 A. h
        {4 G" a! g4 _; Z2 U
      try : |3 D& Y* Z  z/ i
   {         2 p5 A7 G$ l% P* R( |6 C7 J
                        1 r; Y$ O- h% t
                //********************************************************************, F+ M8 W% `+ X' T+ L9 d# r
                // Try-Catch Statement is used to handle exceptions - such as file not found 8 k2 O: q1 J- O' \
                // Reading the files will need to be placed inside a Try-Catch - just like this one!* ]  Y6 K# [: p1 R9 f0 b9 n$ T5 @
                // For more information see page 534 of the textbook
* a& V4 g( e) |                //********************************************************************' _3 H; S2 n! \3 u( {+ [
                    
, c8 U& H4 N- A/ T0 L        }( i  d; ]1 `+ P: s/ B. G* B
             catch (Exception ex) // Exception caught here and message displayed to the screen 9 L* \, l: y: b, I# c* F
          {: s$ F6 H7 p. G' X1 `8 r- p
                    ex.printStackTrace (System.err);( F0 X/ y, ]! X2 g, S
           System.out.println ("Error message goes here"); // Replace this error message with your own         
# Z9 k- \5 y8 S% X) r; l: z9 B        }
" b/ G) g+ p4 e                return true;
3 m) d4 u# O' @) D        }
- Z) S# A1 Q( Q# z; Y3 b, Q7 S
( w# A9 H% @8 _! d( ]2 _4 \} // end of class ProgramCompare
! _& b5 Z5 _; h' {1 O& d; ?# O% P$ p) N, a4 t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' `7 b. a" _, U1 p//  ProgramCompareMenu.java    Provided by: DRS
7 l# W( W9 B- f& O% T//& P6 y% |% |9 Z+ S
//  Calls AuthorisedUsers.java and ProgramCompare.java
5 Q% t5 o! E4 ~, J//
9 d5 r; |3 ]8 u: u2 K//  Driver shell for Assignment 2.' P' p- A% M( s$ A
//********************************************************************
% t4 k$ I( d2 k" X
7 s% h6 v0 o8 v9 c- C, N7 e2 vclass ProgramCompareMenu
# s% a0 X6 B4 W$ X5 B1 z# r! `{
) w# L# n& G9 E    public static void main (String[] args)( e5 e! D, ~" S$ n, ~- }  z
            {* g3 M( G8 ]5 t
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- _9 {! K; i; h8 J2 Q                ProgramCompare reached1 = new ProgramCompare();
  M% \+ ?8 N- X                AuthorisedUsers reached2 = new AuthorisedUsers();       
0 m3 |% L" v+ z  w                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 H+ O# N  b+ K
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" @4 a7 y0 t9 b& W1 Q# T        }0 `- w  J/ p1 |; v9 B' _; Y, Q
}// end of class ProgramCompareMenu
3 a1 a! }  }4 F. M+ |: e
4 a0 t2 N: K3 }$ v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: J# ?3 t8 V  L  l* Y& K4 f//          AuthorisedUsers.java          Provided by: DRS+ S) K7 Q# n2 |8 @: b
//                ' s' B- |5 }" \  A
//         Program shell for Assignment 2
8 }  C% V7 s* U# ?7 y//) v# {) P/ c: ]: j4 W# [$ v, O7 A
//         Represents facts about an AuthorisedUser
- w' q9 S2 F5 _//********************************************************************! B) E. [. V* q( {( F2 }

7 A2 A, P# n% y8 l: Xpublic class AuthorisedUsers
+ ~% e- t0 [# g3 \3 ^2 o, ^    {
# c  x) [) U" h) }, B/ {
5 _, {" @7 O1 K- }        //-----------------------------------------------------------------
, r+ \0 ?, z6 B& A) S' g        // Constructor
9 `! o6 {6 X  B6 e" t! o1 }        //-----------------------------------------------------------------
# S8 A- L- A/ e5 {' f7 @! o1 \0 u: M7 j6 @1 ?
        public AuthorisedUsers()
- Z: A9 G4 W/ d; b6 s" F7 I; i7 n                {
1 M8 q& O8 D) u4 J                }0 k" f* h" {. j: W& |0 s
9 m* f* |* ]3 V1 k/ k
        //-----------------------------------------------------------------6 \6 w5 P. r8 w: A
        // Method for testing that class has been reached) F: K# y" i/ C. j
        //-----------------------------------------------------------------       
/ c2 u$ v7 o/ w9 \        public boolean AuthorisedUsersReached()
7 ]' L6 j- B1 N8 z) a; X' o) z                {& V+ f# r6 W( e2 s
                        return true;                       
; h! @. D" a' d: O" V7 T                }
2 V5 J! i* V, R8 i3 g& _0 Y               
9 f/ ?& Q/ K) o+ B. ^0 o    } // end of class AuthorisedUsers
8 X* i+ ?* P0 o( i5 ?8 _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: B1 H, i9 u; J9 f
Shanghai - 2007
2 m9 A# ?9 i4 d9 o) x8 ~% R- DAssignment 2) v1 q9 ^0 r$ g3 I% K
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). ~& d* K# a7 K) c* q2 R
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 \; p' T) Y( O# nThe staff must be able to:
) t* {* S3 K8 O0 H( m Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 L( L  y* m  _
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.  P' m2 f7 ]4 m* h
 The interface should provide a menu so that the staff can:
+ q: P6 j8 q, }3 S! N7 Da) Enter the names of the two Java program files to be compared! I6 p4 W! Z5 H& ~6 |- A
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
! I  ^5 m% C3 p( Y+ ^1 [3 J** 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).
( y. }4 S" D; Y: _$ JBSA104 Business Programming – 2007: Assignment 2" e  V2 h8 ~) T. d' b+ [
Page 2 of 5( ^9 w$ o7 A. H
b) Print out to the screen all the lines of code that are the same0 I- H9 t& M' o: K
 Include the name of the file and the line number of the code being printed for each of the two files
  h  a$ C- c* Q. a4 @- \5 xc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared: ~1 X: }3 s. L2 l9 {8 _
 the name, username and department of the user% J% C5 s7 {8 d4 S* y
 the statistics of the comparison5 s" O, Q6 G) l9 I
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ P  q! M! c6 |6 c the recommendation for further checking) i% T4 \; g; R+ j
- 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
: A4 t# W, E9 L+ a3 X3 Q the names of the two files compared; s8 u/ J5 W& u
d) Leave the program (exit)2 Q7 M6 R" d' h+ o8 R( b, Z2 T
The ProgramCompare class: (Total maximum 20 marks available)6 m; t1 T# S4 v$ F& H
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)0 s4 M; V* O  O  F$ @% ]- H- k
a) provide an error message if the files are not found or there is a problem opening them8 j# V! O( Q1 b) v$ M
b) compare each line of code$ X+ C1 v) Q. h; s
c) print out the lines that are the same% k, P, g4 k8 D7 d# _
d) count the number of lines compared / lines the same
, a0 n2 g% A" v# Z. W$ a+ NThe AuthorisedUsers class: (Total maximum 20 marks available)8 ]$ t1 ^  A: U
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)2 k" e0 E7 W3 D# f( p  E- ]
4. Provide methods to:
/ q% A- o# P* Q. {1 V4 }; q* f) qa) 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+ P  D3 b( A6 l( u9 n! o
b) return the name of the authorised user3 O  K1 ~  T4 G/ [. i. U
c) return the name of the department of the authorised user, n9 P2 V3 L* K+ s( D, N0 s
Individual Data (Maximum 20 marks available)
, f6 i" u0 d$ |  r5. 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.
0 z4 P* N4 Q% r! n# ?# a/ z9 MDocumentation (Maximum 10 marks available)
, p( y* B. [1 ?' K2 c, B& p0 j$ R6. 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., }& v! p2 P0 M
BSA104 Business Programming – 2007: Assignment 21 \% P* z/ q: ^+ A9 c- ^( Q1 v
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 D) I3 a( J& G不过你要翻JAVA的类库说明。你有下载没有?) C% {" r+ f) v3 ]- v
查询关于对比的函数。貌似关键字是contrast,还有compare
& {( k$ v$ H  R! ]1 D- F1 Q  }4 |5 ?" y, o. e$ x* Q$ E& T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, N% o& E0 f4 Y6 _2 [2 I, n4 k痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ [/ {( O3 f* h  [+ _2 L8 @可以下载到的 是 jdk-1_X_0-doc
& ~2 V7 U" |8 Y
* I- k) V. a: m+ {+ T. K# s3 J7 Q/ K$ O[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-27 15:39

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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