找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1021|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 b: h+ N. q1 s7 i 8 q* F4 S/ r X7 F/ V2 `0 C) P! f
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************; N4 f! f3 n" M# w( w! V
//  ProgramCompare.java         Provided by: DRS
, M; {0 Q6 R6 K) b4 b5 q//0 F- M6 l% Q' P4 g. d
//  Program shell for Assignment 2; q2 n) b; Y, a! e
//
1 A9 w7 A) q# i7 e1 {' u) _0 k//  Compares two text files line by line
) J& c# ?0 c: u/ S9 ^: b0 x//*********************************************************************
7 \6 B# N: ~1 I7 d* `6 e4 E9 V9 q
import java.io.*;5 E+ P/ T; p% v$ I
3 Q8 G5 t# X- I
public class ProgramCompare
. w% G9 d. I4 q$ s{
! a4 d; r4 P! ]2 i  X        //-----------------------------------------------------------------7 H& D6 Q) A/ N$ y" u
        // Constructor, k& E% r: K( @0 C5 l" `
        //-----------------------------------------------------------------
' O( Y7 Z& v. s        public ProgramCompare()
: Q: {  g/ u' [) ?6 X; @        {
  i% h* t: M7 Z0 l        }, Z4 r: |% N4 _6 {

2 ~. |- ?" V' _& ?        //-----------------------------------------------------------------. x9 }' i5 b( [  [9 e; h8 l
        // Method for testing that class has been reached4 ^# L. ?$ }4 H0 ]2 `0 v5 ?3 m' s
        //-----------------------------------------------------------------        6 I2 x, y2 a6 }- `+ R, b; p9 M* L
  r; V" b$ r! q* h3 u# X
        public boolean ProgramCompareReached()        
% P. g# A$ X( Z$ [9 Y" R        {
' L9 s5 h' W+ X) n; R. [, X      try + o1 N) c$ j' A$ @& L; L
   {        
" o) T4 P5 K) v. K+ z, `+ U  R                       
8 l3 F' o, M4 q; ^0 Y' e  n                //********************************************************************
5 D! B1 c0 i4 o5 F# \                // Try-Catch Statement is used to handle exceptions - such as file not found
& {" G# T! t) [% [- h- R" `) ^                // Reading the files will need to be placed inside a Try-Catch - just like this one!: X: q! s+ _4 T" [* N' W. C6 A
                // For more information see page 534 of the textbook
$ A; n! V! M$ ]# N                //********************************************************************
/ M- k8 r& Q3 V5 S                    
7 Q" ^" l) A% c. u, K9 J        }5 `. f8 u9 M8 {5 y2 c
             catch (Exception ex) // Exception caught here and message displayed to the screen & V( Y; g1 V! Q1 ]$ m1 i' d
          {
. v2 k5 C0 ~( H5 r' C                    ex.printStackTrace (System.err);$ }/ O" Z/ z/ p* a4 F9 {9 x
           System.out.println ("Error message goes here"); // Replace this error message with your own         
+ A4 V0 m2 y# _' q! V3 B& o        }
5 i5 Q" C8 y& w                return true;6 T& N8 ~0 e0 K5 Z
        }
. B# Y6 \: E( i- w
4 @- E* [: W2 B- m) P; h} // end of class ProgramCompare
; Z9 _  C# s/ F; w$ _) ~# m' D. W7 h% ]2 W; d/ A% N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# G" ]: i1 d9 {& k; |$ z: b3 a, y: `
//  ProgramCompareMenu.java    Provided by: DRS
% ^: a5 X) B3 \- }5 D% a& H8 Q//3 V5 c% S3 g3 U* c
//  Calls AuthorisedUsers.java and ProgramCompare.java
) X; w: p  i* r0 q1 `0 S/ }5 ^//1 v# c5 e- r% l2 q
//  Driver shell for Assignment 2.
' X* n( I7 g3 `' P, N//********************************************************************
( F9 [$ d! f  R
; ~/ s3 M- D! K* U* C4 E* r3 U% `2 pclass ProgramCompareMenu
0 t$ `5 V6 G' n{, Q  y8 X. W3 h  [- n$ C5 v4 b+ `
    public static void main (String[] args)
' I0 I+ A5 F% a! \* `, ^7 V            {8 M1 {# B5 x: @7 X' K
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
  b8 J& e  l2 l                ProgramCompare reached1 = new ProgramCompare(); 6 g) `( ]- ^. m$ w/ k  B
                AuthorisedUsers reached2 = new AuthorisedUsers();       
' i3 _/ Z6 m/ ~8 D                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- |3 ]/ o+ ]$ @* k: K8 V1 }
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' o. t9 L" U/ i" q: D# w        }
- U9 V2 u+ q: K% t; a}// end of class ProgramCompareMenu
% O# Z! c- z1 V. I/ G
& z) r. b/ R  F! m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ t) w9 Y. g0 w/ U* k2 b8 \8 t% z//          AuthorisedUsers.java          Provided by: DRS. N4 y9 I3 H3 r" ^2 \9 l/ E: e, s* Y
//               
8 A0 Z0 M: {" v//         Program shell for Assignment 27 l9 c! M1 i( c3 ~7 O
/// z/ P: P# ~4 P, }' G% ?
//         Represents facts about an AuthorisedUser( e7 D+ p3 l, j% ^
//********************************************************************' E" O) Y( r9 s  J! o

3 O* v8 ~% ]) p: vpublic class AuthorisedUsers8 d2 A+ l$ x$ J/ M, [6 r( W2 g
    {% r( x" @/ \( ?- F9 B5 A
  t  @( e" l# v  k  k3 Y* `7 y7 i
        //-----------------------------------------------------------------
$ l/ L6 `- ~7 j3 m$ `        // Constructor
3 H/ D  A' G8 H- n0 I        //-----------------------------------------------------------------
  P9 B% S' ]6 R# \9 N) L4 o+ Y8 v/ Q1 X) n0 k! f: |7 P
        public AuthorisedUsers()
- L" ]8 A+ t8 T. @$ H+ q                {
6 C8 h  B: G6 \7 q: G- Z6 S# K                }- P9 J  I4 Q+ }& X% P* y
( q. u2 ~: l  `& d  Z
        //-----------------------------------------------------------------
2 h7 f/ L, E& P        // Method for testing that class has been reached
8 r* g$ r1 z3 H. T2 ^& V. n2 _; o        //-----------------------------------------------------------------       
% ^- t* R# {, E6 k/ V        public boolean AuthorisedUsersReached()
! o) y& B  o5 v9 f; p( ]                {, g. `+ y3 H" D% Q. d9 F/ y
                        return true;                        ' U5 C/ M9 M* s. c
                }+ S  B3 A' n+ L! T3 J6 r1 z- T
                ! |. z" u, r! a* R  C
    } // end of class AuthorisedUsers
