找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1470|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 N, b- q; J7 k r$ q % u: M- _* q5 p$ m; b4 t+ X
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& m7 E3 R6 _9 |2 Z7 q* n2 `9 V
//  ProgramCompare.java         Provided by: DRS. D% a8 d8 t- g& A
//2 O( H0 w+ g6 w. c4 G2 Q5 v& m  v: @
//  Program shell for Assignment 2! {: R) O5 M" Y! [" _  W% t2 L( N
//) h" }' ]6 V) ~  @/ _
//  Compares two text files line by line
! A7 b) O/ N2 ~- Z! @//*********************************************************************
+ j, R. `. O8 M' V! h) ~$ @7 R: S8 _1 E! c! N
import java.io.*;7 W: ]: _2 c; V( T; h7 s
# D; j/ i+ v2 q8 p9 s+ R2 _/ r
public class ProgramCompare1 E9 o4 c: ^2 |+ y; y4 u/ _3 {
{
$ D$ H2 c- I/ w3 i- Z        //-----------------------------------------------------------------
: `& ^0 N- l  _6 v# ?6 L. }, _        // Constructor1 b! s+ i) a: Y! s* R
        //-----------------------------------------------------------------
. v" r: l3 M/ k# W        public ProgramCompare()
. k( \* r: |1 _4 r! _) C        {' R) L- u3 g* G) D* h3 M1 A
        }7 l2 o& W" k( Y" u% [/ t9 Y; _

+ j' _2 i0 B; ?* [        //-----------------------------------------------------------------
( I9 c6 B1 K+ e( a        // Method for testing that class has been reached! T; ]) m0 A/ N. v) J/ J
        //-----------------------------------------------------------------        + c) ^, t! X& a% S8 T0 h* d8 E
9 j: N5 F  G4 @$ E0 s$ g4 H. K
        public boolean ProgramCompareReached()         + `  P. d0 G. P  _
        {; w+ ]) L$ s* A& H9 C+ r' Y* d
      try 5 t! o" D6 v5 i8 `# g
   {        
. U! v. O9 |+ ^( D1 I+ H6 _9 o( O3 j                        7 X0 y' c' Z! r
                //********************************************************************
( `. _" X3 }' }0 M% s: k9 h) ?                // Try-Catch Statement is used to handle exceptions - such as file not found
, x) T6 V* U2 R: J; h  M                // Reading the files will need to be placed inside a Try-Catch - just like this one!
& D! @/ \( v* [. k$ a# f3 S  y$ u                // For more information see page 534 of the textbook
! W* D, I3 n1 g+ f4 C& Z. F1 f+ p4 q                //********************************************************************
+ v$ U2 Q* ^( h! u0 l                    
, X# l/ A% p( U- l        }
: L' n" E3 p2 y  u( P             catch (Exception ex) // Exception caught here and message displayed to the screen 0 O$ F. u5 D1 C  u; d4 Z
          {4 q1 O5 N/ z8 I  L
                    ex.printStackTrace (System.err);
: e: k- Q0 D5 \! G( ~% }           System.out.println ("Error message goes here"); // Replace this error message with your own         
  Z* u$ E# L! H0 F( J( e# i: T3 o        }2 V, [' p4 O! l/ A6 ~+ h# t
                return true;
* p. u$ X" u2 ^( K        }* \5 h7 \# Q; x! K* Q) k. u

. H  V. e# H2 O} // end of class ProgramCompare
  E8 S5 ~) u' C: U  {1 d' Y) t" ^  @4 X0 C6 ]) |( f5 f, j: z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- e1 \: Z8 Z3 s( `//  ProgramCompareMenu.java    Provided by: DRS
- }, S0 v4 H0 Q//; E- |% o' _/ j! x5 }' h
//  Calls AuthorisedUsers.java and ProgramCompare.java" l; j/ C& z* a! S5 m' a& q
//
6 u4 q2 W! s! |! X3 T//  Driver shell for Assignment 2./ A* \) d8 U( L% s9 Q, B0 }
//********************************************************************2 B# _4 x* V  V# T4 j& ^: E. k
* T8 ^: |5 O: b& L4 Q. h
class ProgramCompareMenu
1 r- P6 M0 B( ~/ L0 E{
6 z; M& ]1 `1 [$ \    public static void main (String[] args)3 `% ^  d. K  Q& f5 S
            {
  M0 B9 a2 b9 T, o+ p5 ^. b  \                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 S/ J* {4 {3 n2 d2 H% c% `
                ProgramCompare reached1 = new ProgramCompare();
, u; I* ?# @: l# W4 j' t2 ^5 ^                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ e3 Q" K& N$ [# a                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 h4 \- c- i& t: O
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 \" k. Z* u1 Q0 U# s! N6 d! {        }4 v$ _% ?4 w9 g( V) r$ b; C7 O
}// end of class ProgramCompareMenu8 ~% \+ q& _6 g# i) |8 s
$ ~# a; C- x. h" u, E6 t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, s! U, }8 @% O4 e  K//          AuthorisedUsers.java          Provided by: DRS6 ]& N* H# ]0 j9 b( r
//                ; i3 Z7 v, J6 J" v0 r6 x
//         Program shell for Assignment 2  b3 R" _* U" B4 L# h
//
$ o- y4 B; b$ S2 w' k: r- r9 N* Z//         Represents facts about an AuthorisedUser1 M) U  t4 B; F. q
//********************************************************************/ p9 U0 i; C. G8 |% l

# T) I5 n3 r7 N, _- j/ {* H3 Apublic class AuthorisedUsers
4 d0 d8 Z* K" l: G; F    {2 i9 ^0 p* H& c4 `( A

2 E2 D/ @5 x( Y) ]  ]1 [0 l        //-----------------------------------------------------------------4 R/ ^2 F+ B+ A; F
        // Constructor
. ^4 Y7 L5 v7 z* \2 S  C        //-----------------------------------------------------------------
/ j$ L- }( A* a6 y0 B6 w0 h3 V! R# j! a  {4 V& R5 y4 r" w5 e& f
        public AuthorisedUsers(). v" e! Y: R8 }) S
                {' S! f. z5 f: K: M3 ]4 @
                }
6 p% `9 v- e% \
4 F2 E' u! a5 J* M8 K+ W  u1 Y: R        //-----------------------------------------------------------------* t4 _4 m9 H; e! ~3 i0 @8 o/ m" q
        // Method for testing that class has been reached: J. G5 B# k& P8 h3 C
        //-----------------------------------------------------------------       
' Y7 p# z9 _7 O$ o' V& ^        public boolean AuthorisedUsersReached()
( F% ]$ O2 r. _5 b5 P+ M5 z                {0 A/ Y0 R0 W0 Q) e
                        return true;                       
  g3 I/ l1 K  g* |8 [                }
) o5 R4 s8 v  K8 U                9 {7 ?% e1 y, V
    } // end of class AuthorisedUsers
! }- I# G; H5 ]6 B' Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
- H( N7 M" i8 p5 JShanghai - 2007* g0 R7 c0 \6 m& G
Assignment 2
2 E2 q: z8 p7 Q+ ~( b- 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)+ W* n1 J3 L' b  b" ~& n
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.
$ b5 q* I& Q7 l; hThe staff must be able to:
* p( w& r) L( `# p! R0 K Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
; @  _: S. Q4 d3 N$ D1. 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.% X* m6 _2 i/ N! ?
 The interface should provide a menu so that the staff can:
3 v2 J) {! I- S& pa) Enter the names of the two Java program files to be compared) b$ C( ^/ \1 f5 {
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.+ z$ F+ n' n% W
** 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).+ I5 M  U  ]5 m  u3 O! T
BSA104 Business Programming – 2007: Assignment 2
, p5 y7 @( ~' Q0 O& n& H. fPage 2 of 5
( z: H1 a9 t. {2 W& kb) Print out to the screen all the lines of code that are the same$ y4 |+ t4 r, N1 \2 |
 Include the name of the file and the line number of the code being printed for each of the two files
8 G# i6 x* H4 V% }0 y" fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 C* ]% \& m4 Z) @  D( `8 T' s) r3 { the name, username and department of the user
. o0 K( P+ C4 X the statistics of the comparison. a- A( H- \" i8 p! G
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
; N0 E; u+ F" A- C/ E the recommendation for further checking
2 I: j7 h) S- ?) B- 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; c# V. p) u. P/ N$ D
 the names of the two files compared8 s0 B/ {+ e6 q0 B+ f" g
d) Leave the program (exit)9 Y2 Z. c, ^& @5 v' |* p3 o7 y
The ProgramCompare class: (Total maximum 20 marks available)% r1 X; O5 K6 Q1 ^6 S
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)
$ ?* A7 G: w6 B8 b/ C! Ea) provide an error message if the files are not found or there is a problem opening them8 ], f" |. x/ s5 n8 \' O0 g
b) compare each line of code' N7 C# `- i, W3 d& C+ p
c) print out the lines that are the same
) ]3 d/ Q! M& a% w$ _" Cd) count the number of lines compared / lines the same
! S/ S/ ~6 q% P/ E+ x5 L" VThe AuthorisedUsers class: (Total maximum 20 marks available)( J6 Z+ ?: n: w) a
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)
) c7 J2 K9 _3 E, H: D3 k, L0 K1 y) E4. Provide methods to:  n( f( F! V0 S& ?) n
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 match5 e' w5 |3 d  ~8 Z1 z' O
b) return the name of the authorised user
, G8 h$ c& S2 p2 T- h# t( Yc) return the name of the department of the authorised user" S% S3 {+ v4 k! g+ S2 m
Individual Data (Maximum 20 marks available)
7 _" X! n: R0 w3 G5. 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.; h+ ]- B5 W5 N7 L- j$ k  W
Documentation (Maximum 10 marks available)
+ h% Y% |: t' m' J/ n' ]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.
9 U- |1 Q$ E: s" a9 B! PBSA104 Business Programming – 2007: Assignment 2
  a" {: M8 z8 K. }1 q, rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: S, b1 K0 h2 a* B3 n
不过你要翻JAVA的类库说明。你有下载没有?
/ S, j8 `1 R7 z( n9 y8 @& w查询关于对比的函数。貌似关键字是contrast,还有compare
( J7 Z2 O/ B1 D9 A5 N8 W6 x
8 ]5 Y3 L) K0 I1 R6 U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# q6 ?! |; V8 Z  H% B
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。. V, R$ n. T$ ]& ?( H& y- M
可以下载到的 是 jdk-1_X_0-doc
, H- Y/ o! u7 V) ?# D& B
) v( y4 _& S7 v! G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-21 05:39

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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