找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1201|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " o: k* m; n d 4 Y Z) V0 f7 b9 ?8 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 | 显示全部楼层
//*********************************************************************
: W3 ]( X, q7 t- j//  ProgramCompare.java         Provided by: DRS# M/ l: t8 Q- D' N3 c! R
//
4 e: {* j% k. }" q- h1 o9 H6 c//  Program shell for Assignment 22 k" h$ Z% C- P# w! w, @
//
0 S5 u# h0 Z" v//  Compares two text files line by line
6 E4 t: L! e( }- ]1 u$ O$ a//*********************************************************************
6 J7 l' m8 z' X6 t9 M
" |& c( F) J* t1 X4 ]import java.io.*;
$ _3 y: V8 K$ K9 T. m0 t+ X6 p8 H) k& `' |
public class ProgramCompare
7 V* p5 G  X# u7 V3 S{
2 `; L( o8 M) N9 d- p        //------------------------------------------------------------------ i) X! O; P( v$ K
        // Constructor9 @- h, S6 o0 }
        //-----------------------------------------------------------------+ P- a; N6 h) \; D; P* U
        public ProgramCompare()
$ K7 I' a9 d" m! V" n; |" L        {* j; X0 U0 m. h& L6 X
        }) P7 h  i9 H* o" E( o, l

/ [2 K) w% o2 b* h  }9 a5 _" a        //-----------------------------------------------------------------8 a/ h' M" }: V% |2 [9 `. O- ~
        // Method for testing that class has been reached* p9 ^8 O& T$ B, ~: u% q
        //-----------------------------------------------------------------       
) g2 W, f1 \% \" B
; O% ^$ ?0 f/ Z4 r9 o% y        public boolean ProgramCompareReached()        
* l* E/ l' L1 x9 q, F% R5 @        {
9 \6 a5 U/ h; l7 ]$ {3 r      try
, H& f% |; Z! ^% A0 f9 \3 v   {         % Q9 U9 X% o$ r5 B: u9 Q
                       
; A& P- E( m8 n% X: p1 Q- T9 j                //********************************************************************( ]( B5 {. h8 a
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 K2 s3 a, _% i* L                // Reading the files will need to be placed inside a Try-Catch - just like this one!' z% q: V& s( M: G" D; \8 g; W
                // For more information see page 534 of the textbook$ i+ y; c0 g) }3 s) C8 ^: J% x
                //********************************************************************
) D6 k) _) Y0 J0 E# R                     / r) g% l5 l' c
        }
4 i3 @. p) D1 l             catch (Exception ex) // Exception caught here and message displayed to the screen : p" X9 J, V- {" b& l; _: X
          {3 q. E( j/ C! j% P
                    ex.printStackTrace (System.err);5 ?' o  Z& D2 e: ?! D$ T) O1 M  [# B8 Z
           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 G0 j- i9 Q- b, ?/ s        }
' s0 `0 N3 s* X/ |; F                return true;, K: u) A9 a% z+ a* }
        }( S) ^" I. C6 P8 j# X4 k: G/ h
# E2 ^' D3 y/ A) O  T5 [. F
} // end of class ProgramCompare$ T7 w9 {0 c( `8 P

