找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1709|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 x2 E" u- k4 }( j- [, l" r3 @% m! i* u) L
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
7 Y/ f2 m4 ?" p' q4 M/ L) }# c//  ProgramCompare.java         Provided by: DRS
) ]& |7 A* V5 c( J1 N" ~6 C//% C! y  A0 B! o
//  Program shell for Assignment 2) s* d2 ^5 k) f* M7 s
//* Q+ ]  K& q) g* u6 b8 w+ L
//  Compares two text files line by line6 ]( p* N5 F0 h! h! n/ g
//*********************************************************************( R3 d$ K: L2 G1 m

. A4 Y- T8 X8 v7 Z8 ~+ eimport java.io.*;7 m) K" n2 I; n7 h
, K- {9 m- b' W1 c" o
public class ProgramCompare: P% F% r, a: E6 Y, F
{7 Q. j2 T: b4 T0 `  Q
        //-----------------------------------------------------------------' m+ n0 J9 x' G- W; U1 k: M
        // Constructor
  r& x" M" @7 R: w7 V0 D* T( w        //-----------------------------------------------------------------
$ r, k6 P# v: o8 T        public ProgramCompare()" F; f2 w0 S/ c8 E, r: |# f
        {5 Z) g$ _+ Z$ u! s
        }
" W" o* k. E: Y& r+ Y5 |
! C. H; O* q1 O+ y        //-----------------------------------------------------------------
5 h) P5 i5 ^% P8 O& b+ i+ h        // Method for testing that class has been reached
# X7 k6 u1 L. g& F7 f! V        //-----------------------------------------------------------------       
  f6 z' S4 j, e+ _9 O5 k; j1 ^2 V7 A1 r  Z6 L; f. X, S
        public boolean ProgramCompareReached()        
1 a, Z8 U( Y  B# r: n2 o9 z        {
/ q1 Z' l1 M2 F      try . [' p1 y, c  ~. h8 a6 _3 M7 B: \' W
   {        
$ J5 f. y# r/ W6 g# x- ]7 t                       
! @! B2 N0 I4 Y                //********************************************************************- o  O7 M& I& G
                // Try-Catch Statement is used to handle exceptions - such as file not found
" C- V( K# R* |" p' j                // Reading the files will need to be placed inside a Try-Catch - just like this one!
5 A1 L: g; G! }4 D                // For more information see page 534 of the textbook
% U$ r0 M; t( G' R9 [4 o0 B: h                //********************************************************************
7 N' o+ l* Y8 t5 e3 Y: a                    
/ ?2 Y, s: L% W0 s4 P% ^& J( C" A9 X. v        }
. Y9 d7 `( |* L7 w$ x" ?9 e+ F$ b$ l             catch (Exception ex) // Exception caught here and message displayed to the screen & T8 w/ v! n( q2 {7 x; o: |
          {! U$ M4 z& |6 N# ]- q. [
                    ex.printStackTrace (System.err);
' R5 ~# D( L8 ?+ d1 P; c$ j  ]& c0 C           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 p+ M( ^  s; C8 |# R8 s        }; L/ X1 F9 E/ F7 t
                return true;
8 C5 K" `7 D# v( m4 \# y. F2 }# T( c        }1 p9 e& b1 S& B  U0 b
# D. b" r& p$ W* g) G2 `
} // end of class ProgramCompare
. w6 g2 W) k, G: n1 @: J4 G* e+ [  }8 s: q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) `5 W$ E8 o% j6 y
//  ProgramCompareMenu.java    Provided by: DRS
  s( [5 i1 `4 c3 n2 X8 k//
; y  q& q! I% Z; {  l; {; Y//  Calls AuthorisedUsers.java and ProgramCompare.java
. q' n7 b- e) [/ u( Q& o//
* G! O3 _0 z# J3 I, A' B# _: }5 k& z//  Driver shell for Assignment 2.
) t- S+ ?2 x$ S* ^7 `9 F//********************************************************************
! Y  A+ V$ r1 _! w# P( \& {2 N% g
+ L, V1 m  m& h" ]) Fclass ProgramCompareMenu$ o, z( ^! A  \8 R8 P$ H
{
( X; ~" H, s/ q0 q2 {8 p    public static void main (String[] args)
) p$ _6 Q  s3 Z4 ^8 b9 E            {
2 {* T, q3 J( i2 j$ O: u. S' k                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 K% ^& W+ }% }: l# P
                ProgramCompare reached1 = new ProgramCompare(); 1 ~2 c& U# y( E/ o) s; b* l3 [
                AuthorisedUsers reached2 = new AuthorisedUsers();        / v+ ^( Q: z1 F9 X. Q3 O, |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 B5 W' L- H7 t! \4 j
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 d* w- P# I/ g  E- x9 k: p. c( x        }& e5 ?* K! n+ A
}// end of class ProgramCompareMenu: @8 v; ~! P1 L3 a

/ N/ x$ T9 P6 T( r# F& @) i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************0 y' J$ ?" g$ H4 q8 G; i3 |+ E- O
//          AuthorisedUsers.java          Provided by: DRS5 W5 W- U' s' W6 g6 B+ D
//                4 X6 S+ F$ P1 r8 g& D
//         Program shell for Assignment 2  _* s( \$ U2 Q4 p
//$ ?5 p7 |& w; r7 Q. }# p6 W2 ]$ S6 |
//         Represents facts about an AuthorisedUser7 x) {) E( u! ~* `( ]
//********************************************************************
* f" |1 A/ {3 {, E7 \4 E* x% O5 B  ]' [0 x& M! P! W
public class AuthorisedUsers
8 n" @, D/ D& i  M) @    {+ N: d! x! n' o
4 W: c9 }6 E7 H. O, v( O
        //-----------------------------------------------------------------/ }( W4 o$ Z7 p8 P
        // Constructor
- }3 Y* ^) h- Z4 z3 E; k        //-----------------------------------------------------------------
+ I3 s7 {2 e8 Q" ?; h! W) I' O' {# w6 e# R
        public AuthorisedUsers()
- g5 @% X: t& L1 D% h  ^                {  D+ k' {( V; }0 p  ~
                }
6 X  {$ j8 M( s7 ~/ J5 b5 w& _
; {! W6 F8 _2 ?( e% ]+ ?& W        //-----------------------------------------------------------------% ?) l- u( h$ A7 I5 |
        // Method for testing that class has been reached
; ?4 ~% v: W7 q1 s$ n        //-----------------------------------------------------------------       
& d9 w1 C! ]7 v! T- `        public boolean AuthorisedUsersReached()
! e. D" G( y% F0 N5 c0 U                {& t7 u2 p4 U$ b* M5 c  F9 c4 G
                        return true;                       
* I7 S, d! D7 L8 ]& f4 a5 J: v                }& v$ j: l6 o3 L* Y4 W0 H7 n
               
4 W" o  n% W. a  V/ e- M9 w    } // end of class AuthorisedUsers
: o& f- H9 B: c. f8 }& S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! u/ `; Q) h# _& A+ i
Shanghai - 2007+ d2 g" W8 T4 z' W
Assignment 2
3 f7 j) [7 R3 j% WDeadline 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); m* C& f: x% l9 ^+ y
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.; l& m+ w2 `& h7 ~# t/ D  h$ Z0 e
The staff must be able to:* g- {% ]% `: w2 r7 X) B
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% z& t0 A( f& J2 B9 J2 |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.) w/ ~2 E, R4 N5 L+ ]7 m& y' _
 The interface should provide a menu so that the staff can:
