找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1755|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) q- h: R4 ]" x! x. k R8 l6 }( X3 d! u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
' h* x/ b) `4 S//  ProgramCompare.java         Provided by: DRS5 Z6 t: j% h4 T$ [
//
2 \! w. ^9 C: Q2 w, k//  Program shell for Assignment 2; o) q% @. ?. N: g; {
//
8 `+ j  }" m/ r' ?( P//  Compares two text files line by line
0 x- ~( m% ^) O/ u  w! T% O1 x//*********************************************************************
: t6 y4 Y% _6 p
2 U3 _8 i2 R. \$ m- yimport java.io.*;; @+ f  Q1 H- z$ Z0 R
* S+ }8 |/ H8 h1 G: Z. c, ~
public class ProgramCompare! ^/ o6 H# j# h% k, o, o
{
& h9 s& x7 D; Q; F& w  j( e        //-----------------------------------------------------------------
) g) Z9 V/ i& X8 |. w        // Constructor/ A9 H# u# q5 r; W& s: _
        //-----------------------------------------------------------------
& n/ d( o7 H: Z9 o; u9 m* x7 S        public ProgramCompare()
. o( W" R. L, b% K        {1 K% \% b& D4 j" a& `- e& e, `3 O
        }
1 J0 `$ M# ?& \- y) X" G4 x
! R, _& \2 E$ {9 d( N7 t+ s        //-----------------------------------------------------------------
8 X; s6 [5 I! m" Q9 W. p        // Method for testing that class has been reached( H; L3 ?& ^( L- M# l1 M/ {, t
        //-----------------------------------------------------------------       
7 m6 |9 d- N( _7 r  h+ P& }5 \+ M! I9 R$ `0 k/ C) t; |
        public boolean ProgramCompareReached()        
& @% ]: V8 k8 Q0 x) |# J        {
' B8 P) f: p! p& r% ]      try
) p- F. \2 ~/ J9 s. I   {         5 {; T# W0 G/ f* E8 M. K
                       
  ?- r, [; g+ }, B6 g                //********************************************************************
/ W( P; S2 C" t: }                // Try-Catch Statement is used to handle exceptions - such as file not found
9 K: M/ L/ B8 n' l+ \# Y                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  Z! T( d$ C4 m/ V- Y0 z                // For more information see page 534 of the textbook! V' P3 v* p8 q& ], V7 T
                //********************************************************************
7 `/ s  p$ V6 b0 c0 p                     / J+ Z* E. G) f- J. s
        }# K3 q$ G5 X! z
             catch (Exception ex) // Exception caught here and message displayed to the screen
1 T' x! r: v" S( x: y4 v6 E, D          {" ?9 x! q  F- W4 e* H, h
                    ex.printStackTrace (System.err);
7 n6 ^+ Q- Y# r$ D3 V           System.out.println ("Error message goes here"); // Replace this error message with your own          % k& s% I% M% ]& w$ s
        }9 }& g& ^0 {+ r* t
                return true;
7 Q2 i8 O4 g2 _: w3 w. b        }* Q4 m: ^" I' k  G1 A  s3 H
6 {1 ]# k9 _6 j; U( K8 K8 V
} // end of class ProgramCompare
7 g8 a8 z5 F( {8 w9 r9 [3 v
9 C' l) l2 a2 R  |! I" o% r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ J7 @  w. e! [* l7 O  d//  ProgramCompareMenu.java    Provided by: DRS3 s; e! p  ^- B+ F( V) ?& v
//* X! |0 L7 ?$ f6 H4 ?
//  Calls AuthorisedUsers.java and ProgramCompare.java* u5 I0 k( u3 S& V* `% G
//8 y1 [5 m5 u' X# Y% D5 @
//  Driver shell for Assignment 2.
; e9 o" Q% W: I//********************************************************************
0 d0 |# l  r! C0 f
7 [/ e: W4 g5 v1 n' Oclass ProgramCompareMenu
6 z; Z6 g8 p& U. L+ H& Q  G% M{
# \6 h: u3 `! h3 U3 J2 o0 s    public static void main (String[] args)+ A4 x1 E9 ^& ?) w/ @& A7 D
            {
: `, T6 |4 l9 a* v9 U4 F. U                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable' A" Y4 T* i0 W) ~* l
                ProgramCompare reached1 = new ProgramCompare();
" }6 a! \0 @1 M4 I" ?4 N. }                AuthorisedUsers reached2 = new AuthorisedUsers();        4 v; g& @2 `# I7 l* Q& I
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 \( h" r1 U5 _5 C4 l3 x
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 U9 K2 v0 b  S; j        }3 O1 l& V5 A  d3 r. _! P1 [% j
}// end of class ProgramCompareMenu
$ l9 _5 W* h5 x1 p6 G) ^( f* u9 T' G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- H1 e# K3 o7 e2 X. T. B5 k- N
//          AuthorisedUsers.java          Provided by: DRS
# r& n# e" r/ v( {. s//                7 M" w: @  B! \# E
//         Program shell for Assignment 2, [% Y: x$ k; J8 Q' R
//  I4 F9 c# G: B# q7 v0 x6 S
//         Represents facts about an AuthorisedUser+ ~7 C- n$ x5 T  z& T/ A9 R
//********************************************************************% v  l! v& G+ p0 e
* ?# `  |. `7 g! G8 k: Q
public class AuthorisedUsers  }; w$ @. n3 q
    {
  c1 ]/ y. s* L. Y6 C
0 z  i3 J' w) ]7 a/ R        //-----------------------------------------------------------------
3 B6 Y# b0 w3 ]; w3 V# @; W        // Constructor
( b" x$ g& ~( j        //-----------------------------------------------------------------
: p7 `6 K/ [9 I7 Y1 Y" K5 T7 D4 g5 N0 \8 N$ d1 i
        public AuthorisedUsers()
8 x; y3 S9 d+ K9 f8 X4 M                {& L; g" ~2 |  G- l; a7 K
                }1 Y. [# ?/ `. {2 e* g5 f

) ~3 ^1 ^9 t8 u9 v        //-----------------------------------------------------------------
  v4 f" O7 ^& f! g) l4 _+ A        // Method for testing that class has been reached! }6 @6 \6 s5 w' K& B
        //-----------------------------------------------------------------       
5 D0 @/ L+ Z! X: D# ]        public boolean AuthorisedUsersReached()& S! A/ e- L8 L7 Z' o, F) A; e
                {
, |) ?1 p, y, @3 [9 \                        return true;                       
, N$ k' T5 ^5 i& }9 H                }/ M3 y( i, n9 c& B8 Q
               
2 j- n( g- v+ @& ~) ?# ?7 P$ a    } // end of class AuthorisedUsers
' ], l: |0 D0 i( D9 g$ N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
. K; b6 W8 _' e/ L  h! u. jShanghai - 2007
+ g  a8 x: U3 g/ l$ Q% NAssignment 2
1 a! o# R9 F/ L8 m( 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)% i3 ?$ z, K+ s' L9 ]/ @7 j
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.6 i- c9 T. v! Y& h/ e
The staff must be able to:# X4 k+ b+ |# m; E
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 {4 u7 k* s: M( }5 i% |9 |. m1. 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.
" d8 m( }0 g# d; q The interface should provide a menu so that the staff can:
# H7 {- K7 K( Oa) Enter the names of the two Java program files to be compared
4 z3 K: n- i: ~9 z4 S" u' p$ E For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 ^3 W* y! ~3 ~2 w; n) V
** 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).
% i+ ~5 P# p, B. t8 SBSA104 Business Programming – 2007: Assignment 27 R* ~& k7 _! q
Page 2 of 5
" t' K& i) I6 T" A" L9 T5 rb) Print out to the screen all the lines of code that are the same
/ P7 F* P- @: v5 n6 J Include the name of the file and the line number of the code being printed for each of the two files- P: J- d9 e' `& G) b$ u
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 M9 h9 b- c7 E the name, username and department of the user+ B0 [) f* I7 f' b# H9 F! N' a
 the statistics of the comparison+ K; A: w  u! ?9 f8 i
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' r+ z) t" R) T' O8 v# } the recommendation for further checking7 I& L1 R" u8 i
- 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
0 @+ c; H5 O0 _ the names of the two files compared
+ W' T/ a! O, Z. y* ^% ed) Leave the program (exit)
* A5 ^7 T! h3 q! D% R3 j7 t1 mThe ProgramCompare class: (Total maximum 20 marks available)+ D" H; u4 `1 K  Q5 Y
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)
! D( y$ s6 Z4 x4 d$ `a) provide an error message if the files are not found or there is a problem opening them
' y9 A3 l4 Z; mb) compare each line of code
3 q! O  l6 ?) A6 M) [c) print out the lines that are the same8 p6 l' n/ `5 S. a5 S% L9 |
d) count the number of lines compared / lines the same
: y+ n- ~& i& k( u& LThe AuthorisedUsers class: (Total maximum 20 marks available)
8 E9 Y/ n% D) Z0 u1 ?4 w# _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)
4 X1 n. P; L+ C( d) @* ~4. Provide methods to:
1 i9 |" M+ K. q4 k4 Aa) 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
" C6 b3 k+ B& i" _; Zb) return the name of the authorised user" [2 r9 X. w6 u  k
c) return the name of the department of the authorised user5 O3 `, \- ^  W$ N' L
Individual Data (Maximum 20 marks available)5 {% W4 e, O/ m" `. a0 o+ B( S( p
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.
4 o* f6 |: Y% W$ mDocumentation (Maximum 10 marks available)
# I& i+ c: H5 e6 j' T9 H" ~! v- \  ^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.- {, W* y+ Q+ F' W% a
BSA104 Business Programming – 2007: Assignment 2
0 k% F) ^5 g3 o$ }$ q  {Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ W! D- S: {' A6 Z
不过你要翻JAVA的类库说明。你有下载没有?
# ^9 @( ?4 i6 h% Y' r查询关于对比的函数。貌似关键字是contrast,还有compare& K0 d0 H# F: Z6 m" n4 W% D9 `
( W+ u1 D* ~0 i6 z. h2 p
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% n. F! S2 Z( a( z( t7 b! P  G
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% g) H" ~7 E) c* \2 n可以下载到的 是 jdk-1_X_0-doc# U5 [  o( d. x  |& ?% Q( ]/ k
: D0 L$ x: F; v9 G: }! W3 p; i- q4 \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-24 19:52

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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