+ _: p. f# Y4 v/ \! u5 Z/ z2 c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
6 X9 t9 c; \0 m; r7 _//  ProgramCompareMenu.java    Provided by: DRS: G" o; o. U- _' x  r( x3 c, Z0 C
//! o- ^% z7 P/ Q: f* K
//  Calls AuthorisedUsers.java and ProgramCompare.java. r% j$ d7 A* S' B# }( v
//
6 i5 ^' f' t( T9 @( }: f//  Driver shell for Assignment 2./ O; u0 s! M9 M1 g
//********************************************************************1 _! W: `3 G0 t6 _! k" |0 ~) T& x

8 r; F8 i' k/ `" j4 Dclass ProgramCompareMenu8 n- U! f6 ^2 ~& K: |1 _
{$ r2 t" b7 i/ P
    public static void main (String[] args)
: o6 s3 R  A7 V( v. E% D: U            {
) W# {. }5 z1 B: j" `                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% Q- `5 I4 z8 f                ProgramCompare reached1 = new ProgramCompare(); / h! k" l* }( p. b
                AuthorisedUsers reached2 = new AuthorisedUsers();       
. D$ ^/ q" ~% g7 O6 ?8 H+ K# r                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());( Z7 ^; m- E! t, l5 ?; J
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  _& |. k; ^  g8 H# F# d# f/ |        }, G8 B4 j, F+ ~4 p  _: `
}// end of class ProgramCompareMenu
: W2 G% u8 Z5 ~; e
% Y; i/ R! w3 a/ h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************& D7 W8 i/ Q) k, F9 |# ^
//          AuthorisedUsers.java          Provided by: DRS" i. X, |. S% x6 F8 W; H( b* G
//                . w; \' `# z5 d* w+ M: A
//         Program shell for Assignment 2; V4 P6 V: t% [
//  ^; d7 G. o( P" r
//         Represents facts about an AuthorisedUser
7 ~& I' P3 G6 \. C* b, B( B//********************************************************************
9 G* M. a8 Y) P) ?8 O9 e( l) Y9 r, M5 _) m% ^8 r% b8 c1 b
public class AuthorisedUsers
8 B: z" d3 c6 [5 c    {
" i$ r, \2 t8 A, j
  O7 q9 [, e* _1 T9 b8 i/ r, j        //-----------------------------------------------------------------
& O' a7 j$ W1 I1 u3 U& V        // Constructor
* _/ A( R+ g& K        //-----------------------------------------------------------------
  u1 m* H' n8 G+ l7 Z0 U" g: i3 |4 ^3 ~6 P1 N3 w
        public AuthorisedUsers()7 \  x9 p6 y! f, d7 Y
                {0 v$ [/ U: D; j. w+ e
                }
% g1 C2 ~: v7 X- Y2 \8 y- m0 F2 g. ~" ^% @. J/ Q0 m8 c# k) Z
        //-----------------------------------------------------------------
  i7 ]4 U$ k8 D+ v. [, q        // Method for testing that class has been reached+ H  i4 [5 Z3 h2 v5 c
        //-----------------------------------------------------------------        3 P8 V& E  C2 n* g0 \/ o5 r: x
        public boolean AuthorisedUsersReached()
3 {3 m7 D8 }" ]6 S) N, I3 m                {" F8 c- ]0 @$ |0 J& x1 F1 g
                        return true;                       
4 M: K+ [- Z. F3 y0 Q- B$ K                }
3 L( p& J% U5 u$ I# V' m* p4 N               
: b+ C( N  c8 D# H4 V4 J    } // end of class AuthorisedUsers
& Q1 g, Y0 K3 ?5 s: E& M3 Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) {5 O/ P1 P, k# M' Z+ W8 |  x
Shanghai - 20074 G9 p6 r  v  s- F) Q  x5 r
Assignment 22 }/ ]& H1 K2 u' c5 {
Deadline 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)  c1 X3 L8 t  [
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.
5 k& d# C% y2 g* NThe staff must be able to:% t! Q9 j, S! C# y2 o2 c
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 s) L# ]# b6 s, ~) l
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.
: y* m& Z) V7 B- ~! [9 Q The interface should provide a menu so that the staff can:& r6 ?2 a7 [- V' i4 f
a) Enter the names of the two Java program files to be compared, W4 U: a1 k6 G& M" R  q
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
! t! S: V( G3 E$ i. e/ i( T6 H0 ?** 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).9 W  o9 V* y3 r" i$ l( W
BSA104 Business Programming – 2007: Assignment 2
& _5 P; B3 S0 I" GPage 2 of 5& k; k( O. ?& p# ?& B% d
b) Print out to the screen all the lines of code that are the same# {7 d: H, Z4 n$ Z1 ?
 Include the name of the file and the line number of the code being printed for each of the two files
/ R) {7 y) T- Dc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. |4 b5 d8 B! H
 the name, username and department of the user: r) K$ ~. P' a* G: d
 the statistics of the comparison+ I/ q9 C- y, G, x9 k* a/ N
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 {7 H2 U" [: V3 s
 the recommendation for further checking2 h, ^  F6 p' X- G
- 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
3 _' z+ ~$ G+ R* j% F# R. F the names of the two files compared( R! t' m5 \1 Y: E4 ~
d) Leave the program (exit)  X- W3 x+ m5 C2 d5 ]$ S3 b
The ProgramCompare class: (Total maximum 20 marks available)
  ~3 n' `( L) s0 K2. 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)
9 x( d1 E) L6 @  o0 f& ma) provide an error message if the files are not found or there is a problem opening them
# w2 E2 _. a+ f2 qb) compare each line of code: b; d9 t# q/ }3 G
c) print out the lines that are the same
* ?5 C# _' i* H. ]) e" Kd) count the number of lines compared / lines the same
) ?9 z- t  F4 C2 a  ?! ~The AuthorisedUsers class: (Total maximum 20 marks available)
! e2 U' |& `, P$ {, H3. 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)! O" z- r* o2 N9 B; }& L
4. Provide methods to:
6 H4 Y$ m% Z3 t; C* ea) 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 o, g& w1 ^. P7 N5 c1 \b) return the name of the authorised user) m% F$ h' ~) |7 r  p& s
c) return the name of the department of the authorised user+ q) d- z) A. [( [! R
Individual Data (Maximum 20 marks available)
& o2 z: U" b8 H5. 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.) z; U- i' l( I0 t
Documentation (Maximum 10 marks available): i! T" b' c% M, W
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.
, r" n) `+ c# }5 F! rBSA104 Business Programming – 2007: Assignment 2
  T0 k& i8 J) L. P+ D. n9 t% ZPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ {6 G7 y+ k! T8 Z3 v
不过你要翻JAVA的类库说明。你有下载没有?
0 V3 f; O" D+ {4 z8 @9 s& E查询关于对比的函数。貌似关键字是contrast,还有compare
0 N6 I4 Y1 [1 q
6 s* k( Q1 n/ @% Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ l5 y; q0 L) O痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。& f: x4 B3 W+ a5 w0 V
可以下载到的 是 jdk-1_X_0-doc
1 ~% Z9 g# f- O2 k. N$ t7 \" f+ ^7 L$ r0 h- [/ S" n2 B7 y5 X* Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-17 06:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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