找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1491|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 % E: e6 c; x& n9 [! l9 U) f. x 6 r, ^# @- D+ M& o4 u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************- J/ W# A. }$ K
//  ProgramCompare.java         Provided by: DRS9 ~# }9 j  d% Q; i0 X# C# l5 \4 X
//
; b, p/ r, s" M8 @//  Program shell for Assignment 2/ X9 P. q# L: D2 W3 X8 o6 [9 n; y; Z
//0 v% y# e" j2 a. S
//  Compares two text files line by line
! V2 y( ~2 o: s, J; d//*********************************************************************0 w, @* b# y7 D9 f& R; Z$ T, u
4 p* _& G( R2 j, ~
import java.io.*;
* D: |/ I* E& }8 t+ p$ Y
) x0 {! J7 {+ f: G3 {3 J" F& q$ cpublic class ProgramCompare% y- d8 m' @5 V* D
{- L% E/ f& W1 m% P) v1 s; d9 H
        //-----------------------------------------------------------------
3 B& a# _" ?! T% B- q$ V        // Constructor/ D% ]  f( a; f& I
        //-----------------------------------------------------------------( ~; Q/ M1 A; N, D: A( f
        public ProgramCompare()
# e5 C$ \: }  I* k. W        {& ^3 t) D6 `1 m
        }
# z0 e# G+ }) g) N( \8 \$ l' z! D; J7 Q( e# m0 H% ^
        //-----------------------------------------------------------------( D% l3 h) j7 |& I8 f: D
        // Method for testing that class has been reached+ X( q8 _. u, _2 K" _/ i
        //-----------------------------------------------------------------       
/ J6 d) k$ j8 c0 _" o
, {  s" V( C! t        public boolean ProgramCompareReached()        
3 K6 e* a9 ~3 r+ _. M' Y3 P        {: Q2 ]: h( t7 s/ S- S( M
      try
" w5 K& F9 p1 _+ R1 E  X8 }   {        
) G& t- l% N0 ]7 V4 E% o. i                       
  B* `0 `% O+ y8 P8 [/ @                //********************************************************************! ^3 O8 P9 F2 T1 r  Z0 o
                // Try-Catch Statement is used to handle exceptions - such as file not found
: g6 u' T, w  O2 n' k8 e2 h                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ K( Y5 b0 }1 e4 M4 e$ Q8 Z
                // For more information see page 534 of the textbook8 ]; d( m5 w" x0 j: ~
                //********************************************************************9 J& ?* X& q9 w: R8 i
                     9 ~3 O6 G: E* G) A( \- b
        }. k. c! [6 [. O
             catch (Exception ex) // Exception caught here and message displayed to the screen - B0 J$ O% q! o, K2 w, e% T
          {7 ], u; q' H3 S# z+ L
                    ex.printStackTrace (System.err);
0 `7 f: c" V8 y. J$ d+ }, y* X" p" U           System.out.println ("Error message goes here"); // Replace this error message with your own          6 \, L- S8 Y$ C& |. ^
        }
3 A/ L1 C* _0 d9 O" \: b3 f' f                return true;
- {$ [- M% Z9 W/ p0 W7 ]        }
, B7 |6 q" p: `9 P
% b2 u& ^& {( ?8 o, y9 J} // end of class ProgramCompare
# N' K. E9 j4 p- u3 G6 n% j) a- Z$ A" C8 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, k; X2 h% m- s4 y//  ProgramCompareMenu.java    Provided by: DRS% ^: N! U# a( ^+ Z& g7 u% ?
//
$ Y2 _5 l# P$ k# ^/ _. L1 Y//  Calls AuthorisedUsers.java and ProgramCompare.java
8 O$ A. x  }5 d  Z) h5 \$ o//
7 r* }" q: ]1 x  Y/ q/ F//  Driver shell for Assignment 2.
) C% o* C/ t1 N0 B//********************************************************************7 c$ ~; l  |# O7 |/ R7 u' d

