找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1344|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& t6 ?, A! [0 ^' H & z) P. b/ h. Z3 b1 h& ~
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
+ i8 Q7 ?& l* {( Y//  ProgramCompare.java         Provided by: DRS8 h" e* e2 s9 i* l3 U) m& U
//% U2 z2 T& D' p; X
//  Program shell for Assignment 2$ g) Z. d! \: W2 g1 s
//
7 j- b% n; }2 E: F//  Compares two text files line by line
1 a: o9 {* |% P+ f6 ?& X' i//*********************************************************************
" W* k% b$ i: e, \7 f4 J- A5 ?% {* X
import java.io.*;" I3 u, P, _1 \+ p( v% A/ O

1 K; t1 v2 o# Ipublic class ProgramCompare7 F& }# w  d9 R0 W- G
{
7 D/ a* @; @, Q* y9 r        //------------------------------------------------------------------ n8 ^' N7 {8 U
        // Constructor
6 `2 k& t- I+ }) P+ C9 H# _        //-----------------------------------------------------------------
9 Y  l2 P) X, a  O        public ProgramCompare()
6 P# q4 e0 `- G        {
( d+ X0 I% Y# ^- i  o        }( {) P8 V; z4 q+ V/ n, x

- H$ g- T& B" |' c+ [1 e        //-----------------------------------------------------------------5 a/ \: a, Z2 w$ P
        // Method for testing that class has been reached
' H3 c) @; f% W        //-----------------------------------------------------------------       
3 u8 Q/ i$ @0 A* A- X6 a
5 k+ x3 N* J) M; r5 C9 x& D        public boolean ProgramCompareReached()         & E( r- q8 v7 ]- k0 f
        {/ ~. B4 A. r* G. ?, y. w  {% J$ r
      try 5 \/ ]# L+ m1 @' z; D2 Q4 [
   {         * V+ v2 G& H; j# A+ A
                       
2 E  @3 F) x8 N5 [3 Z                //********************************************************************
% A1 t6 H' l  N. |! V  R                // Try-Catch Statement is used to handle exceptions - such as file not found 3 h6 L& u7 R" R; f& T0 J. U" o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. f6 M( R1 f7 y) b+ n+ }( [9 L                // For more information see page 534 of the textbook7 N/ V* \8 Y! H) u
                //********************************************************************3 h4 |; G$ p$ k% {8 e
                    
1 Y' G2 ^( N+ r1 E- m/ h+ T        }9 p2 q! L* O  Y& k4 Y. a( t
             catch (Exception ex) // Exception caught here and message displayed to the screen
- o, s8 K* U/ e( I: A, }          {
: @$ v  W8 C4 S% A                    ex.printStackTrace (System.err);
: f& J! x5 Y& t5 ~  A+ O           System.out.println ("Error message goes here"); // Replace this error message with your own         
' P3 @9 j0 h8 h4 K% D2 f) Z        }
8 Z' V; P  x# k0 F; `                return true;
0 ~, d* W/ D* E+ M; t        }2 k7 V" {$ u; B* l) ^  S( H* [: T
& _1 i( R- h8 f9 z% D6 Z
} // end of class ProgramCompare
4 p: `6 B4 ]- J
' R& h& Y& l5 j9 w( H- J- @* V( S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) F- q6 \1 U( e9 f
//  ProgramCompareMenu.java    Provided by: DRS8 U6 f3 K6 [# w9 E- ~# z& E
//# U8 m$ b' N' N
//  Calls AuthorisedUsers.java and ProgramCompare.java
: z+ C3 ^! x7 g* Q//; \! X) \4 I8 ^0 B" I1 W8 [, y/ R
//  Driver shell for Assignment 2.. T3 r9 N8 V, ?  O
//********************************************************************, ]. n2 _* J& a$ i
, c) @1 a8 F0 ]. S9 a) Y
class ProgramCompareMenu" B+ Y( C% k+ \' X" m
{) W- {' C! C+ z- J: V% w( f! k
    public static void main (String[] args)
! T) @. i5 n3 f) J, c" g) w. }            {: N# @$ c: l6 ^! I+ V5 ~* E
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 t7 x; |; ?, G! Y                ProgramCompare reached1 = new ProgramCompare();
: ?5 i2 M) D3 R; d                AuthorisedUsers reached2 = new AuthorisedUsers();       
. _2 l; q& }' Z: G* |$ B7 G' g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());( {& E( d$ j4 {+ x* t: d. P
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / T; b- {- q' K4 V5 p  o' q: B
        }
7 T; `$ z8 P& ?9 Z1 o0 k}// end of class ProgramCompareMenu
" L1 _; B8 j7 r, ~* H5 y9 F/ N, S) v2 a
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 m2 L/ @! f$ t1 J9 h5 ?! r
//          AuthorisedUsers.java          Provided by: DRS
; T) s" r. L4 S% d/ \//                ! V4 h4 C9 J) E
//         Program shell for Assignment 2* Q5 }" o' O3 @! [1 ^, ]$ m
//
9 `; m2 ^5 B- o* \  u//         Represents facts about an AuthorisedUser
4 P" u+ u& D) p6 x2 Z//********************************************************************& s4 @" A" T/ u
, s7 I6 d- j- A2 f! y
public class AuthorisedUsers
7 W0 ~9 W* ^* |7 `/ K7 ^    {
- P& ]1 y7 T) c3 R8 ~8 Y+ v$ Y! C* o; m) I3 g4 x$ T7 }8 K; r. c% \& w+ ?- \
        //-----------------------------------------------------------------3 Z- |/ Y5 G; f/ \! `9 ?/ U. {
        // Constructor1 S5 ]. p7 y* m( F! C* N$ w
        //-----------------------------------------------------------------
4 T  w3 E! w5 M1 j
& r5 |8 j4 h: Z9 x        public AuthorisedUsers()0 z9 A8 c' J8 f# h( K6 p: o' W
                {% U1 N) M8 G. {# K
                }
% |7 Z7 e, n' M9 L' u! t. J! q. k! M* {
        //-----------------------------------------------------------------% m6 R4 X& w% s9 v8 w
        // Method for testing that class has been reached- O/ g, r8 S9 N4 M
        //-----------------------------------------------------------------        6 l: h' E% W; m# ~1 Y1 f1 X
        public boolean AuthorisedUsersReached()
. G( d6 r9 `5 o# F7 |                {
) p1 e% [0 @5 i1 Y: x8 t! ^' ^2 x                        return true;                       
# K5 o& f2 [: u0 {                }# R) E4 y3 |- W- E4 C4 G+ E
                7 D& K* d7 z3 R. r8 I3 S! O
    } // end of class AuthorisedUsers; o0 D; j0 f" l( N. T! b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
. @& a, {- `" A2 r0 \0 JShanghai - 2007
# ?  V# G4 H0 P6 XAssignment 2
7 n. f  R, T7 f. g* N1 ^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)4 R* l7 _( f+ G" e; r
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.
& R4 |2 ^: h" l* z. cThe staff must be able to:- @5 S+ c% p) h$ M4 v( L
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. }" E' a+ ~7 ^3 M: f
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.
! q7 [; ~/ w4 m; d8 M$ o2 k" z The interface should provide a menu so that the staff can:  a  F, t- X) ?6 ^
a) Enter the names of the two Java program files to be compared
. z' n# N$ f' P# X! ? For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 v! q! i; M' r% 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).& o, E. V8 T$ X1 {8 W$ e6 C
BSA104 Business Programming – 2007: Assignment 2
5 S6 g5 b7 O/ H. L& KPage 2 of 5. p3 b8 h; y! G) A7 E, i
b) Print out to the screen all the lines of code that are the same
* [; ?$ O9 L4 Z+ ?; Y' A* A Include the name of the file and the line number of the code being printed for each of the two files6 p& L6 s. v- ^. `9 n" L
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; H0 f- M, r; @' F0 z$ [1 v
 the name, username and department of the user" x5 I# p8 C4 Q! d- Q& E
 the statistics of the comparison
0 `1 O5 J# I5 E$ i0 J2 W: E$ U- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different3 b( Q( O, M1 G4 d& \; q: w- x% [2 e
 the recommendation for further checking- }8 J) y; x0 m& D" G) O) p0 e
- 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
, L- Z( a2 D. u0 B7 R6 X the names of the two files compared( c7 Q7 V, m) j; ^! i
d) Leave the program (exit)
' T" M  q) w. k: M- G3 u, FThe ProgramCompare class: (Total maximum 20 marks available)$ f0 D" u- |2 a# Y+ D6 x) B' a
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); T' @7 A: S0 H" V9 |% ]) h% e; e1 W
a) provide an error message if the files are not found or there is a problem opening them
$ j) |: B* h8 O8 a& B% T/ d9 }b) compare each line of code0 _8 _( a2 [- u* `% ^) w: ^+ t
c) print out the lines that are the same
; O, K# S8 p1 g) \7 E0 ?7 {d) count the number of lines compared / lines the same
. J: T0 e' I* s7 P: fThe AuthorisedUsers class: (Total maximum 20 marks available)
% i6 J7 D) l& G0 V4 J3. 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 I! w1 Z6 [* C4 g
4. Provide methods to:
; O& D4 O! I9 v2 }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
7 s8 z: X( i2 @' ~: j4 e6 z; Vb) return the name of the authorised user0 ]0 `9 }) U! u' `' A
c) return the name of the department of the authorised user  X8 h( M% e3 b& c# \
Individual Data (Maximum 20 marks available)
( k$ p1 f, F% c& y* _% ?2 J$ _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.  I7 c* F: V: g7 T; R) e; T
Documentation (Maximum 10 marks available)' |' t7 x( W+ k1 F, J! W( r
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.
5 I  A1 X- E0 _8 bBSA104 Business Programming – 2007: Assignment 27 ^* D: W7 r9 f# a+ }1 ^
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 w3 j- m. D; q( O5 Y不过你要翻JAVA的类库说明。你有下载没有?1 y* X9 H0 a$ p7 _: L# x: Y
查询关于对比的函数。貌似关键字是contrast,还有compare
8 F4 z$ O4 H$ D
- R+ L9 V& `+ s9 B2 Q$ \/ o& W[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 P/ J: b$ o5 c9 K/ A+ n' Y
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。$ [5 Q/ E% p! v6 z- ~2 j; `
可以下载到的 是 jdk-1_X_0-doc
6 P: k: U6 [, _* B9 N9 o3 D- U0 _4 P, Q5 ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-3 14:53

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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