找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1463|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! q2 F! q8 ?, n) z1 L% w; y/ ?6 m* R4 [# y* J
回复

使用道具 举报

 楼主| 发表于 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 O7 h; W2 K9 ?- O
//  ProgramCompare.java         Provided by: DRS
' I; m# B9 O& J% F! J1 j5 T//
8 ~$ D" M  n. a, R//  Program shell for Assignment 2
8 K$ x9 E6 a9 }/ Q; b1 p//; H- ]  O. {  e7 R. P- B7 Q! h
//  Compares two text files line by line5 H1 f- S# L4 c
//*********************************************************************
7 S# a7 z' @  a; S5 r% ~: Y
& j2 A' l7 c0 B4 I: ]/ A1 x/ t5 s1 Fimport java.io.*;" w3 ^+ P/ W7 ^, i* u+ p$ i
8 _# O7 H+ R' G0 Q6 m- O6 c+ f
public class ProgramCompare
; w4 G  c6 }* c% C2 h! ~. ~0 y{
& k+ P8 Q/ n) G. Y  y3 K' I        //-----------------------------------------------------------------
, H+ P, [+ l% }. V- p) M6 R: y        // Constructor; D: U2 z7 R4 q( k1 q5 K
        //-----------------------------------------------------------------  j( L+ d& G( b; P
        public ProgramCompare()  o  x) Q( C1 f1 ?, r
        {
/ [; |2 u$ a1 E% T2 y3 ]        }
+ ^7 t9 q! s( s/ a: a9 N4 w
+ P3 ?+ Z/ z2 Q8 N( B; W( X5 {        //-----------------------------------------------------------------
' Q4 [4 E0 @' m/ L0 O        // Method for testing that class has been reached
( O. D  J- b6 U; X7 l        //-----------------------------------------------------------------        4 f% B' ~' r+ w8 g

9 g/ G  b8 U8 W$ }7 q        public boolean ProgramCompareReached()         ' O+ F) h. ~# E" a% l* R
        {# j3 ^' F( ]3 w& R# E& }* P8 w
      try
: N; T2 ]/ H. C7 N   {        
. t& S7 e7 O" t) Z- L  Z  c                        . T  g. d( O3 V4 e# i2 G6 B
                //********************************************************************  r, \8 a) E7 x/ O( u
                // Try-Catch Statement is used to handle exceptions - such as file not found 5 t4 b: T, G. z7 D  O* `1 p$ J- p: L
                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 T& F" `$ Q0 F7 I1 H% k
                // For more information see page 534 of the textbook. ~/ m# ?& [9 `+ @
                //********************************************************************* n2 C% O) M* q" Q, H- @
                     # I( V6 w- D% p, A
        }/ _( }7 n# W% h- i( h. r
             catch (Exception ex) // Exception caught here and message displayed to the screen
, p' K$ f% E2 }( j2 N4 h+ U          {
2 w* }, m' v3 ^2 I$ D                    ex.printStackTrace (System.err);
1 D& w6 ~9 y$ f& @' Q% O           System.out.println ("Error message goes here"); // Replace this error message with your own         
* t6 x; [8 c% @- ^1 k' a        }
' K$ W- @9 h: F$ \; `                return true;
9 }4 i0 E% r! S  i% b9 V        }
) a# ~' l+ w' l# J: q" S7 u8 s1 @! p
} // end of class ProgramCompare# g  n/ ~: C  N9 C  Z
9 N4 \8 [& U+ U2 ^: C' ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" e6 @/ J: f# I3 ?
//  ProgramCompareMenu.java    Provided by: DRS
* s8 {7 s  d, Y* o- V! b//
) \/ N# {, e! H( E# a4 }7 f//  Calls AuthorisedUsers.java and ProgramCompare.java
" @0 V' T- [/ ?1 p3 h8 J' d/ w! r//
8 x& b# t6 |) p2 j3 e; `//  Driver shell for Assignment 2.. y5 X9 _6 m: J% s5 C: w' I
//********************************************************************
. f" f" G* ~7 v! E
4 C2 a& A: Y5 ?) K( xclass ProgramCompareMenu; E/ x3 }& Y. R
{. A) j. R- ^5 c, c
    public static void main (String[] args)
- n0 l7 \7 d, b& M3 u1 W/ {! A            {6 S4 M8 h7 K9 U" |
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- k. j  S  u. N; w2 J                ProgramCompare reached1 = new ProgramCompare(); " F9 e! _; w7 o# ]% M# Y
                AuthorisedUsers reached2 = new AuthorisedUsers();       
; L- O( ^' u* W  [                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 a, @- x1 O- f                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! {$ s( |2 K8 V4 I. y        }
9 W5 o- @0 ~! W% G3 O2 i1 n}// end of class ProgramCompareMenu* j& B( i3 i" p4 G) e9 o$ n9 U, ^

4 L  x1 Q. ^$ d6 F+ V9 K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" ?( p& i( f2 x5 ]& D3 h
//          AuthorisedUsers.java          Provided by: DRS
- p! B1 G; L. j, c2 a/ `; B$ R$ r9 i//               
7 [0 a/ M2 ^7 K& d' d( K//         Program shell for Assignment 2
2 a1 [( W& v6 e4 U- }//
0 v2 g) m5 ^' c//         Represents facts about an AuthorisedUser1 O3 \( i6 n) [+ K3 R
//********************************************************************
& @  m7 V% A, ]- ~3 g& z% O! Z  [( \& c4 h% D! ?. s: v
public class AuthorisedUsers# Y, U/ }& q# E9 r, H
    {
' T: U( A4 |4 h; b
3 O3 H( i9 f# X% H0 |: T3 V        //-----------------------------------------------------------------
) m' u* y( Z5 n% |6 K: r# @5 C' z        // Constructor) E, x! g" ?( q$ k: @' H0 a4 g
        //------------------------------------------------------------------ r4 C. Z* t  K
; c. C9 H6 A, K$ `) Z7 M: i
        public AuthorisedUsers()) l$ a( d- x' ^1 g2 x  o
                {8 }0 g' O1 E4 M/ q! t( w
                }
1 C: g0 T+ J7 @; g. l- g) B+ j6 f, |7 A' Z, Y$ b3 C, b5 |
        //-----------------------------------------------------------------% l- G6 E; ?* ?5 c; h8 d2 C8 b2 z1 U
        // Method for testing that class has been reached- R; |/ n; s. W  N) s
        //-----------------------------------------------------------------       