! G" {2 A" K9 [+ n' H+ o  [5 B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" a2 {1 S: ^, i# d
Shanghai - 2007
. m# s4 x% P7 ~# T/ }' a( sAssignment 23 q- `3 \! n6 r9 Q; G% m# T4 T2 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)& ]! [  _: y$ L% H0 ?
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.
" u$ @3 a( Q! ^& G7 u5 A$ pThe staff must be able to:
0 N( K! U2 a0 z! o Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' O( F! R- a/ j2 _5 W4 C2 _' V1. 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.
; T" [! z$ g, b0 c7 a The interface should provide a menu so that the staff can:5 t8 R. s% x1 t, m
a) Enter the names of the two Java program files to be compared# g( Z$ |) C& G5 ]7 t. C
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  |) ?, a! B. ~# l; S7 D" }$ K
** 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)." G- K" A8 l; J: y) O
BSA104 Business Programming – 2007: Assignment 2" h5 s* p( R# @' r8 W6 }' f1 n
Page 2 of 52 N* c. Q: }. P+ U1 S: }
b) Print out to the screen all the lines of code that are the same
, H% e& o) ]: M$ d- c, y) F3 ? Include the name of the file and the line number of the code being printed for each of the two files
0 U/ X' v/ ?3 e" x, ^c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. c/ l0 S1 n& q7 X- [& k the name, username and department of the user
. Q8 H; ^4 i3 }+ r3 S3 I the statistics of the comparison
* {9 W+ u  g: Q& k/ i- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& r0 c# B; ?2 Q. B6 q4 O& U, p/ q- `( C the recommendation for further checking5 ~2 |1 b2 x% }6 K" ]
- 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 closely6 }7 U2 t7 k4 d; {" V
 the names of the two files compared
7 t6 y  e) t- P2 Td) Leave the program (exit)
% H: D) X& K- w0 M, ?( o, i9 CThe ProgramCompare class: (Total maximum 20 marks available)
, [; E1 Q7 b. ~5 T2. 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)2 P/ Z7 O2 s$ i# h( _+ X1 S
a) provide an error message if the files are not found or there is a problem opening them* n8 s" c- e+ Q
b) compare each line of code
! s5 ^5 }  n7 y: x: i) B  Gc) print out the lines that are the same2 k2 K' K! _1 M( y1 Z
d) count the number of lines compared / lines the same
' U4 ]& v8 i) K( v7 D' WThe AuthorisedUsers class: (Total maximum 20 marks available)
! ]; \6 A5 @- ~, d5 G3 T$ F3. 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)
! b9 s! a* j# [5 R4 C! d4. Provide methods to:
  b4 ^/ c% C3 L( b" H; pa) 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
4 c4 ?0 s* N( N7 G. V5 Kb) return the name of the authorised user
, C$ m4 ?+ |" M0 i, C# o6 bc) return the name of the department of the authorised user% x" U4 V% a" w; ~8 h5 a# K
Individual Data (Maximum 20 marks available)/ v& L% y( z( I4 {1 k5 z" h* x
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.1 T! Z0 c8 M; V  |5 ^. z7 {7 Z  A+ p
Documentation (Maximum 10 marks available)
$ `! F8 n* a$ c) ]+ g/ x$ J' `* K$ T6. 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.
5 y, X; Y$ y: z1 N- ZBSA104 Business Programming – 2007: Assignment 2
; F- B% M. L8 P7 zPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了3 S( ^  t+ F1 ?( a' z
不过你要翻JAVA的类库说明。你有下载没有?
" l" T+ |2 L  I7 ~, r/ w1 x2 c. ?查询关于对比的函数。貌似关键字是contrast,还有compare% h4 C) Y8 M. L, Q+ k- Z
" X2 R, |) P2 w2 |; L
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ n9 \! R% f* I! v) q0 N! ^
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; p3 v3 m7 A8 \) A可以下载到的 是 jdk-1_X_0-doc3 Z  N& N6 f6 A& J" _5 i1 Y: z

9 n( ^9 q+ Y8 a, o$ _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-8 21:25

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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