找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1600|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 E8 y _" e1 I8 W/ l% y" a ; ^2 H i/ R! Y6 }1 [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
5 G4 z) b! m( p5 y7 |) e% h/ h//  ProgramCompare.java         Provided by: DRS/ y9 j' m( G& a) O% b! q1 Y
//; o$ o" @$ I* u1 n$ c/ D& h4 B
//  Program shell for Assignment 27 V! M0 o; X' D. B* d
//" X# N+ P6 P( D
//  Compares two text files line by line& m# v8 e3 O$ K4 y* g
//*********************************************************************" [/ U4 J7 C) Z/ ^% F

- O/ j+ b! i  @, T9 U! ]! Himport java.io.*;
" c9 F9 c$ _2 W  z" X2 F5 C' O* x  ^* v; p7 @' d) U
public class ProgramCompare, X) x8 r: S. Z
{" r+ W0 R' w& }% P$ X
        //-----------------------------------------------------------------
  z# P+ R# {5 X8 N9 W, k        // Constructor) O6 D9 ~% N5 i/ C# W2 h
        //-----------------------------------------------------------------
, p' t: A  O: ?: s; W0 z3 l        public ProgramCompare()
" L4 L. a/ ]: \$ R        {9 p+ n4 c- q. L8 V+ h
        }
# B- H& ^$ G# P% h
6 E5 r8 u4 A  c8 M$ T+ o        //-----------------------------------------------------------------
% o; G# h% F& A- o5 o' e/ r6 p! S        // Method for testing that class has been reached$ }$ j. R8 \6 G4 B
        //-----------------------------------------------------------------       