' H* l, }/ f0 @3 z        public boolean AuthorisedUsersReached()2 L3 x* t7 x, _1 E/ q6 B
                {7 q# i6 E- H3 X$ `: ]+ y% d3 O# m1 T
                        return true;                        / O5 p2 E7 ^6 W$ |- l+ y4 t. i- [, G
                }) b9 L7 q3 u  p9 T# u# X3 v
                4 C& r, m# s9 I; C0 [/ _
    } // end of class AuthorisedUsers
, q& {* |* G. l' |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ A$ |! O- U" y6 M5 \* I3 z+ KShanghai - 2007
% f% Z1 m* J/ z9 C; r7 SAssignment 2) C1 {7 k; D; G- {5 Z( w' ^
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)& }! V+ O. a1 g& G9 H) z
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.
: }! a: E' m% _8 T$ C- }The staff must be able to:0 }( V8 x0 j3 p
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 [; M5 w: S6 i4 a* M! ?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./ X) q1 {) T% o9 h5 P
 The interface should provide a menu so that the staff can:
4 @, I$ g  a4 {a) Enter the names of the two Java program files to be compared. D' _# o: M1 b8 J
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( M/ l" w! i) I; _( ]' t1 B
** 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).
1 R! p' U+ y# u/ ABSA104 Business Programming – 2007: Assignment 20 O7 o+ h9 {' E& T2 K6 f" {
Page 2 of 55 h7 d# d4 a: f, B
b) Print out to the screen all the lines of code that are the same
, o6 r! Q% U$ W7 d0 C Include the name of the file and the line number of the code being printed for each of the two files0 P) k% U  m* u& M  Q- D( E
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* t' x5 ?9 i  J# a" m( D0 b  X: \6 [ the name, username and department of the user$ g: E2 C- C5 s% d
 the statistics of the comparison
7 x( A: p1 v2 @, O6 L- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 h4 ~9 g- ?  x7 N) h  ^; M the recommendation for further checking; D3 }: b5 L) Z: c# k
- 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( _( T- N7 u' c$ }
 the names of the two files compared7 ]  S3 [. f$ Y4 G
d) Leave the program (exit)2 H. s" Q0 R2 x0 v" ^. l+ ^3 X5 h
The ProgramCompare class: (Total maximum 20 marks available)  Z' n/ E. U" f  g" M
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)
8 L/ V" m9 l8 R2 {! R9 y0 W" z; L& ?$ U! Na) provide an error message if the files are not found or there is a problem opening them
: C: I8 f8 v* e8 }) O! g1 h$ g! nb) compare each line of code% l3 H5 d( P8 b! U$ H; Y
c) print out the lines that are the same* w7 r: |* T2 M$ y7 Z3 [) y: |+ I
d) count the number of lines compared / lines the same
( u. A5 J  w% Q% s8 _; tThe AuthorisedUsers class: (Total maximum 20 marks available)
6 p: T5 u5 ^2 Q& }- P1 n0 t7 Z7 }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)6 C! ~& x# y" |
4. Provide methods to:
/ o, H7 Q( m) Y% Pa) 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
" g5 ]( `* r( _! G; Ub) return the name of the authorised user
2 U) @& ^: k& ^- l0 ~c) return the name of the department of the authorised user
; Z/ u! J9 ?; z/ VIndividual Data (Maximum 20 marks available)
) ^& m* Y2 h* ]9 q, z: d5. 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.! S# {9 i* n* b/ A
Documentation (Maximum 10 marks available)
9 R1 d% S/ r  m/ L' Z6. 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.: H: |6 z/ t4 w3 V! |" m
BSA104 Business Programming – 2007: Assignment 2
% F: N5 g. l+ l' m- u  RPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
3 ?1 ~9 Z! J- f6 k4 ?+ k: a% g' U不过你要翻JAVA的类库说明。你有下载没有?
/ g0 ?' l: ?. [( C; _/ K查询关于对比的函数。貌似关键字是contrast,还有compare
! ?4 X8 m  J' t- c0 ?
$ p( E8 x  D9 N2 k9 j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 W/ D7 y4 Q9 u1 S9 Z0 F) z
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% v6 z" w3 W% W, t4 F+ M可以下载到的 是 jdk-1_X_0-doc
6 n  t8 }% f+ x  h! _
% E9 q  {: G) D[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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