找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1354|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 g5 e2 f' O/ g8 D2 q, o # a& u5 _1 H" p# b4 w: v
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- Q" Z1 h/ {  N) ]//  ProgramCompare.java         Provided by: DRS! @. n5 Q8 @9 _+ M$ f- X1 a
//
' S) ?) K6 V0 P  o) J9 A& p//  Program shell for Assignment 2, S7 c7 r4 w" f- p8 C
//$ W7 ?& P2 ]+ E  Z0 O; C. Q7 Q
//  Compares two text files line by line
, g3 e5 }6 {, _! [# h- _3 S6 X( {+ @; `//*********************************************************************
/ F  n% b- s" s3 a* z, U  }
/ F- a7 j- C7 R/ ximport java.io.*;
( F; T$ \& {9 e$ `, I% e* H& C6 q( t' B
( W) |! A5 u, ^; jpublic class ProgramCompare! i* p, _7 D. g: y& v+ [: P6 `
{
( g6 K; B6 o( v$ |& `2 U        //-----------------------------------------------------------------
* a( h% R5 W# m' r; C        // Constructor' @- m# V) Y+ f# w* u1 d: w, Y
        //-----------------------------------------------------------------
$ W7 u' i( x  l! c  P        public ProgramCompare()2 W! k4 k3 y8 b) D/ a1 u+ B
        {$ a8 c. h! J7 j! ]9 N1 f0 [, O0 P+ N, b
        }6 r- D2 H" i# e: H( ^, J

. I+ M/ Z( J+ ^% P1 R( C        //-----------------------------------------------------------------
2 o- P* m. G& `% ^; @6 ]! ^        // Method for testing that class has been reached
4 @1 }4 ~& s5 }7 A  K" m& W        //-----------------------------------------------------------------       
. O+ q  D- d0 }6 \
" D; f: H# V- c0 ]9 R1 L  H% c5 G        public boolean ProgramCompareReached()         9 f- n. d! c0 d4 C' y
        {
2 h( F0 F3 y% F3 L' @5 @. w  t      try 9 A! g; b0 \1 P1 x- k
   {        
0 c& s1 T+ C. w( g  B  u5 ?% r                        : R7 c# H* |: S3 p5 r
                //********************************************************************
5 i" a6 I3 Q- x: ?                // Try-Catch Statement is used to handle exceptions - such as file not found 8 e) N0 ^' ~. n* A+ X4 B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
( ^, M: d( X) U! ~; c                // For more information see page 534 of the textbook
: m1 l- v( ?1 F2 k- ]& ?                //********************************************************************$ n: \0 P; c( e$ L* K. b# T
                    
) }. B3 ?0 ~9 Z* ?" z9 \, A1 s        }) K/ F& H. c: i/ {& G0 _+ m8 V/ T; {
             catch (Exception ex) // Exception caught here and message displayed to the screen   P# L' P) }4 Q9 d. L
          {
1 ?* _8 |! C; H7 L                    ex.printStackTrace (System.err);
" f! @) n: j& F/ H3 A. c" \1 ~           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 l# J# H3 m9 `        }
/ Q; ?4 j; e* a9 M% I6 }                return true;) ]& m8 m' x0 b) ]: f% g
        }
% c% {1 H0 M" |; L# {% z7 I) ~+ N9 d* U4 l+ m5 D2 R
} // end of class ProgramCompare" f3 s4 [  Y/ J+ f  `- B- j
) Q7 h2 c! _" G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  a, B9 r. X$ @5 M/ R9 d, p
//  ProgramCompareMenu.java    Provided by: DRS
- Y0 ]3 B# E6 b: f/ d//
5 R) C6 w9 o) j6 K7 z2 m2 m//  Calls AuthorisedUsers.java and ProgramCompare.java
- f8 l! J& v9 ~% ]% [" H//
5 w8 \6 Q0 L& o0 h+ T//  Driver shell for Assignment 2.
6 a$ Z! T0 H5 s//********************************************************************. N" Q% X5 @( n+ t0 L9 ]

- N- q) x% B# [8 l' x1 Gclass ProgramCompareMenu
3 r: e3 v2 r- h8 B{8 |4 \0 o( ]. W. U
    public static void main (String[] args)
- y5 _8 Z3 M% u# d+ |6 y            {
! b7 P1 t6 d! [5 k8 L                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 ?$ a  h, b) k0 `
                ProgramCompare reached1 = new ProgramCompare();
0 {' {# l" v: V# O                AuthorisedUsers reached2 = new AuthorisedUsers();        - S' Y, s/ z$ |  i* ]" D% d/ f4 [/ u
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 s% L$ B2 T2 [* K                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( g+ [) O$ O$ K' K- ^        }/ r# l, L2 j8 O$ H3 @
}// end of class ProgramCompareMenu
: j5 H. z0 B; N+ j( r2 R: e
" e+ O* d0 s. a7 ?& J: s' |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
% `2 _2 J, b- _//          AuthorisedUsers.java          Provided by: DRS
4 K0 K- E% N% `3 N) C- b//               
+ P: e2 w4 E8 h8 q& v7 B  R//         Program shell for Assignment 2) ]2 F  h2 j; r
//
) {. Y0 w2 `+ e2 X& l" d//         Represents facts about an AuthorisedUser( N& x7 x- y3 n* Y6 V
//********************************************************************
, S/ e9 p( J, i% s9 s& O/ r9 D
1 v1 J' v2 t% xpublic class AuthorisedUsers
( `1 G0 g) g6 r    {  Q( z% Q5 G7 g' h& A  {
& M% r9 n4 Y0 o: r; T
        //-----------------------------------------------------------------) C: V8 f: m; p
        // Constructor
' Y3 W, `8 `) g        //-----------------------------------------------------------------
+ k- z2 O: a( Z8 T. H8 I* a7 [% v  Y. Z6 V. x( P
        public AuthorisedUsers()
& Q: ~  r) @/ u                {
. C+ O" {+ b' O% z3 E7 Y                }
3 A! X/ E- L+ W0 C) P( s: h# J5 D- _6 X, ]/ \6 N
        //-----------------------------------------------------------------9 Y5 w# ]2 w3 P9 ?$ i9 J. ]$ S
        // Method for testing that class has been reached! x8 h4 f+ w2 ]  m
        //-----------------------------------------------------------------        ( P$ ?5 @7 E4 `0 X  M. ]7 @: |# \# C% N
        public boolean AuthorisedUsersReached()
. ?! K4 P- Z% B+ k. }                {0 P4 \6 }/ M. c/ V
                        return true;                        + H, k5 m9 I4 h* ^. r
                }
