找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1235|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! P. O9 y) @# P: B T- ~& J. z) G & y. D( ^/ d( R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
1 S' t6 J: l& `) t//  ProgramCompare.java         Provided by: DRS
* t( x* |5 G0 X0 u) D//( z6 b) ]! U- o: n9 p$ d5 b
//  Program shell for Assignment 2
6 ]+ H* `8 v- N//
7 {0 n0 M4 @) P8 I6 ?2 B- x: h& e//  Compares two text files line by line5 @! D. d( m9 Q7 t, P5 K1 \1 C8 C
//*********************************************************************( u0 Y: ?4 B5 Y
: c0 O1 D3 |( q+ t5 X
import java.io.*;
9 ]7 o0 s9 U: E) ?/ s/ Y' o% F1 j& B8 C7 e& Z2 A
public class ProgramCompare4 ^: A6 _) i% v* e3 U- i& H
{
( |- i# p$ T( l! G        //-----------------------------------------------------------------
# s0 c* s7 ~* C0 P) O: x        // Constructor6 e$ l9 e' ^- n# g7 x9 |( S
        //-----------------------------------------------------------------
6 Q9 J2 A  n& o        public ProgramCompare()
- U1 o/ s9 p- u6 X, K        {4 ~* h1 N- U7 _) f
        }) L5 l: R9 S$ d  o+ R2 O' u- d* p

; x8 c  L5 f7 l        //-----------------------------------------------------------------
" T% s5 k  \: q/ `        // Method for testing that class has been reached
: c, z3 W8 z/ e3 A  \        //-----------------------------------------------------------------        5 K! u/ u7 a0 n/ v% g% M
8 e, d0 Q' w" }% q! F. x
        public boolean ProgramCompareReached()        