5 `( t2 e! K% Q, s2 r/ O2 ea) Enter the names of the two Java program files to be compared
  U, m4 ^, N. g! A. P  z& y0 @ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! a  l5 h4 ?, I0 f
** 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).: `4 }5 X0 K8 v/ [
BSA104 Business Programming – 2007: Assignment 2" h( f5 z$ E2 ^1 s) P+ b6 B' `: M: h
Page 2 of 5
& ?* K3 I8 \5 qb) Print out to the screen all the lines of code that are the same
4 b. M0 _# k+ J% P Include the name of the file and the line number of the code being printed for each of the two files. B+ ~, R9 I7 l' S2 J9 Z9 }$ B
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 y7 ]7 P% S3 G( t
 the name, username and department of the user6 E  W7 L# h/ l( i- Q5 A( r
 the statistics of the comparison' z7 w0 ~1 q% _5 B
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different5 X- T: e% w6 R) \9 I6 @
 the recommendation for further checking
/ ?. ]  ^" I2 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 closely: E- R: M9 g& e8 y
 the names of the two files compared
6 ~1 x* K3 S6 Wd) Leave the program (exit)
! t' y2 u/ ]4 A+ gThe ProgramCompare class: (Total maximum 20 marks available)
+ W" }* f2 W, A6 k* j6 Y2. 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)
+ F; ?  D2 [" e- i) T; g: la) provide an error message if the files are not found or there is a problem opening them
3 V) Q) s# L0 V" V+ ~# B( H6 Xb) compare each line of code6 r% G% D& n  s7 T: g3 w/ i+ J  r' p
c) print out the lines that are the same
- {; ~; {3 v6 P+ q; r) N$ H  m2 vd) count the number of lines compared / lines the same6 ^: c) C; e: `8 M# Z$ Q
The AuthorisedUsers class: (Total maximum 20 marks available)
# D) L# @* y( Q( k% E; L- y3. 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)
, r: T2 y. s; W/ F2 z+ X4. Provide methods to:
2 c6 j( F1 @! I  S* L3 la) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match1 o( j! s& T( z
b) return the name of the authorised user
% O8 F8 a- a. A' y) p- j6 B- e0 jc) return the name of the department of the authorised user
  Y( \+ u# |1 ?* yIndividual Data (Maximum 20 marks available): A$ G  }6 o# ~
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.. K% d' L! t8 L  E  O
Documentation (Maximum 10 marks available)3 q7 M! {* z0 M. S6 r" k
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.
+ l3 P; T; ~; T  ?& ^6 V: qBSA104 Business Programming – 2007: Assignment 2
8 n# t2 |4 i, ~! `+ _1 t4 OPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 ]6 C# j8 o1 S不过你要翻JAVA的类库说明。你有下载没有?# ^3 Q" O2 S0 }
查询关于对比的函数。貌似关键字是contrast,还有compare" h# y9 V$ D% N' n0 a
* m7 m& D* _$ v
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 m4 y" J# o0 Y# @* a. v# a% D: s  P痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% \: Z. \$ F3 E6 j, I6 _6 J
可以下载到的 是 jdk-1_X_0-doc
! t3 J2 @! \+ p( `& k& R
5 G+ \9 E  g2 K; r[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-7 16:26

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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