找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1720|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! y; U3 t$ F2 k+ }: k$ l; K! E& Q; M9 B& W
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************+ v6 V5 l: Q2 p- e
//  ProgramCompare.java         Provided by: DRS
2 V0 z9 M0 U% p//
) Z1 {- D7 J" O" u//  Program shell for Assignment 2# Z4 i: b* t0 i; n8 _# \
//2 i. \: R6 v7 h4 @
//  Compares two text files line by line
% `9 A2 c. G# }; Z1 z/ b9 x//*********************************************************************7 k: i5 K1 Q! t$ c: t3 Z& L9 j
4 J5 K4 _1 J% n4 h5 P" \& `7 C
import java.io.*;6 x' b+ j) _2 A9 c9 i0 ?# p9 F) h- y- n

5 g5 Y7 H$ k5 |5 O5 ^, s7 V. ?public class ProgramCompare5 u- c, j6 E2 i4 k, _
{! l: T8 ^6 _) k- H" T1 D7 J) ?
        //-----------------------------------------------------------------
0 U7 U' ?0 r9 b# D# m        // Constructor
* W4 x+ D' ^. E( Q) ~% b        //-----------------------------------------------------------------& O+ y5 I3 V+ D0 Q+ f- A0 Z2 j
        public ProgramCompare()2 b# U4 K1 f, k. E8 l9 m# W0 ~, m
        {4 _, |  j3 M/ d) R) A9 D
        }
) j1 D) ?0 O. `% b% D/ c" S' G% ^  }0 n- }+ \( `* h9 E+ a* y5 X
        //-----------------------------------------------------------------* ]+ U) ~# x+ J7 v& V. \
        // Method for testing that class has been reached
/ v. U6 s5 i, i, z        //-----------------------------------------------------------------        / V' j% A1 x+ `% s5 C

7 ?$ Z1 K7 m# F: w# F; k) _+ y8 n        public boolean ProgramCompareReached()        
2 Z* O1 m& O% C/ [; H1 X        {
2 a$ Z( _) `1 X9 p6 n, S      try
( g' e8 n1 y0 I5 P* U0 {& F   {         ( k2 b+ D& J! ?- r7 A
                        1 t/ }" L8 D1 O' Z/ e7 P, [
                //********************************************************************
+ V8 A' g6 T: @# x2 y* S                // Try-Catch Statement is used to handle exceptions - such as file not found
8 V- ]4 P. |0 O8 P/ B9 o                // Reading the files will need to be placed inside a Try-Catch - just like this one!
* Z7 Z! [& A9 {; X% }. F                // For more information see page 534 of the textbook
- e- Y6 z+ Y7 I+ J2 W                //********************************************************************# {& b) O$ R+ E  y8 }" d
                    
, i4 f) R* k$ N: e+ T        }
# A) }, ^6 M/ u  N" N2 E5 `             catch (Exception ex) // Exception caught here and message displayed to the screen
8 U$ _8 L8 S4 ?: p- H          {9 z9 X. q; J) H2 ]# O: j7 K( ?$ s$ L
                    ex.printStackTrace (System.err);! z  f2 C3 f! I* P0 H! s
           System.out.println ("Error message goes here"); // Replace this error message with your own         
0 W# v& E) [. m" J5 c& ^3 [3 D: s        }$ A! Z3 l. ?  h; t* N
                return true;
% k  d0 i: F% {  Z( e        }
" _3 H/ H: P, X4 T6 n$ s9 y/ V0 S# K8 ^
} // end of class ProgramCompare, _) _4 B0 W4 g9 g

5 V3 ^6 x9 m4 D: e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
  U  c/ ~  |( k# _- k7 A9 F//  ProgramCompareMenu.java    Provided by: DRS
9 t' c  u7 N0 m! c2 B7 O//# F0 x- q# i4 N( C5 ?* p
//  Calls AuthorisedUsers.java and ProgramCompare.java! S) Y! O/ v! x. Q/ F; W( K& S' t
//
1 i% Y# n0 F" S1 l  ^: f- t//  Driver shell for Assignment 2.  ~/ P  `* x1 E; G6 Q, x7 ~
//********************************************************************
. `8 H8 g, j3 X  l8 r6 U3 d0 C: @7 [8 q
class ProgramCompareMenu
4 u+ w1 j5 M+ I7 e/ _{
& J3 m/ n+ d+ M4 O$ L' f/ K    public static void main (String[] args)3 A  J/ s2 A( @! |3 z+ S; x4 r7 {
            {
6 j- j5 A  ^+ R: q& z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- G- k6 c; b9 k* [: y& u4 L                ProgramCompare reached1 = new ProgramCompare();
/ T/ x" X, B& c9 x9 Z# {$ h                AuthorisedUsers reached2 = new AuthorisedUsers();        3 }; t! }+ F1 M/ D
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ P/ v0 w% x& u4 o  L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) n; ]7 _$ n; c4 `, {        }
$ Q* @+ ~2 \4 s  R4 P' f}// end of class ProgramCompareMenu* a; L( V  T1 u% [; D6 X

1 a; O; M( k" N" [2 ?" ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************( ]$ A6 M: `: R# w
//          AuthorisedUsers.java          Provided by: DRS" o: P  W% U6 Z3 R/ y
//               
& D  w0 ]/ j& Y' h, e//         Program shell for Assignment 2
, E! C3 f" [5 Z  l8 X5 O5 f//
9 w  n- S( Q# O//         Represents facts about an AuthorisedUser3 E' X3 r+ d( V. o. i% j: Y
//********************************************************************
3 t, ]& ?7 L& ?* o7 V& ~- p0 |0 Q2 s2 z, d8 u/ J
public class AuthorisedUsers/ A+ x) i: J; u
    {" p9 ?  a9 z( U) e* l4 p

+ Q! S$ U! ]7 h9 B) y        //-----------------------------------------------------------------
, A/ k! z  }9 a$ n9 z  h* O        // Constructor
  J8 i: s, M' m8 v+ y& p( f: `        //-----------------------------------------------------------------2 F; |1 f- Q( ]9 k
