找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1602|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 $ M7 T3 z1 O% ~ h 5 q: \! G/ a% b
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//********************************************************************** i2 G: T. D& J& B& Z! L
//  ProgramCompare.java         Provided by: DRS
% }; H6 E/ v* Y1 ~, |* c- @//% u" S4 U3 i( [6 h& d, _
//  Program shell for Assignment 2- y( L8 f  F( l
//
/ i. Y4 \# P5 a& V: W6 B//  Compares two text files line by line
. v+ a. g- `) N//*********************************************************************
- C1 y8 x" z# M+ c/ o5 @, {* ]( w, q
import java.io.*;3 l) x3 h7 n$ v% K7 i* r
' W  m* ]  L' K$ P! k
public class ProgramCompare
0 c$ O! c1 U6 F& j- [{
, x- w+ q$ [5 R: A        //-----------------------------------------------------------------
2 ~* f4 {6 o1 \- U1 n        // Constructor
% V% k+ z  D5 I/ ]; c        //-----------------------------------------------------------------* z/ R8 w( h" w! t7 U. L; K
        public ProgramCompare()
5 K6 O' `; ?4 h4 @        {5 h+ i7 D) S$ @9 ]( m7 H' v( f
        }/ i( Y  Z* w" ^  t7 z

& O1 b! @3 ]- P; A        //-----------------------------------------------------------------. w3 u8 `; `" n$ A: o( H- i
        // Method for testing that class has been reached
1 B2 J2 _6 y$ f' _" }        //-----------------------------------------------------------------       
, h' ]5 _9 x  f1 L2 @; P5 i4 w5 ~3 ]6 u1 p7 T: q8 u7 s# j; h# I
        public boolean ProgramCompareReached()        
! ?7 W7 n8 ~9 E        {
- |; P/ z! v' _' K2 C0 _      try . P0 p9 @7 o* y
   {        
+ O! p# n' n5 U, O  ?                       
/ h6 l* I: q8 }3 P/ j) V5 V5 K' E7 X                //********************************************************************% m; t% [1 T; B8 [% d- ~6 f3 `
                // Try-Catch Statement is used to handle exceptions - such as file not found
* ?9 ^! o, R' C) f) T0 f! f                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  h. }5 i% V8 f; R                // For more information see page 534 of the textbook
1 M  d. \3 ?8 {  @                //********************************************************************- l" _2 m0 V& z
                    
) I: Z7 b+ y$ c, L( G) a0 o        }0 s* ^* e4 N, N5 h
             catch (Exception ex) // Exception caught here and message displayed to the screen