4 c, O: T6 B" ]& s; c0 j) T
2 ~$ [3 P& t5 X) H$ e% w7 \        public boolean ProgramCompareReached()        
0 L# ?7 M9 ~3 q        {
$ q1 t4 A  b/ v, L, W! [7 P% @      try 4 C6 T! x; c7 v# o1 g$ F
   {        
7 d& R1 c& U. F) y+ ?- A                        / @( B: o8 N, }( b2 b- {0 }
                //********************************************************************& g0 L: t& v$ H+ r, R8 \
                // Try-Catch Statement is used to handle exceptions - such as file not found + o- V; {  c- n2 M; J
                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ R- a' v7 p* `( R( U4 g
                // For more information see page 534 of the textbook
( \" `; [' @/ f6 R- }7 F% M                //********************************************************************* S$ f5 |7 m3 d4 a5 x
                     ( N3 f5 j+ N1 y
        }" S& l! M# b9 E6 b4 o
             catch (Exception ex) // Exception caught here and message displayed to the screen . W( B) d7 J  o8 s4 E
          {
+ _; g$ b$ @# @6 `. Q5 Y: s9 i                    ex.printStackTrace (System.err);
5 L3 @( r7 t! I7 \6 ^! n! ~7 Q4 H           System.out.println ("Error message goes here"); // Replace this error message with your own         
- B4 p  h3 L: M$ {2 i' i% y        }3 o, I; d" H: @% x8 a
                return true;' A. L8 r3 ?0 j$ ]/ b
        }
0 s. H) I% S( o5 [! N: s( O" P3 s  |
} // end of class ProgramCompare& l2 A! W- S, C5 D& ?5 t1 p
4 S6 {" B+ K1 \% W/ B! r9 c
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
% i, T! }/ S2 Y5 k//  ProgramCompareMenu.java    Provided by: DRS- Y# |0 V: }1 A  L
//
  D, l% S% E$ E# Q; J) M//  Calls AuthorisedUsers.java and ProgramCompare.java
6 B8 r6 t2 \/ M4 w0 c0 i0 R2 ?//
6 T6 e: r+ |8 p+ }% j//  Driver shell for Assignment 2.
5 c* m5 ~6 \; m3 E/ d- s//********************************************************************) F( y4 P) ~8 M1 N3 N
9 r! \( E( G2 b' ^/ H
class ProgramCompareMenu
+ q) S' P2 Z) i" p% \2 ?{6 t. e5 d: c1 z; u; f
    public static void main (String[] args)
( U/ z' `! ~. \            {
$ \* M9 Z9 g7 U                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 l8 ~  }! ~1 `! z" T& o                ProgramCompare reached1 = new ProgramCompare();
4 I' n$ x+ ^/ Q: m, \                AuthorisedUsers reached2 = new AuthorisedUsers();        " e1 {" w) @1 u
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 [8 T! I" d/ O8 M
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 y6 Z7 ?: f( [4 ]( W# y
        }
6 b2 A3 B$ B1 u1 J7 X6 p2 I- B* W3 F}// end of class ProgramCompareMenu; ?( ~) g% d# A" _- a

% D1 o$ J) {' q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************9 k+ ~' B! h0 p# @  x
//          AuthorisedUsers.java          Provided by: DRS& A, T* }0 U1 P8 I
//                5 r& x0 z$ b5 e9 z
//         Program shell for Assignment 2
) x  z* f$ O* {//. E$ Z. X: n& g9 f' t5 |( @% Q
//         Represents facts about an AuthorisedUser2 v* ^$ j" l4 a% i9 H
//********************************************************************1 S( q4 S( C2 K( Z( T4 ^2 R$ C
* F5 [. J6 q- [; h! a1 `. O
public class AuthorisedUsers
7 _/ A* a8 l; |+ \2 P( U    {
  w  g) E. z# y/ L4 P! x' o. s, N5 L: D7 z4 u! B4 c5 M7 O
        //-----------------------------------------------------------------4 A' s: W, C2 Y/ t. u- A2 z
        // Constructor& z: X9 n9 a% V# }' h& F& L
        //-----------------------------------------------------------------
* w' R  ~* }) K' A7 |/ J+ [
% N3 [1 S! k# \& c9 d( h        public AuthorisedUsers()6 W, g- X. D* w  V4 x5 H) R' e
                {6 ?9 S. _3 H0 X: H7 h* w6 q& u
                }
) l! A4 w5 B$ p. R& _2 Z$ w1 x# ~: G
1 g4 e  o7 F: x1 o7 ~        //-----------------------------------------------------------------
( a) M% Z% k+ q0 p        // Method for testing that class has been reached& {! [* g3 [0 Y+ I5 g2 j" {/ d
        //-----------------------------------------------------------------       
' q" s, p0 c" c' {7 I- B. h- S% N        public boolean AuthorisedUsersReached()
4 g8 F/ [, A( z7 f7 V                {
! @) d% ~0 i  A: L' ^4 S                        return true;                        3 T3 ]( J  D8 @& ^  q1 q
                }
/ V2 _" S3 T0 @                5 k3 m3 u3 c8 \+ N# b- M
    } // end of class AuthorisedUsers+ `3 \  t. S7 m# E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
. [4 k3 T* y3 N4 e$ k( ^( }Shanghai - 2007
/ S1 R9 c* Z( w# K* y( D* MAssignment 2; c2 ~$ g. \# ^5 `. F1 [; 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)
3 m& M+ ?9 @! ?* n8 @0 r) F1. 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.
: N' _) T6 T1 bThe staff must be able to:2 T: d, E) o9 Y' M
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 R% u6 G: L1 U! d% V, d
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.
. }( ~3 [$ ]2 R# x) t0 y The interface should provide a menu so that the staff can:
$ X! X0 m4 j; G" ~0 P: N* s9 Q% Ua) Enter the names of the two Java program files to be compared
8 U- f$ _$ W0 J: a9 p; { For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 w% w& z- H, \, V** 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).
3 o0 _3 j/ E( r5 E2 h7 j1 ~BSA104 Business Programming – 2007: Assignment 2
+ m8 @( w3 w$ ^0 {5 i$ q5 |. m+ }6 RPage 2 of 5
, U( V: o( p- B! y0 m6 W' tb) Print out to the screen all the lines of code that are the same
8 U& g4 g1 u2 O# ?% b! ~ Include the name of the file and the line number of the code being printed for each of the two files4 W- A1 J3 s: r) A; j' {; M- n
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 g" {# Z" P3 f9 d9 z4 B: a
 the name, username and department of the user
) x& X$ t% ^) Z& [9 O. g9 C+ c5 v the statistics of the comparison4 O3 Z# E( X  ?0 [, W( J' @
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: ?( ~( g+ R% e8 f4 y, M" D
 the recommendation for further checking
* Z# E: ~  b1 k+ `6 W: r- 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
) v' h8 F( s+ ?6 X4 B the names of the two files compared: m7 r/ ]/ n6 e2 q+ X5 ^
d) Leave the program (exit)
+ L1 C3 Q1 T- e% H5 tThe ProgramCompare class: (Total maximum 20 marks available)
1 F4 A5 e: U9 `4 o; E- j- x- p2. 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)
7 n6 y! v' g5 V9 `) s/ Wa) provide an error message if the files are not found or there is a problem opening them/ A* e% ^) A; }: ~$ A8 x, y
b) compare each line of code
) S% Y1 |9 R, I, T9 nc) print out the lines that are the same
! k  Q2 |& a- j( l" i4 Wd) count the number of lines compared / lines the same
  {# f% X$ W& Z, CThe AuthorisedUsers class: (Total maximum 20 marks available)
  `% b& P  {0 S7 w3. 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)
* u3 H, b: m  o: _" z2 p4. Provide methods to:
6 b) X6 \8 B: u# ~+ fa) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match2 X2 [4 B; i8 l% n0 j3 q: W
b) return the name of the authorised user4 i, D3 y; W' s
c) return the name of the department of the authorised user
: B! g1 X9 U, y$ @; {; AIndividual Data (Maximum 20 marks available)& ?; r- |: o( D0 ^1 O) j8 D4 ^* 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.
  a- J. j$ ]" G* y8 \Documentation (Maximum 10 marks available)
% u; D) {0 y/ G2 d6 A6. 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.
( k& y5 _+ {, b* oBSA104 Business Programming – 2007: Assignment 28 \, T3 J, ?9 l) @* ^+ Z# _3 b
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
) r, O$ C% J: O( J7 f不过你要翻JAVA的类库说明。你有下载没有?
' f; x5 X( G+ m0 Q% k  |6 b查询关于对比的函数。貌似关键字是contrast,还有compare- E! m4 D2 M+ b

9 J, k& ]6 E# J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 e  D  W5 f  H痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
/ d) {1 }9 s3 ?+ [, u可以下载到的 是 jdk-1_X_0-doc
1 ?2 h' n: N9 R. G, a5 I
! ?! J: l" ~* ?- N. ^2 E( f& r+ l- O9 }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-4 09:18

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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