1 u  g0 T3 i3 v" Qclass ProgramCompareMenu
) {) Z5 s* ?* }$ {' }" {{
0 ~5 S: [  q* b( t    public static void main (String[] args): @5 d# X1 j7 N/ p2 P& F6 |7 b% G
            {# c" N* x! H* o8 R  s  G+ Y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 g! D8 L& Y9 b( t& V& J
                ProgramCompare reached1 = new ProgramCompare();
5 u+ p( L; m' z3 G                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 Q; Q- p7 I; j5 I                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());; d+ ?1 v# I, U7 d& O
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 T: ^; C7 g( w        }
0 R8 y! w( z* `}// end of class ProgramCompareMenu: G6 Y& d  s% \/ v+ t" S2 _

( K, P* ], F1 y% S( k2 j8 H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' G$ x2 `: G& _8 |% F
//          AuthorisedUsers.java          Provided by: DRS6 H5 W2 \7 v6 R" P( m2 c: ^
//               
9 h) H( L9 m- ?2 f# ~* A( _: x//         Program shell for Assignment 2
0 j' r* e! v4 h# g" \//
7 \8 `  H1 y: G3 g; @& \. ^% R//         Represents facts about an AuthorisedUser
( l( k. @% N) k' e- u/ U9 n//********************************************************************- e6 X  g6 d* K9 ^+ c" X

7 C/ G5 ]" I5 L. r6 N+ ~1 n- ppublic class AuthorisedUsers2 |% t1 e) ]4 W  ]: J/ x& o7 ]2 t6 k% m
    {/ z& C2 Q1 V6 R
, L1 g/ F  {, q* A1 V
        //-----------------------------------------------------------------
) X! I( I2 K' ?6 A0 e' |        // Constructor
7 X" g' b: s5 q7 E( L        //-----------------------------------------------------------------$ h* e; ^6 V4 O" c

8 `. y+ }/ Z3 L: _' r        public AuthorisedUsers()
. G  V. T  S4 r* V/ M0 |                {* a, ~$ R7 J5 Z# n
                }
* R7 j! t/ U) C' D( @  N1 ~1 U. K: G
        //-----------------------------------------------------------------+ D5 F6 N; W4 K, R) Q
        // Method for testing that class has been reached" L( ?& i" h: L% j' p
        //-----------------------------------------------------------------        , \1 {8 y4 i, u
        public boolean AuthorisedUsersReached()
6 K: `3 {. U# A$ Y                {
- b6 }" h- A+ M) r1 a% `                        return true;                       
6 q* N4 `, v) K1 l                }
- Q4 v! m8 j$ s) X( C4 F               
; l$ B' E7 b( G0 R0 I    } // end of class AuthorisedUsers9 y5 ~5 ^& }% [: x! ]. Q0 E7 e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
' d* I2 k* O4 A8 {Shanghai - 2007$ [+ `! O) i# R
Assignment 23 p# ]4 y7 J2 i, r5 {" U9 c7 E8 i
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)
9 Y0 e/ s+ [: v+ i. f$ m- C  \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.
- K" x8 s; {% u# i1 e. BThe staff must be able to:: f% f$ J. O! K# F" T+ G& E
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 k$ I7 e9 n6 p1. 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.0 X8 w9 Y2 u/ s* J0 W
 The interface should provide a menu so that the staff can:
5 z* c, I* Y+ H& ]2 m9 P0 @5 w+ Fa) Enter the names of the two Java program files to be compared
' Q4 u( w2 R2 c3 j4 Z2 f& r For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- k% U* h8 B+ G5 r0 ?
** 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).% `+ q3 P$ o& \. s; t5 @3 J2 [
BSA104 Business Programming – 2007: Assignment 2& f8 ^8 e; P8 p( N$ i) r3 Q  z: m
Page 2 of 5
- b9 e" `8 |. lb) Print out to the screen all the lines of code that are the same
, ~2 f6 y. Q5 K" p, J7 u6 @+ @* v- R Include the name of the file and the line number of the code being printed for each of the two files7 p2 Z3 G) E8 U3 _: Q) j" q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
) ?9 l, ]4 B$ n the name, username and department of the user2 b1 I5 a* ^! K1 S
 the statistics of the comparison
' p" f' T3 i2 O; B7 f8 R- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" a3 s7 |3 w# F& k
 the recommendation for further checking
/ v* c7 j. v/ K+ L* ]- 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
( ~* @2 F2 J1 o8 K2 z the names of the two files compared9 B3 K, @) H+ I. i" v
d) Leave the program (exit)
& p  M0 y) Y, R; rThe ProgramCompare class: (Total maximum 20 marks available)
1 u1 o% J4 z: L3 |$ w, G% C2. 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)
* J- j  {. }' F' Sa) provide an error message if the files are not found or there is a problem opening them
+ d: k% U3 D+ _; x1 }, a3 @b) compare each line of code- l8 c. w9 N8 K6 o8 F8 h
c) print out the lines that are the same
0 T: F- k( H+ p- g  j/ hd) count the number of lines compared / lines the same( N. m2 ?- Z1 |, S$ k
The AuthorisedUsers class: (Total maximum 20 marks available)1 z! y! d( g% n  Q3 k, b
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)
# ~8 d2 \' ?2 m" n) U# C# V4. Provide methods to:
3 z( ^8 n) 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
: d$ n! U3 j! r8 K! ]b) return the name of the authorised user, [$ X4 _$ l) j- ^' Z* q
c) return the name of the department of the authorised user
4 a) s; d( J7 X% G3 {: p" YIndividual Data (Maximum 20 marks available)
9 n+ m3 I! t4 j2 f5. 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.
0 M% {, R  S6 hDocumentation (Maximum 10 marks available): E* |+ w2 h5 z' V1 y8 R8 P  @
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.
# O4 g  s$ z% r9 K! z& RBSA104 Business Programming – 2007: Assignment 2% i+ q% B- Q% W
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
  t/ O+ Z' N, F0 q不过你要翻JAVA的类库说明。你有下载没有?
: i+ I3 ?; O- _, n8 g* _查询关于对比的函数。貌似关键字是contrast,还有compare
" l7 L- a! d+ J5 z1 O" j/ o( Z4 K( P. c. v1 L
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 K# n) C" s) a7 R& A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
( T6 D2 J, I8 g/ F/ s可以下载到的 是 jdk-1_X_0-doc  b" S2 R0 z$ S0 }! }! Y, n" @% z
0 n) `7 t- q/ j) B: g; S+ H8 Z% L
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-26 04:44

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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