; B! k/ e1 c- Z) M- J1 V6 L3 s        {' Y" ?+ C- Y% @
      try
' B, O+ B' T" q5 d   {         4 t2 t; Z3 u3 Q' z# G
                       
# P9 Z  T; ~" C; M, v6 o                //********************************************************************0 y. ^$ Q9 u% u( }9 v2 |, y
                // Try-Catch Statement is used to handle exceptions - such as file not found
% j7 Z4 x; A* b9 l& S8 s                // Reading the files will need to be placed inside a Try-Catch - just like this one!
; j4 B# a9 c0 r- v                // For more information see page 534 of the textbook  U& G$ V" j  `" V8 n
                //********************************************************************
) U' k$ I, D- Z8 F3 J                    
6 O4 [) p% |0 S3 ^# \        }
/ L  W( U' T5 R( Z! E             catch (Exception ex) // Exception caught here and message displayed to the screen 1 _: L$ z/ L, Q5 H
          {* {" G4 Q( N) G: _
                    ex.printStackTrace (System.err);
4 s  B4 p7 O) `# O           System.out.println ("Error message goes here"); // Replace this error message with your own         
, L- s$ h5 |! P0 I" S        }) ]: D- [$ z/ p6 P9 P; k& J. D: ~; T
                return true;
9 E8 M* I! ?! N6 p- z1 Q( @  {2 C( M        }
  A$ M. ~' x( Q1 B8 b; W/ l
8 q5 G+ Q4 P$ P- s: p( {  D6 M} // end of class ProgramCompare
3 z2 r8 W0 M- D$ A  U' _) v6 k& ~9 Q. A( g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
; v+ n' ~0 F1 R( O0 V9 a( @7 ~- A//  ProgramCompareMenu.java    Provided by: DRS) r. `2 y. i. _! q7 {
//! J* E) w( i7 `/ u0 w( X
//  Calls AuthorisedUsers.java and ProgramCompare.java3 O* c% K' S: ~
//# u) B" l5 P/ q) n8 ^. ]6 ]5 Q" ?
//  Driver shell for Assignment 2.
/ \) N5 D" y+ v4 ^! v9 c//********************************************************************! O4 g7 M: F( c( b
" Y# n/ Q/ Y" J8 h  f
class ProgramCompareMenu
  R+ x. V+ P5 u7 X1 N& v{
; a5 S: {* y0 z: L    public static void main (String[] args)
. f: T1 u7 ~8 ^8 K( D: m            {
2 R, x! b  T3 O                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 l% `/ Z! W1 i/ h                ProgramCompare reached1 = new ProgramCompare();
) ]. K5 @5 m# m5 r$ |                AuthorisedUsers reached2 = new AuthorisedUsers();       
. p3 C& w; g% V2 Q  B& C                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 m0 {3 z' H5 s8 p5 V                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ m* K- t. o( G5 e8 Y/ |        }7 _8 B3 \8 x4 Z' @- E8 j
}// end of class ProgramCompareMenu: P  U$ h6 G: A/ n4 ?6 V9 G3 R

# r4 z% l+ H0 _; i1 f# V9 ~# h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. D* l4 @5 c) m
//          AuthorisedUsers.java          Provided by: DRS- B# C3 {; R2 Y
//                ( O9 B7 M& R# W* L2 P, t
//         Program shell for Assignment 2. c1 v& m2 w5 _( l
//2 }2 P5 Z0 o, Z5 c+ x" f
//         Represents facts about an AuthorisedUser
' l4 s+ w& c- f: [4 O+ e4 C//********************************************************************
5 x# G6 h2 P$ |7 R$ U9 O9 [5 B7 R1 \2 `1 d
public class AuthorisedUsers
  b) F5 s; e; e4 K/ k5 L6 M0 T  u    {* R! t6 {, i9 U5 f$ L
6 Z1 y4 T% U4 j) f' b
        //-----------------------------------------------------------------
- B& }+ f6 h) w, ^2 B        // Constructor1 B/ y" C) I# O2 U' R3 H
        //-----------------------------------------------------------------
9 g" u1 b  n, S% h+ B$ w* d8 x' W1 D4 X7 S2 ?2 ^  i$ s
        public AuthorisedUsers()% V( n8 o/ Q+ y  X2 g- E8 i( ?& O3 p1 r
                {
! |% A) v1 K" V2 L, J" d$ a1 n                }# g3 s+ n4 k- K: [/ P- t
; d6 M0 l4 K( b# c6 W6 F4 T
        //-----------------------------------------------------------------
7 f9 \0 R+ }' A2 H4 {        // Method for testing that class has been reached7 @8 N9 i9 A* w4 A0 @# v
        //-----------------------------------------------------------------       
8 z' `& Z: ~4 h7 Y0 C0 b& _        public boolean AuthorisedUsersReached()' d9 C& w' K$ r4 U" H  S" q
                {
) r. d0 ~- s& ~! m! g; q                        return true;                        & |* g. D8 ?' v5 \2 f/ ]# r
                }' Y% ^" @4 K. a- s9 S  e
                ) ^; V% F! E: J/ i$ y* D
    } // end of class AuthorisedUsers
1 [" z1 q' m2 j2 \7 c! P% ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 e8 L& w0 C, F1 VShanghai - 2007
' z; i$ t: D$ ?+ qAssignment 2( {3 T7 @2 O" t; Q) A, O9 {: C" 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)
$ }$ J0 p' `( F2 l" i3 k; U( M* e1. 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.
' A' C8 g6 }3 ~$ M  z  bThe staff must be able to:
) L* l6 |4 N7 F/ \. k; ^ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 ^, X5 X7 b) F, z( y! l1. 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% s9 a  W: |% x" X The interface should provide a menu so that the staff can:
3 o$ G: M/ Y% |7 j6 P9 fa) Enter the names of the two Java program files to be compared0 ~: c/ a1 k1 J8 j# l$ u
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 ?( Q0 W) t9 L7 ?  ]+ ^8 j5 p- 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).
5 o) R% M; P- Z) v; jBSA104 Business Programming – 2007: Assignment 2( E4 o0 U$ g, w( k; N+ c
Page 2 of 5
8 G% t1 g1 Y$ X! \b) Print out to the screen all the lines of code that are the same+ L3 X! m* H. U$ ~9 `
 Include the name of the file and the line number of the code being printed for each of the two files
; O! D/ H* e2 t& m# \+ H3 Jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. H* R  K8 Z& T* G
 the name, username and department of the user
- R% l$ b4 Q, h# o! R; k4 C0 S; p the statistics of the comparison1 Z# R3 e3 g: {
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 k6 A! B$ s! Y* s8 C7 y the recommendation for further checking
/ L& A: S8 d7 q& I; x& D- 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$ Q; O6 @7 O) P' n' b- L2 |6 n
 the names of the two files compared6 _, ?+ E: _* [
d) Leave the program (exit)
- ~$ l2 ~3 x' w. C; t4 AThe ProgramCompare class: (Total maximum 20 marks available)* ], _8 Z& O. P# u) d" W+ A& V1 I
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)
/ i2 F9 r- o, j3 ta) provide an error message if the files are not found or there is a problem opening them
* l3 D3 k4 x! w3 Q+ |b) compare each line of code* p& I5 n# \1 {8 f6 I3 @) V
c) print out the lines that are the same
  Y. n' r( ^7 K5 M9 S  B) b7 Rd) count the number of lines compared / lines the same8 Q+ u! `& G' M2 j- U7 b/ ~
The AuthorisedUsers class: (Total maximum 20 marks available), l& t; {  n$ c% p2 H9 ^
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)
7 O# P- N: q% P! [7 _* @+ ?4. Provide methods to:  S; p, j# P( I% |; [
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
5 U3 d3 O. \3 gb) return the name of the authorised user
9 v$ @# h2 S0 ^c) return the name of the department of the authorised user
+ i/ l+ ^) S) Y+ A! _Individual Data (Maximum 20 marks available)
3 N4 P/ [1 s1 K1 x/ e7 X5. 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.
& L) G5 V8 K7 J: F) S9 LDocumentation (Maximum 10 marks available)
" b1 z6 A6 a0 T2 @1 w* T6 D6. 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.
* B, D0 b7 {9 |0 U9 {: U2 X3 W' lBSA104 Business Programming – 2007: Assignment 2
1 s5 U# y7 M' k9 Q4 P' tPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. I2 d" m, r3 u, r# s. s2 f3 U* v
不过你要翻JAVA的类库说明。你有下载没有?
# S" u7 l4 [. K8 n( o. ?6 U查询关于对比的函数。貌似关键字是contrast,还有compare
2 A# z6 P! Q- w5 q2 C+ k8 Z# A7 P* s2 O$ k- k
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# R2 @3 V( f" q! Y7 U( q8 e痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ [& ], J) ?6 L3 i- K可以下载到的 是 jdk-1_X_0-doc
7 v3 _3 G. \0 b6 j
" N9 M2 Z( O/ x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-27 14:46

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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