% K7 c5 q  @! X4 [: r; \
        public AuthorisedUsers()
# F+ ~. |) _" c* b7 Z8 ?: x                {
+ L1 J4 o1 g& w, y% D, e- V( C                }. T- q! Y/ @' N& ]! U, h0 V- i1 D3 x
7 l- ?2 O7 }9 G$ k0 @1 W$ N
        //-----------------------------------------------------------------
3 |" L9 }% V& e2 |: L        // Method for testing that class has been reached0 `! K9 b4 ?$ q& f8 b/ o: @
        //-----------------------------------------------------------------        % A( i( H/ S. S8 z0 h; @/ c5 v
        public boolean AuthorisedUsersReached()7 S' G. @! L, x+ d* z' n
                {
4 l. O5 a. d" ]8 G$ F. t; ^                        return true;                       
: k4 s1 Q6 P, U                }
5 z- z4 U3 |, M: X% E  v               
2 q) o1 X3 V: e0 q2 X  l+ U    } // end of class AuthorisedUsers+ k! k2 f7 ]+ x7 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! I9 z5 Z! Z* F4 p1 Y$ yShanghai - 20076 ]8 k, l' ?6 o/ E
Assignment 28 t( [. j1 f8 b1 t. X6 Q4 i7 ?% Z
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)+ A. |+ H  S. _1 G) 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.
- I- W2 Q2 m1 f5 Z0 uThe staff must be able to:- I1 Y* A& N( l0 a$ c- s% P0 L" P
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 M! L' n. V' e  A1. 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.  Q: J9 V3 N5 y/ E- X
 The interface should provide a menu so that the staff can:
( l! \1 p0 G6 x9 I% v7 n1 }4 Qa) Enter the names of the two Java program files to be compared# q, ]' o1 _/ s  i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 ~; B9 H5 Y% d# t$ L3 ?- |8 G
** 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 C1 X& H2 `+ {! v7 s. U- T. tBSA104 Business Programming – 2007: Assignment 2
* V; |/ E* g2 z. c6 u- {: k: YPage 2 of 5* A# |9 i7 o; i$ c- v# @$ s
b) Print out to the screen all the lines of code that are the same
7 C) h4 K0 t% a8 y Include the name of the file and the line number of the code being printed for each of the two files6 h  x1 c& T/ Y8 Y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 p- @4 e3 v& b/ J4 c
 the name, username and department of the user$ z/ _+ ?' E% h- g1 _
 the statistics of the comparison
' N6 C6 ?4 K1 k, m2 D- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" b. _) _  T! n1 ^4 M4 B, S$ B+ C the recommendation for further checking
% s% U* @# H# B- 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 Z6 }  n# @# \. ^ the names of the two files compared
1 n5 T4 W$ D  @  F0 \" xd) Leave the program (exit)+ N% x- \$ ^: ], s3 R5 K
The ProgramCompare class: (Total maximum 20 marks available)" Z6 Y* k. G+ x5 |7 L1 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)- r* [/ }, t+ K- F# A
a) provide an error message if the files are not found or there is a problem opening them# J  v# ~* N8 z" G; J3 J
b) compare each line of code
$ A$ K  F. L2 x* r0 V) O/ gc) print out the lines that are the same
3 l$ }4 k. i& N* yd) count the number of lines compared / lines the same) X& ^, B( M+ H% U8 M
The AuthorisedUsers class: (Total maximum 20 marks available)0 m6 R- J) B: S% D
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)
' X/ ?  ^% e5 r9 I9 m4. Provide methods to:
; U6 s& `, H0 U  ]  Sa) 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
# d& U5 H0 Q) O/ I0 l  x" Wb) return the name of the authorised user
5 Q4 h/ `9 S2 s/ y/ M( i4 X- Xc) return the name of the department of the authorised user3 m& ?; b4 F+ |6 X! y3 p5 z
Individual Data (Maximum 20 marks available)' R( s' Y/ K+ V9 K+ C3 H
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.
* K! y  r) N' g% Z) u" t3 dDocumentation (Maximum 10 marks available)
( ~7 n* T3 A0 i  J; w' u6. 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./ E$ c* b; u. S9 _  o' l1 g
BSA104 Business Programming – 2007: Assignment 2
; s$ z1 w% ?( B- H3 j# _Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 g! x0 h! t+ Q& O; n( u; l
不过你要翻JAVA的类库说明。你有下载没有?
5 H# z3 `0 R  f% k8 U查询关于对比的函数。貌似关键字是contrast,还有compare( t% n/ c/ v. Q4 t, k4 M
6 E$ F  i1 A$ J4 U5 S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 z1 L( a1 B: V( N, q痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- T* i" x, N! ]可以下载到的 是 jdk-1_X_0-doc  ]; |* _0 c3 l% q
: L5 k3 }; g8 U; b
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-12 00:55

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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