找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1239|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 . t& P% w% Y- @ Y& w : C; ~2 A% Q1 |1 q9 s
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
1 Q5 L6 y5 ^+ K* E, e//  ProgramCompare.java         Provided by: DRS
$ U: r- c7 |* i$ d- E) R/ _/ c$ F//. |; W7 V7 Z) W& v. M- i
//  Program shell for Assignment 2
1 H5 g9 n1 i9 G: U1 L; D  \//" I+ \' `9 z& B1 G8 M" s' K9 c" U
//  Compares two text files line by line8 U: X; l6 X  B; x# V" A
//*********************************************************************
/ ]: Q6 p8 |  K6 [5 |5 `, _% i
% F3 o+ g! g3 E) X3 Dimport java.io.*;
" W4 B5 S# Q9 \$ u; E6 F* y# r; Z( b7 G9 u3 S+ u8 V
public class ProgramCompare# R* n6 K# D" ?3 p3 e, A& Y
{
9 s3 c1 I, M+ ~) \& x9 z1 l        //-----------------------------------------------------------------( U5 {  u* q$ y. g; ?2 e* K
        // Constructor9 k2 d8 h$ i% \. z5 V1 G
        //-----------------------------------------------------------------* n0 O. r) L" [  R. G1 i1 I4 u
        public ProgramCompare()) B. y  z% S: k& _: T; I" D4 m
        {3 Q1 W; L2 B1 h- x% D& r8 @
        }
1 a8 I* m. r$ L$ D
9 Y, m/ [, C4 A/ s; g        //-----------------------------------------------------------------
+ r% e6 ?6 [. q2 l9 d        // Method for testing that class has been reached4 @) [3 o7 ~. s! Z
        //-----------------------------------------------------------------       
+ l& R, K' S8 v( E" I9 O  \) S9 I$ }4 a* d' f+ r
        public boolean ProgramCompareReached()        
, O2 e9 L. h! A  o3 r3 }        {7 C5 G9 }9 x& W8 v  d0 [
      try
# [0 |( J- U% E& C9 ], Z+ w8 m% E   {         7 H) Y5 f# C! `1 K4 ]  [+ B4 s
                        3 \& K4 \+ M/ q2 o
                //********************************************************************0 u3 S+ \+ _7 X* J2 v2 g) k6 h
                // Try-Catch Statement is used to handle exceptions - such as file not found * I) N, S& ?* O/ ~8 S
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
: M" }8 h- n, k! \                // For more information see page 534 of the textbook
/ Q0 O# p0 e0 r* h+ l% a                //********************************************************************
; q5 n+ Y) v/ \  i8 R* H6 m2 S) w- i  D                     , c7 Q5 }" h; x
        }3 S" d' I: O/ J: x; {. m2 \0 S
             catch (Exception ex) // Exception caught here and message displayed to the screen # f0 g" y% K; j
          {
# e& H! }) E7 n9 {! v                    ex.printStackTrace (System.err);
4 T3 `5 Z. s8 v+ i           System.out.println ("Error message goes here"); // Replace this error message with your own          : H! e  y7 Q1 P- ^, G8 {/ c  _: C
        }
+ F: u3 `8 L8 z, Z$ K( U                return true;
6 [1 p! O. w6 M; B( l: A        }
' l% ]' w2 d6 K! e
; l1 I+ t8 ?9 b! t8 b} // end of class ProgramCompare4 r8 @, x; i9 q4 Y

* J# F5 X* E7 a( T) X7 P0 Q# S+ q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************1 Y. J8 J. J! ?
//  ProgramCompareMenu.java    Provided by: DRS0 x' c# S2 r3 u2 e$ Z
//6 u* m! ?/ M4 {/ H% K4 ~
//  Calls AuthorisedUsers.java and ProgramCompare.java
/ ~! }5 n( `8 ?8 W6 ?//) P. `5 Z& L# W5 d$ a2 a
//  Driver shell for Assignment 2.$ y! Z& c, N9 f' ~: e5 _) t. L
//********************************************************************
" F) H" U1 h/ \9 i4 ?
$ s# Z8 ~) y' L2 L! h* {2 ^  {class ProgramCompareMenu( V% O) ^/ H. q. r! [- E7 E
{( V! H; t, S$ a/ \. p1 b( z
    public static void main (String[] args)
' S- O+ R+ p4 l; h) Z            {; F8 V9 `; n: |: |$ z
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: l6 l. o1 r$ n% \6 H: R
                ProgramCompare reached1 = new ProgramCompare();   _. G* H5 s: H+ A4 d0 F  ]& S
                AuthorisedUsers reached2 = new AuthorisedUsers();        4 q; ]* V3 {' \1 v
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
8 G; D# E' k2 i+ K6 k9 X                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ( `9 l6 O6 y, Y8 ~0 a, ?0 g3 D
        }7 e0 s# @0 a( n
}// end of class ProgramCompareMenu
0 S- W$ \6 p; Y/ Z3 D3 m+ m8 i9 K& b: {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
+ e2 p7 M% x/ s//          AuthorisedUsers.java          Provided by: DRS- d  ~/ z9 l+ H
//               
7 s5 E7 A- C# V- n4 G//         Program shell for Assignment 2
5 h4 p' q! k' B2 d- c& C2 Y$ q//
3 m' p& k3 M4 h8 }! s# t1 T- }/ D//         Represents facts about an AuthorisedUser: m2 u* G+ }; J. z5 I7 A
//********************************************************************
* A4 ~, X, y* ^$ \/ x5 a
% L' Z6 {5 E# b6 h4 F" Q& N& Ppublic class AuthorisedUsers; U0 B2 i7 w' S+ I
    {  B, R) X* `* S, E; X
1 c6 z* X3 b0 o- O
        //-----------------------------------------------------------------
: ?, }3 ~, e) T% w- |7 O        // Constructor% g- M. [, G, }3 g
        //-----------------------------------------------------------------+ C6 a+ y' T. E6 N) ]: }7 ~
; `  k. N6 b1 D- F! _  n# Y3 a
        public AuthorisedUsers()4 ?8 x: I" \$ O- T& K
                {' ~* W: q5 L1 e9 ^3 {
                }
4 g- S) L8 @/ F) L: v8 U. t. p4 C* S5 y4 _, U3 {- ^0 E. O  A7 E' ^
        //-----------------------------------------------------------------/ l' j2 s6 D; g8 z
        // Method for testing that class has been reached
2 [' |, \- ~. O) x        //-----------------------------------------------------------------       
& d1 P. h) T. }, I( S( ?3 @( R        public boolean AuthorisedUsersReached()6 m  c) N. Z* O1 u1 q! q
                {! W( j+ P! [; b2 i# X9 E/ a
                        return true;                        ) \% F+ b+ R2 |% j0 {  B
                }- i% I" h: L0 }
               
/ p" o1 f  H. X: N3 C: h    } // end of class AuthorisedUsers
* A+ W4 B4 ]& C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; Q1 X1 D! h1 a+ E0 v- H$ i: N- FShanghai - 2007
4 U; ~* U& {0 W8 u% Z$ f6 x1 fAssignment 24 f& G: H; ]5 F2 p* H
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)
$ s( n$ d- l: }9 [! l. a+ |; 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.
( N9 M+ J7 f3 u: NThe staff must be able to:
! M) s1 a6 U- s* V1 y: Z. U Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! X( w" }# K( l- C7 I9 Y
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.
) V* q3 v& D- k0 c, |" W! V The interface should provide a menu so that the staff can:
  u7 R) u0 G7 W1 F- O/ ^a) Enter the names of the two Java program files to be compared5 G8 H( e( {; z% M. L) Q! B
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' y  d: W5 @* \: X* V5 U; 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).
$ X5 y. f: d0 ^. a: zBSA104 Business Programming – 2007: Assignment 2  y5 o; M* j6 U" K: i( p: R
Page 2 of 5
. W2 Q5 V) u+ A6 w6 b, Mb) Print out to the screen all the lines of code that are the same: m3 F9 `1 ~& ?8 ?
 Include the name of the file and the line number of the code being printed for each of the two files7 c2 _2 Q( V, m; r
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  }  J7 L8 k3 g5 m
 the name, username and department of the user: X/ m2 R! V' a
 the statistics of the comparison
, T$ r3 }* r  U/ c+ M! B- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
9 q. z3 C" r8 n& d) N- V/ C0 [0 v the recommendation for further checking
% O% z2 b/ E. Q2 I/ {1 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 closely
2 ?' T. h5 i% C& a" _# o8 P  f the names of the two files compared
; M) j. j- c+ D; Od) Leave the program (exit)
. y0 F  L7 j5 wThe ProgramCompare class: (Total maximum 20 marks available)+ M* T: G  O& f" e! j4 U
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)
1 r+ h8 m5 ^* G- a2 [  s4 J( _a) provide an error message if the files are not found or there is a problem opening them5 h% E& Q4 O7 f" t  q% F
b) compare each line of code
( N9 ?. z3 P2 a+ R+ R+ Yc) print out the lines that are the same
1 k' W) `0 L, O* u$ b; P( K8 o2 z. ed) count the number of lines compared / lines the same
# Y  L/ T$ P' [2 q  J+ wThe AuthorisedUsers class: (Total maximum 20 marks available)
6 ?- Z; k8 _, O# Q3 I" L. Q3. 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)
9 v7 X- P5 W. ^# e9 V$ Z$ R8 V3 N! G4. Provide methods to:* I( o6 V( A3 `+ J9 H: h+ x  k
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
. X- {% r1 J: p! Fb) return the name of the authorised user$ E. o  Y5 g; |
c) return the name of the department of the authorised user
9 _3 l" t. O& H# _/ m/ w% |; H/ KIndividual Data (Maximum 20 marks available)
: ?* U7 p9 J- c2 |6 C0 y5. 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.4 z( `4 H9 ?8 e
Documentation (Maximum 10 marks available)4 P! c. k* r5 q1 Q8 s
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.
/ r. K( F  n3 U- ~BSA104 Business Programming – 2007: Assignment 2
  O$ E$ K  s& d4 E/ a5 \/ ]3 G; ^0 QPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# h( L( B, r' C. S9 q9 t
不过你要翻JAVA的类库说明。你有下载没有?
$ {3 y& h3 T- @: Y' \9 d- {查询关于对比的函数。貌似关键字是contrast,还有compare; n* @" f' e! c3 y
; L! H, I4 R8 K! v2 S/ v, e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, f8 I7 r9 C& s, _# N8 `痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。& X3 l5 p0 ]5 S% @+ J. G
可以下载到的 是 jdk-1_X_0-doc( N7 ]$ `4 x  _4 w  @9 N' d

* a3 G; n- S6 r+ d" p! x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-29 06:00

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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