找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1812|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 , w- Y6 H0 r F' f+ ?% c' }) [/ r ( c2 Z+ s. a3 f
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! y' M2 e- h* Z
//  ProgramCompare.java         Provided by: DRS6 S- _3 }4 F) B3 O7 u
//
" C5 T8 R9 d% s$ n) i//  Program shell for Assignment 2
& U" b! u& ~" |7 d0 z//
5 n, G( A: ?! Q+ Q5 \+ P; t//  Compares two text files line by line
- p3 U# ^; O5 ?/ l1 K//*********************************************************************1 i+ L' t0 @, `" N# `# `

  w% }3 h0 ~' ~  k/ x; y' Rimport java.io.*;" @3 @( e& |8 D
3 g9 r( l  z' `3 s; q* L1 N' B
public class ProgramCompare
7 Q& z  b* i9 O' l) D3 p{9 k4 P  A& m2 Q9 z6 k
        //-----------------------------------------------------------------4 V( F1 z' ?/ x4 O* N0 i7 B& T
        // Constructor
* Y! N' T. @- F8 v1 x        //-----------------------------------------------------------------2 v" J) w8 ~4 a6 m
        public ProgramCompare()/ `! g: p5 c& ]1 t) L" Q
        {7 |- p- q. L, `% z0 t
        }
$ G  ^( m2 _5 K) p$ o) d* k, V% }. F) u6 [# L; \6 a8 C% q
        //-----------------------------------------------------------------
. H% i9 b& p/ G& \        // Method for testing that class has been reached
! G5 s. x$ b% E1 i: B0 E% A/ F        //-----------------------------------------------------------------        , Z' ^  {7 h/ {3 U) C+ J: W0 ^

8 G( c, g8 p. O0 Z% ]        public boolean ProgramCompareReached()        
% J% k/ ~/ J5 |" H        {2 M* {' W* N& w  S0 I' l# K' r
      try 2 C, x6 w+ Z8 g
   {         ; n/ c. R$ z$ {. _4 O
                        : s& _- Q% }! R' i
                //********************************************************************4 ]+ h7 S( ?2 y
                // Try-Catch Statement is used to handle exceptions - such as file not found 0 L" P3 P" o2 e+ @, \
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 d+ x( p# \7 z$ i' L; g/ K                // For more information see page 534 of the textbook
6 ]1 h$ b9 s. M6 a# q/ o8 L- f3 ^                //********************************************************************
  }# A9 M  A; e: C( [% p: i2 P$ \                    
1 t- N. ^5 w! v- \: {, h- {4 r        }
& X. f  U- U. i+ T/ K             catch (Exception ex) // Exception caught here and message displayed to the screen
, I) y) G! B& ]9 ^9 I  q          {, ?* l4 a% k1 |' x$ n/ _
                    ex.printStackTrace (System.err);4 u* J7 o! P! U4 j. _  S
           System.out.println ("Error message goes here"); // Replace this error message with your own          ! m0 G3 S1 G& C3 v" Y, P
        }
# T: Y8 |; a* G1 L' ^) q6 S4 X0 e                return true;, t& H+ }' C$ A% r' }9 |3 g6 v; v
        }
- j8 |" t" Q# y5 E- D$ F, \' @7 f4 H
& Z% E( f5 u: \9 ]/ |1 r( q} // end of class ProgramCompare. W$ X9 d- F8 Q
: V9 O, ]( N* n& p" L8 ]$ g+ K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 W9 O1 L+ S5 A. ?' K+ T" n//  ProgramCompareMenu.java    Provided by: DRS
4 ^% C) e) u. L/ w' w* X4 y- d//. z' H4 L2 b* o* N/ [& Z9 c+ V
//  Calls AuthorisedUsers.java and ProgramCompare.java$ j( Z, j4 z  [" S6 K
//
$ B' u: A% q2 b- o6 y# S$ }2 p//  Driver shell for Assignment 2.
/ m9 O, g7 D5 v. w) }0 Q: z. s& m' j//********************************************************************1 ~9 _. V$ t. k) p