2 ~; \! Q$ X2 f/ l+ k          {
- r( }7 b9 _# V& H                    ex.printStackTrace (System.err);
9 y- Y5 d2 {4 U/ u. h  x, E9 f6 b           System.out.println ("Error message goes here"); // Replace this error message with your own         
6 U, r: Q9 _7 `8 w7 c& `        }
+ |- t1 K& G. _! F  B6 x1 v                return true;
& P& E, T+ M. s* v& p        }
, g4 ?! l" P2 ^; u% f9 w! W' R5 |( `. T0 [; y) W& N
} // end of class ProgramCompare8 r) L4 E, p' o0 \$ H0 N: B
* ?" N/ v3 b; G2 n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& N7 A; p1 y$ g$ {- C
//  ProgramCompareMenu.java    Provided by: DRS
% R( N+ |  W. q' L//' S# o/ H  l* ]+ {$ l3 K
//  Calls AuthorisedUsers.java and ProgramCompare.java$ B0 Y0 w. I# u+ ]
//
4 |( F1 J/ i$ \4 O//  Driver shell for Assignment 2.
7 G. ~7 s$ V( k( l  Q% I//********************************************************************! @9 i. D/ e9 P! J
+ q5 |; a8 ]4 R  E' U# z! i
class ProgramCompareMenu8 H1 J1 Z/ V; a2 W% @, @8 ?+ S
{, X( P8 S! i4 C) b
    public static void main (String[] args)0 Z7 d9 i, Y% t
            {
3 ^, }: J7 j! d) _& H  z/ ~                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 Q! X- D0 J! l
                ProgramCompare reached1 = new ProgramCompare(); + G) Y2 {1 h* L) z' C8 {, x  }$ n
                AuthorisedUsers reached2 = new AuthorisedUsers();        1 |. x; N* D3 T- v* |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# A' R- B3 F3 W* T& e' L
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  s3 H+ M9 G& L/ E- R7 a" p# m        }
( U5 o5 {/ X: ~+ i* R! [1 s}// end of class ProgramCompareMenu8 C; Z. M( u( B! j

, b) N8 s& ]( N9 A& S1 L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 a2 T; p  C4 m4 K0 a//          AuthorisedUsers.java          Provided by: DRS: h1 u$ A! }$ `% @6 q; c5 h
//               
& |' J( l" K) y//         Program shell for Assignment 2! s6 Z- k; U5 g6 H' d0 N: R
//1 t/ B+ q+ e4 b9 W6 |% _
//         Represents facts about an AuthorisedUser
" p- ?5 Z0 e& h% F//********************************************************************' R2 S; ]+ r- L$ j1 g( N
9 e) W" @4 W; U3 k5 J6 R
public class AuthorisedUsers3 t# y8 D& g! A3 ?1 N
    {2 e1 V& k4 K6 h

  j3 ]% V5 R7 \7 ]        //-----------------------------------------------------------------
3 E; z8 d3 K% U( v+ Y' J        // Constructor& @9 N* s1 P8 ?0 }6 f; [. @4 _& [
        //-----------------------------------------------------------------
2 M+ n+ n% Z2 O  y% W& y; ^  A* _% k4 W$ o* T
        public AuthorisedUsers()
8 c. `+ M5 b' W7 ~                {2 g# B2 F6 y9 R) Y3 j% ~
                }
3 ]. B  T1 o4 x
, N/ P# k- B8 l" r        //------------------------------------------------------------------ M7 `( C9 K' [2 R0 D* I7 O
        // Method for testing that class has been reached
, b! t, \# q/ V        //-----------------------------------------------------------------        ; Q! ]& |# l; q, a
        public boolean AuthorisedUsersReached()
' J" _# H0 U& |$ m# U( p  E8 e2 a( n                {2 q8 _/ x* r6 {# z0 m/ T1 p8 |
                        return true;                        $ M2 K# w+ q: V+ r; [
                }8 S* U+ x4 W) F* A" L
               
. }0 h( j0 u! z0 A% U# o    } // end of class AuthorisedUsers4 C) M- U9 x* n; `. r+ E: o" D( v6 e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming$ [, S8 j  F' c
Shanghai - 2007$ p* e1 T+ u& G5 s8 ?/ r( Z5 U
Assignment 2
  W6 M/ {# c! [( P* ^: XDeadline 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)
# t' [6 N6 I3 I- p* \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.
9 x0 A2 v8 R! u  E! H% ], O1 GThe staff must be able to:( `6 n# Y' r" ~7 [+ e
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" c2 q& p8 Z$ t+ N. T4 Z' e7 {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.$ A7 }: r4 {" [& P- M, A* P) u; [
 The interface should provide a menu so that the staff can:2 S% r* h* s% W( q2 H8 a. C
a) Enter the names of the two Java program files to be compared
4 C( G/ r3 F% G4 i$ O" a For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 p7 Y; ]- S) I- \$ B: A. m** 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).
- r: l+ q, A3 t+ XBSA104 Business Programming – 2007: Assignment 2, h% n: X  ~% G# S
Page 2 of 5
" P  \' `! P1 G0 m$ k' lb) Print out to the screen all the lines of code that are the same1 F$ @+ a" i4 y" Z* J% L9 N& y
 Include the name of the file and the line number of the code being printed for each of the two files. Z$ E  o/ n0 U7 C) P& X6 ]' F
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared8 [. Q, v9 e  ]. P9 ?
 the name, username and department of the user
1 ?+ N: P- x  u5 Z0 S+ p/ x the statistics of the comparison: L' `9 t" U  y) f& U
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" G+ Z1 M: ]1 x) L: f2 `
 the recommendation for further checking
8 v( M0 D/ O6 V8 T. n, P8 d' s- 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  o( ~5 y6 Z& T! l4 `; V
 the names of the two files compared
0 k" k8 Z0 _9 s; u  k. Kd) Leave the program (exit)
! m' c$ e9 A5 D; M' DThe ProgramCompare class: (Total maximum 20 marks available)
( ^' v2 W  F( c, x+ x+ r2. 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)
* m% h7 ?2 n- va) provide an error message if the files are not found or there is a problem opening them
  A. G" s# e. k. `5 j, e- a- {b) compare each line of code
( B% B5 a8 J+ C+ I" Z8 yc) print out the lines that are the same
8 \2 W* M9 s9 o  i1 {  @d) count the number of lines compared / lines the same" s: W% w8 q. d$ t3 K0 O7 G1 O
The AuthorisedUsers class: (Total maximum 20 marks available)
5 `' P5 F  v$ C5 j. d- M3. 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 ^9 k# J' G( C7 l- k4. Provide methods to:; V; d% L& K  d, o0 N; X
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
2 ^6 n( h& v6 }) p5 qb) return the name of the authorised user, _$ h7 i& _8 j! g3 j- R
c) return the name of the department of the authorised user3 R; v6 j" m# G' T( b# f7 Y6 k; S
Individual Data (Maximum 20 marks available)
7 c. a! z- M2 q# T% d5 S5 @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.
8 `3 E6 ?) H+ q4 L: Y6 f- NDocumentation (Maximum 10 marks available)
) d% X' g, O1 b6. 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.
2 C( W) p/ K7 l2 j; @BSA104 Business Programming – 2007: Assignment 23 v1 p8 s3 x: d
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. N) ?0 L/ ?# Q& I6 M! c& {
不过你要翻JAVA的类库说明。你有下载没有?
, j3 y; d, \4 \; G! z" W查询关于对比的函数。貌似关键字是contrast,还有compare
3 C- z# Q; t3 D2 M3 Y. j- {5 B$ Z7 L$ L5 }1 H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# l6 f$ @7 T+ X4 k0 S; v) }- [
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 `/ s# r% q; \" l可以下载到的 是 jdk-1_X_0-doc
. C$ {$ C8 g( |$ y# P2 i$ O- [9 [. ?6 l; T- h" X7 p7 Y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-4 22:54

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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