找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1188|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 C- k" S% X$ h% g M7 }" x 0 Y& Y' G$ l3 Q8 D
回复

使用道具 举报

 楼主| 发表于 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 S7 J+ k* _& D4 V1 p
//  ProgramCompare.java         Provided by: DRS5 M: K2 g. [+ j6 M) Y* u+ w7 H
//4 h4 O$ U, P) f
//  Program shell for Assignment 21 X3 J) e/ u/ }' s$ @5 l: ?
//+ d- K* ~3 Z9 O- Z1 s8 A  S% E  v
//  Compares two text files line by line
3 m4 ]! ?- u' s0 ?; K//*********************************************************************
' b$ ?3 R! R' z
9 g* h& x8 Y1 Y' d. \( }import java.io.*;
  o  g- d( {' g: ?+ B! B
$ C( L6 k0 F6 L/ |public class ProgramCompare
' _( H# t( u. O# G- q5 K{
- @- y5 `5 d$ ^& |; Y* i) e  r  I        //-----------------------------------------------------------------
  I( m- g7 M. {6 L9 Q! n        // Constructor
- {9 f! ]# k6 f        //-----------------------------------------------------------------# [. }5 R' l8 c, g
        public ProgramCompare()7 x" {$ `+ b0 u7 W8 ?2 `
        {0 J% n' z; M% d' w
        }
$ U) b8 V- S, K  \& k0 t! }5 `) g( v7 f" }
        //-----------------------------------------------------------------
1 {/ |, b3 T! T( Y        // Method for testing that class has been reached
3 u' f! C3 ?* W" i' Z        //-----------------------------------------------------------------        : {( m( \" ~. q
6 V+ f9 i! X4 Q
        public boolean ProgramCompareReached()         . ~& S5 C- z7 v" q. Z, v  L- f
        {- q3 v/ d% S* t5 k4 B6 W% ^
      try   ~. n9 f; Y8 |" W( S# ?+ F6 R
   {         5 S4 X4 l# ^: G/ X
                       
  s( `9 g; V$ L% p                //********************************************************************* o' D* @- ?5 R* `' y5 t; L2 ?
                // Try-Catch Statement is used to handle exceptions - such as file not found 2 z0 B0 y! Q( ?8 O$ Y2 B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) i& e. F8 ]( q' f, `# u! w                // For more information see page 534 of the textbook
# d# v5 o, _% _5 n                //********************************************************************& p( P7 q. p4 `/ Q9 x( M- w& n. u+ I
                     0 K/ z: D+ {" J: F
        }( }2 f# \3 F# {* x$ L  E
             catch (Exception ex) // Exception caught here and message displayed to the screen
9 Q9 O; O" {5 t          {& q/ S) q8 I+ e! w5 ^; u
                    ex.printStackTrace (System.err);; h8 J0 J* B1 H+ d
           System.out.println ("Error message goes here"); // Replace this error message with your own          $ P; L9 X7 \8 h7 E" T
        }- F. f, W% \( M. }
                return true;& B" K: w$ F0 J1 ?5 M
        }
2 C% A9 _9 E: |! f' W! H& H( E9 N* e- n/ W8 b8 Y, ?$ o+ z
} // end of class ProgramCompare0 t" w- k, n0 v, X6 U

$ k9 X9 L+ p& `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ t' v! R. E. R. D$ p
//  ProgramCompareMenu.java    Provided by: DRS
  [7 ~! {( K! E& d% M) g//
, |2 o% f$ P. E9 j# r+ @. A//  Calls AuthorisedUsers.java and ProgramCompare.java
9 M0 F3 N5 [; ^+ @//
/ }, G) S$ s: r' o' Q//  Driver shell for Assignment 2.* G: G0 K0 U$ `3 a
//********************************************************************7 F9 b  Z7 X7 C' h
) h5 ]6 f( Q  R! V& F$ w
class ProgramCompareMenu
- F4 V/ i. m8 q& M1 I7 `{
9 V* m% F: [8 d# l    public static void main (String[] args)9 J+ {- }8 S+ z% S
            {
( J/ q; `, U9 p: D6 m0 w* Z, f$ b. o                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& r6 ~  k3 s# p$ j- p                ProgramCompare reached1 = new ProgramCompare(); ( W4 n9 [5 q) J
                AuthorisedUsers reached2 = new AuthorisedUsers();        4 r$ A! _" H* V/ C4 b% o- Q
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());$ Q0 ^! }+ {5 s9 M
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , Y3 G8 ^8 U; Z& M( C
        }1 z' O) r6 `7 W9 k. X9 a# g$ N- h, R
}// end of class ProgramCompareMenu
. Z* i: o# Q* h2 x# @
$ r. L+ q" x4 H% ?) v4 S' _% }- t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" N/ |$ ]7 l0 |! m3 P4 v
//          AuthorisedUsers.java          Provided by: DRS
4 z' K2 s8 r! Z% L' ~. Z9 s//                0 n) {* l4 e+ i8 o& F# \
//         Program shell for Assignment 2
" r4 g& F* H* o//& ~! }( k0 M4 a9 e/ P
//         Represents facts about an AuthorisedUser
) Z4 o- v0 Z1 @! @/ [! f( I* A//********************************************************************% r7 G, P, b  ~! F1 t
7 F- a: i/ |5 M, L1 \
public class AuthorisedUsers
# ^: `- z. |! K, N: A    {) V6 o/ z! D1 Y
$ y) e$ q: }( f3 o& Y$ I& X
        //-----------------------------------------------------------------. i: |! [% H: m8 n( |
        // Constructor+ G7 T/ P3 E8 ~/ h: R2 l9 d5 Z1 r6 N" Z
        //-----------------------------------------------------------------
; U, m5 W& T8 m' `  \; z2 m1 r; ]+ L, ?0 R3 e% A9 L4 \
        public AuthorisedUsers()$ w! p! R* |! U: G7 o1 m7 p
                {
/ M* |+ B' C  x4 [+ F2 A                }
  S  Q( v% w# g! L, V, O& Z8 z7 J- N0 R" p! D7 B# P3 [; ~2 X( R; @, i/ Y
        //-----------------------------------------------------------------
0 J! |! M7 {( ?& E$ Y        // Method for testing that class has been reached8 v2 x& `& _$ o- p; M) G8 x
        //-----------------------------------------------------------------        $ H6 b8 ]+ P( N3 V
        public boolean AuthorisedUsersReached()
7 K) A0 X9 I- ]: a' O                {! s# o9 m; j2 k
                        return true;                       
+ m) z+ m1 s& f1 a+ ?" ?- A                }4 v1 s& q" E/ r& \& V
                ( r! |2 b5 W& J" O: a0 S4 W
    } // end of class AuthorisedUsers0 q! P2 H) ]. b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: L) N& v7 I% \* b# B
Shanghai - 2007: J0 P" ^! Q7 @1 ?9 s1 h$ I# c
Assignment 2
4 ~  a* N8 ?" u" \9 GDeadline 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)
5 i- X% `6 i" y4 D1. 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.
+ j4 A2 l; e7 K& D+ B3 oThe staff must be able to:! x5 i1 }# l& t/ h8 \$ R$ i& O
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.; \, G  W4 ~( b  |# y3 W( l+ L& w' A
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 u1 A* H9 I5 a The interface should provide a menu so that the staff can:
2 e- y* @( N& a2 J2 F0 c* da) Enter the names of the two Java program files to be compared! k7 p/ q+ f; Z3 s# ~
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 @" M9 J/ Z3 i  X( u' L8 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).
. b; |- r0 ?9 v$ \. bBSA104 Business Programming – 2007: Assignment 29 K$ Z) U6 i8 S3 \. a: x
Page 2 of 5$ t9 Z) m/ l( H) s
b) Print out to the screen all the lines of code that are the same
: k: u/ Y' G8 \7 b; q) k! C Include the name of the file and the line number of the code being printed for each of the two files
8 b- b$ C4 }7 Q7 V( Rc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared8 d  W9 `* k& @- z8 ]3 ]2 I4 ~) D. z
 the name, username and department of the user; y6 e" m" e$ q, ^8 A; `  I: K
 the statistics of the comparison
1 F! S' B( c9 v3 O& G8 x! `& H- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( x- H% ~( S1 M, x the recommendation for further checking
0 p6 ]/ K+ N: m- 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
& `+ R3 `' {% T9 p9 w the names of the two files compared8 e0 y, r0 I( B
d) Leave the program (exit)/ z2 Z! c6 T, g! t7 I( U/ k$ i: G& c
The ProgramCompare class: (Total maximum 20 marks available)$ V. |. h- j+ ?- A. a
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)6 P9 Z( d7 f. k1 [) x, G
a) provide an error message if the files are not found or there is a problem opening them
( z+ a$ K0 F$ a+ _" Kb) compare each line of code8 o: I" w- W  Y# t) p* `
c) print out the lines that are the same
& ^7 `6 B0 @7 ~5 nd) count the number of lines compared / lines the same( Y. g" w( _5 ]% C( c& p
The AuthorisedUsers class: (Total maximum 20 marks available)
% t! e& B0 I# G# m% D7 j3. 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 A/ l" `2 {9 E* P/ u$ o% L4. Provide methods to:
7 E, W+ `; @* v8 T6 Y+ o8 Y0 D2 xa) 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
8 q$ b( x5 N$ A- u6 H8 S* ^* Mb) return the name of the authorised user
* A  ^( @- o' l& a- U8 j& Lc) return the name of the department of the authorised user
+ z4 K0 U9 Q1 oIndividual Data (Maximum 20 marks available). e% C' c2 \# Q3 H0 i
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.% m, v+ c9 T2 k6 Z4 Q. @6 j
Documentation (Maximum 10 marks available)
7 ]6 {6 e" Z3 W8 E" {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.
/ ]6 m, b8 }' A% aBSA104 Business Programming – 2007: Assignment 2/ l5 U6 Q6 b% }$ f2 u
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: |. Y  m/ i- v
不过你要翻JAVA的类库说明。你有下载没有?( K6 S. V7 T0 ^# c
查询关于对比的函数。貌似关键字是contrast,还有compare. U" H! I' K( m  o. w/ t/ X# h
7 ?2 T* r* G6 D  V, C2 n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 u% H  \0 `4 K; H( R
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 \9 ~+ m3 L  V6 l% ]可以下载到的 是 jdk-1_X_0-doc
; N9 z0 e; p! s% ~  E$ U7 q' D, \6 z& G- X# i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-12 00:58

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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