0 _* y& s7 D% B1 J1 W" _               
2 e. Y8 b% {& d' Y7 m. f    } // end of class AuthorisedUsers
' J& }1 i+ t  v( h) }  W& `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming4 S8 H, M/ h. I$ B+ J/ h
Shanghai - 2007* r; l1 H. x6 g+ Y7 r6 S2 l$ j' g
Assignment 2
6 G. \3 E, R/ Y3 C4 HDeadline 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)1 c( v8 _- d7 S0 h- I8 ]
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.
) I8 w3 @$ M% c7 R0 h$ jThe staff must be able to:
0 P6 V5 ^. n1 ]0 w& R Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 }  m/ t; y+ [
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.
. U& R) t& a. G The interface should provide a menu so that the staff can:8 d; n7 R* }9 \
a) Enter the names of the two Java program files to be compared8 j5 }7 q5 x7 K! c; h
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program." a$ {: x  o0 ]% k# f
** 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).( q$ ]! C9 _! j' L: \- s! O" G6 l
BSA104 Business Programming – 2007: Assignment 2: }$ E* k, M8 B( c0 L
Page 2 of 5
. i2 Y: s& E0 {( Xb) Print out to the screen all the lines of code that are the same; Z* A. A9 P( p* z
 Include the name of the file and the line number of the code being printed for each of the two files
1 ?8 ~! ~* u& Rc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
5 r3 }  u: w& M0 z" [5 G. | the name, username and department of the user! J; d" n! ]5 E/ u7 W$ h
 the statistics of the comparison# R4 a) j. \* F% ]( J
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 q% ?" X! y& O2 ^' e, Y: W. @$ o
 the recommendation for further checking6 ?6 M" D, a2 ]  Y' {
- 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 closely1 J! |- I  ^6 U2 v" V& f
 the names of the two files compared
' p9 ]1 c* M, }0 y  o* md) Leave the program (exit)
2 K9 \9 W( [. G' F6 w) q  }The ProgramCompare class: (Total maximum 20 marks available)7 Y1 Y- q2 z# i/ n( |
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)9 a# p2 J6 C& L  |' H4 s
a) provide an error message if the files are not found or there is a problem opening them
& e/ ?2 t: C) d! Q( X8 k: V; W% Fb) compare each line of code8 }1 F* ^. q3 g# ^
c) print out the lines that are the same. c& s( ?1 R* S, x$ B2 b
d) count the number of lines compared / lines the same
7 O0 i0 Z) {. s: h5 r7 qThe AuthorisedUsers class: (Total maximum 20 marks available)$ ^' f1 g3 n1 {& g. N( v3 K$ ]1 C
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)
" v% B% ~  U" M  @( I$ B4. Provide methods to:' _6 x; c$ g# p) R. L- Z4 D
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+ N0 f2 u7 y7 d- u7 D  L* j
b) return the name of the authorised user
) u& ?3 r. Y: t4 k. wc) return the name of the department of the authorised user
- A' B6 U; I( ]9 ~Individual Data (Maximum 20 marks available)
7 v8 ?; a& k- H- N+ m/ R5 S5 N5. 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.
5 D' a& ^  Y% n0 R# bDocumentation (Maximum 10 marks available)
% q4 _+ K" M' W- X6. 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.
$ N! T% h# M; G- s; F4 rBSA104 Business Programming – 2007: Assignment 2
. B: L  t* y0 O! p* f2 X9 @Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ c( U3 W9 D3 R9 L不过你要翻JAVA的类库说明。你有下载没有?
6 n; g+ U! o# S$ n# I' Q查询关于对比的函数。貌似关键字是contrast,还有compare+ A* i' r0 I% E" f- _+ k) F
# {% ]/ x. m+ W) l+ ~( H2 x
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% ~$ X3 P  t3 s. j) C7 t9 R
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
9 D) Y6 W# [5 C; ?可以下载到的 是 jdk-1_X_0-doc# ~' ^, o' X, O; E1 M
) b4 D5 U% V* F, N( p7 V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-5 11:54

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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