找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1596|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 }! B8 V1 {$ l& F# K; G" c" H7 b8 ^- R; Q1 y5 C6 E+ z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' ?# h" K; V4 @
//  ProgramCompare.java         Provided by: DRS+ v2 F9 j( F  G  ~. h3 K1 u
//
* Q, I2 f( j, z* U- D( K//  Program shell for Assignment 2
7 ?4 `9 @& x* R+ o9 e, I/ E* Y//
& l; O8 {- C0 [8 l//  Compares two text files line by line1 k' r5 a' R$ ]* L! }
//********************************************************************** _2 U2 R0 `+ t3 P6 F

" S, B! C0 h. ^2 S! ]4 G+ Oimport java.io.*;2 r9 j" R/ b" G3 s$ H
" t# e: f2 G' n/ h/ ]/ e. i
public class ProgramCompare$ n0 j* F3 k+ c/ n
{
/ m7 x5 O: ]9 ?( G+ t        //-----------------------------------------------------------------
0 U+ A/ n  }! T; c! u        // Constructor
' s1 [: C; i2 G- Y9 Y, J& g        //-----------------------------------------------------------------6 P% D* ^% }( ^. D; c1 F( X5 b, U- @
        public ProgramCompare()
, q9 C* ?, b! v; m( W# V/ ]        {$ `6 i5 q) v+ ~; V" i# \. k5 L
        }
! a# Z; g5 W2 N1 l( |' |% b) O' J8 L. ^' x3 P3 Y- V% ?; C7 d, z0 d
        //-----------------------------------------------------------------3 Y* m- m( ]$ L/ c, d
        // Method for testing that class has been reached
; a- w/ e/ x, G        //-----------------------------------------------------------------       
" w, Z6 n% j" R9 k7 S+ o. I: e* `" ]! U, s* p& {
        public boolean ProgramCompareReached()         : K9 U6 J; A+ G  J  \+ t
        {
& b% t, t0 c) ^* j9 z: B      try   w: Z0 n/ H2 x1 g! G, ?
   {         2 s' C  W. U, W4 v. R
                       
. W$ o* C. o* s- v$ M' P                //********************************************************************- I. M$ ~7 y: S! @; n( P/ r
                // Try-Catch Statement is used to handle exceptions - such as file not found ) Q2 m1 W% J# n# f
                // Reading the files will need to be placed inside a Try-Catch - just like this one!* l& v! c  x: l) G1 v) d$ {
                // For more information see page 534 of the textbook
1 c4 |( \0 D# v  _: s                //********************************************************************
8 O1 M1 I: B0 c9 k% W) I3 R. P9 u                    
. B) I. T# g6 R$ K( \        }6 u4 q3 [% o2 f" C
             catch (Exception ex) // Exception caught here and message displayed to the screen , H" X' }( X- x$ \0 J4 A# ^
          {
$ R, |/ h" A4 I9 o, C+ i9 n( q                    ex.printStackTrace (System.err);( \2 p5 }* H6 `# {$ P" s
           System.out.println ("Error message goes here"); // Replace this error message with your own            F" D" @6 r. g+ z
        }
- h5 }$ K9 r, v# T) J( b* Q/ o2 k2 O                return true;+ {2 a$ [# b8 v. f
        }
0 J) |5 Y$ O/ k; B7 y/ E
0 c! q1 y6 ^1 i7 H} // end of class ProgramCompare
$ v, ]. M' S* _: j7 o9 P, n, y3 h
2 }: s1 d, e3 s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
5 `$ ?& L6 ]+ p- `0 ?" I+ _//  ProgramCompareMenu.java    Provided by: DRS
. b! m8 F/ U6 J* j* q! M8 Y) i//
8 [' s5 p' m. U//  Calls AuthorisedUsers.java and ProgramCompare.java
: S0 ]/ P7 E8 V& c6 ]2 l0 ?//2 \) c  _5 y. [# R& F
//  Driver shell for Assignment 2.
2 a% E/ J/ Q5 i  x9 g6 m! a) n//********************************************************************
4 {& e: Y7 j" n, ^) u
3 J( X8 D7 O9 d- E0 sclass ProgramCompareMenu
# S. X* B* j- n$ \# Q9 i7 B9 T: [{0 `6 J' v# Y6 q; s6 x1 o
    public static void main (String[] args): }: n( z. s4 f. m8 }$ ]' {
            {
! a& V' y! G6 s& X9 a. S                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 I/ D, {( o) [3 @/ v- |                ProgramCompare reached1 = new ProgramCompare(); 6 v5 G- p" M: B/ k
                AuthorisedUsers reached2 = new AuthorisedUsers();        , J  W- I: S5 @* ?
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 F6 O. q# {4 H2 ]                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + ?2 s. T. d; n  {. a1 x
        }5 R& [8 _+ X5 H2 h7 G9 q
}// end of class ProgramCompareMenu
5 a$ x8 ^+ k. N& m8 g* ^) \# S2 P/ F4 `% l: M0 {+ J) E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
( Y, K6 }2 e7 X+ `1 g! @! C- ~2 H1 {//          AuthorisedUsers.java          Provided by: DRS
8 p+ s4 C4 U6 \: t5 m//                * S9 u1 |  H/ `6 }, ~! q
//         Program shell for Assignment 2( [- T4 ^8 M/ Z2 v$ t4 F. }
//
1 }1 A$ L! M! J//         Represents facts about an AuthorisedUser
2 _4 N) l2 U! v2 E  l, S//********************************************************************
3 p! `7 \; |" z) {; g) o& Y' s4 r# C5 K) P  m) K" s4 S
public class AuthorisedUsers9 H5 i/ Y/ [( Z3 r1 \0 J5 x9 w
    {
. S% P- R0 r+ _7 a
, @7 T6 y8 L/ T' f3 {" U  n1 Z1 N        //-----------------------------------------------------------------' ]2 k8 Y! d. |* K- {
        // Constructor4 A$ B* A8 W/ d; Z) n+ Z! I. A
        //-----------------------------------------------------------------$ [# |9 m% W5 B  t/ z- j  o
& }; `8 J; s5 N! M5 }
        public AuthorisedUsers()* c9 ?5 [  m* w
                {7 e$ C/ Y% Y" o. Q2 f
                }
7 S) @7 U' [" `5 Z) k6 v
9 R5 l) B+ o# @% O1 }        //-----------------------------------------------------------------6 p+ j! @" C! R' H  f3 ^
        // Method for testing that class has been reached4 p% {8 q) }# F. d2 @3 M4 ]' D! d
        //-----------------------------------------------------------------        " T" c0 M+ Q7 U
        public boolean AuthorisedUsersReached()