' ]4 Z/ K' q9 r) l# D, ^class ProgramCompareMenu' o% R5 W* ]1 o/ u
{
) }6 P4 m! f" K4 u) F, L* ^    public static void main (String[] args), m! U5 F' `: s2 r; c# ^+ V  j
            {. ]' D0 H' D( w( M4 a
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* |/ v- J. M7 d# i/ N
                ProgramCompare reached1 = new ProgramCompare();
. v2 J8 Q9 f5 Y1 c- F                AuthorisedUsers reached2 = new AuthorisedUsers();        5 }7 W" h& W! t( L$ U6 g* i3 p
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
; _1 r" }+ p% m% G$ a5 L+ P: n                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- [- l2 P2 l/ l        }: D9 m% d& ?1 i# G  a% W7 x
}// end of class ProgramCompareMenu' Q# h! d0 A( C

) b" J% a7 B% p7 ]/ T2 J; T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************( l; Q* E  b1 B. r7 M
//          AuthorisedUsers.java          Provided by: DRS3 ~) i# `; l: Q" r' V
//               
/ ~/ t' ~; N7 G; k& M//         Program shell for Assignment 28 \  h( s: G' [) D/ K
//
' C/ W( p3 c2 ]1 _0 H//         Represents facts about an AuthorisedUser# M! T. x4 s3 J' Y7 Z$ Q
//********************************************************************
9 e: k4 }) o) {( D  `5 a( k8 N& m; ^! _/ p. e3 O; q' G
public class AuthorisedUsers
2 v2 c) W9 F7 Z8 H, Z; `+ }4 X    {" t0 s& S' Q9 B8 g. w

: W$ z5 `' U4 d' ]4 U        //-----------------------------------------------------------------% T) E- ~% c3 C) o/ u' c/ c7 Y, F1 u
        // Constructor  e( n4 f# ?# Q0 u8 m& g
        //-----------------------------------------------------------------  K% ^7 m% I" b
- O, T0 f$ s8 q# y1 a$ c
        public AuthorisedUsers()
- d+ j* J- D, F                {
- p; X, v/ R, L2 N" R5 ]" ?8 H                }: a% B" _( V2 Z4 t" ~( ]% Z

) s9 [2 W/ l3 V1 S' ?; S1 x        //-----------------------------------------------------------------
0 T1 A, r$ e$ H* J9 `: W1 k/ K        // Method for testing that class has been reached
5 Q8 K. ~; `3 L% x: P        //-----------------------------------------------------------------       
4 a, J, H! t: |1 O+ F& G3 o0 v        public boolean AuthorisedUsersReached()
$ S' Y  M' n, {7 H) U1 g, j. Y                {
+ ?' ~- i9 `) _% P1 E                        return true;                        * c) D) u' y' |* i; g4 H) `
                }
: e5 Z5 q5 A9 I* M                % z; C: {- f2 @/ |, q: r
    } // end of class AuthorisedUsers
8 {1 L7 {+ ^3 ?5 g8 g  u3 K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, ?8 r- Z) J$ KShanghai - 2007
$ V4 l- n1 C% s4 p& mAssignment 2; o  q( o$ d8 N/ m( h' c/ `
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)3 B4 J: d7 P& {
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.
# b0 x  ^) `" bThe staff must be able to:* _1 [3 {4 y! V! L
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# A& |. l" D! q% _3 e- y1 \% s; O1. 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.
/ H! c" I+ m# L5 ]4 z The interface should provide a menu so that the staff can:' C& R7 c  ?( K" L; i- n8 H4 a
a) Enter the names of the two Java program files to be compared
5 D- F; d, T+ c( } For this assignment, it will be assumed that the two Java program files are in the same folder as your program.+ Y7 D9 W% {' O4 O7 }  E
** 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 U+ J  Z- W! O; i$ k5 _' ^
BSA104 Business Programming – 2007: Assignment 2$ ^1 c' s- a7 G3 U0 d0 ~
Page 2 of 5
) b2 Q6 z) `1 n" `% ?9 y  ]" y* Tb) Print out to the screen all the lines of code that are the same6 v& n2 a' j' q) c/ U+ G4 L$ |
 Include the name of the file and the line number of the code being printed for each of the two files9 `+ E2 G2 J2 ^
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ n7 b+ I/ l$ _1 \* I3 t the name, username and department of the user
* u8 t+ O, U/ o5 [4 t+ X! B9 R  s1 L the statistics of the comparison
7 Y; `; W, F* g+ Z- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" t1 e0 J9 A* S8 [! r7 `- y+ T' l7 f$ } the recommendation for further checking
5 h, r+ F  P: r# W3 H- 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 closely5 e0 V  R+ W7 ^; u
 the names of the two files compared
/ t* x2 n2 W. w" Q; ^4 cd) Leave the program (exit)
1 V$ v1 x4 J0 U# F3 m# w( @The ProgramCompare class: (Total maximum 20 marks available)
% u/ w& ?" a7 B9 B% }4 f3 e, u4 g2. 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)/ J3 X" O; i: ~& o) |
a) provide an error message if the files are not found or there is a problem opening them
- V& `# \/ O* fb) compare each line of code5 ^. d4 d) s, v: q, \* G
c) print out the lines that are the same* @( K4 U% \! r* J+ o) X2 d
d) count the number of lines compared / lines the same
3 M; X# d( t. z& q7 |, oThe AuthorisedUsers class: (Total maximum 20 marks available)
4 k  J% z' ?9 W- h8 ]$ X9 v! ?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)
% ]/ r( }5 Z( f3 ?4. Provide methods to:& ?$ o6 Z4 @0 X8 g  O
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 match
+ O3 B1 L: P& A0 C7 Sb) return the name of the authorised user4 f+ a$ q: m% I: C
c) return the name of the department of the authorised user; n$ C, D3 {; p5 ~; G4 Y& q
Individual Data (Maximum 20 marks available)
# O& @0 q1 W: h0 b% Y5. 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.
6 B1 n0 y! e8 M' C$ a+ R, ]- ]8 A( @Documentation (Maximum 10 marks available)+ B; t7 @. }3 a; A- {* D+ ^
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.- Q$ Y$ L# d$ ]7 o  }7 v* s
BSA104 Business Programming – 2007: Assignment 2
/ `/ U  Q9 j$ n# u# C5 q4 wPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ [$ ]7 h5 z* i* \( c3 G
不过你要翻JAVA的类库说明。你有下载没有?4 y0 o1 q* i) s# @6 O8 ~5 N& l
查询关于对比的函数。貌似关键字是contrast,还有compare
! U: t+ s* M; M0 p0 d# Q: X9 u) n( P4 k
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
. p- t+ c. i4 R* D' u* B3 I痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ R9 r7 f, {$ _9 m可以下载到的 是 jdk-1_X_0-doc* C. c% d1 ]5 C3 k& b+ ]; @8 K
- c, F: M" b/ m" K( ^5 }* m) G
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-11 12:00

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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