9 r8 h3 t" W, z* L3 Q: w                {
$ u: R7 L1 M9 [, l6 d0 q' Z                        return true;                       
9 d+ A/ B- E' p7 o                }
& |8 \. I6 C7 N) ~# D" {  v                ! V+ y) ]7 q; F2 T0 S
    } // end of class AuthorisedUsers9 ~: N/ @0 ?( r1 ^( z5 p( B
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming6 w5 c2 o  Z: K2 z" Z3 I
Shanghai - 2007% h) r" P& K' j# S
Assignment 2
+ s) v2 v3 S. O# E4 g+ `$ a* D% kDeadline 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). f- e- }2 M1 p! u7 o' q
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.- q, ]& N5 e& B, f2 t
The staff must be able to:0 H* G6 s, \6 k8 l- N
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 \+ O+ f2 I: z6 c  S1. 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.4 F5 E# J3 ~+ p5 o* \9 t8 f
 The interface should provide a menu so that the staff can:/ p2 s% n9 G: `- I- @) Y
a) Enter the names of the two Java program files to be compared
, i. O5 G8 c  e3 S& y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
% m+ n" l; X- c: C8 s  P** 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).
: i: t% x, L/ IBSA104 Business Programming – 2007: Assignment 2
( ?+ C$ [* P! @: s+ v7 p# H# ?Page 2 of 5
" |  l2 d) u: d% ]b) Print out to the screen all the lines of code that are the same
$ w/ s! g6 E! x Include the name of the file and the line number of the code being printed for each of the two files# s4 K  E# Y5 B% p
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; o1 a0 I# j& V) N# D
 the name, username and department of the user
) }1 {5 Z7 x1 W$ t$ k the statistics of the comparison4 X9 n  J, @3 x2 ^$ F
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 f' ^; M& s: {1 i# p, q the recommendation for further checking
* y% v) p0 ?# r1 Q- 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 closely2 ]7 S2 g! E0 z  r
 the names of the two files compared- L1 d! s# r9 I8 [
d) Leave the program (exit)
) K5 i+ H5 D' T8 Z; Q+ o3 f$ @  {( ^The ProgramCompare class: (Total maximum 20 marks available)& ~9 E7 O" M5 Y9 u5 V
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), X( R3 Z! d* o( k9 `' @0 _$ v$ Y
a) provide an error message if the files are not found or there is a problem opening them
2 {& j! G, h& V5 m" z* Xb) compare each line of code
' L; M* g- T3 |  r; P2 u; lc) print out the lines that are the same
" G0 [# W4 m" R% ^* C, |d) count the number of lines compared / lines the same' g. f4 ^4 ^$ R4 U. [. R
The AuthorisedUsers class: (Total maximum 20 marks available)$ a" h' _7 B& P* {, F, y
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), f# l0 o/ |$ O' \" o2 d
4. Provide methods to:& H& l9 e" _6 b; Q6 k6 g" s8 K1 V
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! Y5 N0 E/ i) K$ C* ~
b) return the name of the authorised user- c. o5 q3 O8 ~
c) return the name of the department of the authorised user
. l. p$ f7 T& ~4 a" ^Individual Data (Maximum 20 marks available)" G  ^( f; @* @! U2 J7 ^+ c) z: U' ^
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.
) Y8 f( C& ]( yDocumentation (Maximum 10 marks available)
# @5 N8 M4 L2 w# V6. 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." x) K! n, X/ ]2 X8 v* ]
BSA104 Business Programming – 2007: Assignment 2
" g5 T$ u9 `4 p- Z7 PPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ l" u& c& C8 ]/ S* D+ X不过你要翻JAVA的类库说明。你有下载没有?
7 k4 h* O9 |. o* e- P0 [查询关于对比的函数。貌似关键字是contrast,还有compare
; u$ p/ r  R' j6 A/ y& `. E- J2 a" m7 g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, N: W. q% l( N! Q2 X痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。" s+ _; U7 M8 _! n
可以下载到的 是 jdk-1_X_0-doc
( H7 O4 G+ L8 \' r+ L( U+ K6 t$ ~5 ?- h9 ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-2 18:51

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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