找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1515|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急' e7 A7 d% |. y; j* U - e+ m5 N2 [9 Z/ F) e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 [% ?2 R, X' f) t
//  ProgramCompare.java         Provided by: DRS3 H3 J. N: a) Q6 p+ `+ \
//
, _. R8 D! G/ H. |9 e& J//  Program shell for Assignment 20 x, a. y+ H8 p6 I
//+ }- f+ o  y9 ?8 X
//  Compares two text files line by line
! m- o7 N' H* {4 s5 K//*********************************************************************6 z' y  k3 Y! A8 {9 ^( P) c( K

, u8 ^. j; l# O* L$ f' b% e! limport java.io.*;. [5 J+ i* C! f
+ x  V* G: V) J& x! O5 T
public class ProgramCompare
5 J- ]$ ?" Z2 g; @+ U{
! t7 k$ }3 j, z  y8 K: i, y        //-----------------------------------------------------------------0 S" H9 x% T# k4 D, Y3 j- C( A
        // Constructor1 z1 g4 K+ A& W
        //-----------------------------------------------------------------
* A9 T% h& {( `9 c0 A, a        public ProgramCompare()
' j6 ]6 O! g* |  f        {6 |' D+ D+ \% a' O7 x- N  D
        }1 M) A2 }* v9 I1 b: `
6 n: A  V( s! B) P. }# S
        //-----------------------------------------------------------------
( C; r# l2 R  ?! y) @        // Method for testing that class has been reached
4 M2 Q5 c0 e/ d. ]3 M6 v4 {        //-----------------------------------------------------------------       
6 ?6 Y! V# P8 H* x. D; r1 g4 Y" D* Z3 R& W3 R" s8 l9 u3 m- |$ c
        public boolean ProgramCompareReached()        
' v5 u# n6 ^4 K        {
; Q6 ]; V- O6 t7 }      try 7 u0 Y9 h$ i" M; R( M( Q/ b* q  Q/ e
   {        
  N2 P) M4 O" W. F9 }0 x. V                       
# _: ^' F. U- b6 t                //********************************************************************; Y' y7 T# u- H$ Y" h
                // Try-Catch Statement is used to handle exceptions - such as file not found
+ }# }2 X$ w3 p1 r4 @2 l* m                // Reading the files will need to be placed inside a Try-Catch - just like this one!
5 \# K/ ]3 L3 ?                // For more information see page 534 of the textbook. R( w( ]4 F  l. X4 R, K; G
                //********************************************************************) f, R# Z. j2 u
                    
4 L' n4 n* z3 m0 u        }% d/ E  ]' a% q" P$ J, ~
             catch (Exception ex) // Exception caught here and message displayed to the screen 4 V9 C5 p- A( B. o' o# z& ?
          {
' W  h  T  m7 j0 ?                    ex.printStackTrace (System.err);
4 g+ U9 B# K. f. x           System.out.println ("Error message goes here"); // Replace this error message with your own          + N: ?& Q: ]- d1 _; R
        }
/ O- A# h2 q  n                return true;
+ q. Q1 I$ f% x' O        }$ w. L, W/ [1 x

0 P6 ]& L$ p! }0 L5 x) I' }} // end of class ProgramCompare
  E2 }  a7 r. Y( X% d5 m
/ o0 O. C; G4 Y6 s/ y9 b( |& F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# i- z; P4 h! R7 N& |. Z$ T0 O
//  ProgramCompareMenu.java    Provided by: DRS( R- c$ Y& C8 e# J" {
//& R, \& `6 r) F% k: {% L# d
//  Calls AuthorisedUsers.java and ProgramCompare.java
% s- U! x) z4 c//
3 `$ O3 u+ |2 D( b2 x8 K( y//  Driver shell for Assignment 2.( X  k9 I+ r$ v! b7 `
//********************************************************************
( c! Z* p% D5 N9 ^9 J' [0 `  u1 o
& s" H) q  h* g7 M) |class ProgramCompareMenu
$ K4 K) V3 o- D6 e{0 A- \# O: ]/ y8 b1 V9 q  n. h
    public static void main (String[] args)
# |0 h, V$ C* J            {% u( I2 B5 z7 L( ~* U' D8 V
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- H; U* Q! @. H% D
                ProgramCompare reached1 = new ProgramCompare();
! w+ W% f6 F% P# J                AuthorisedUsers reached2 = new AuthorisedUsers();        - D7 @1 U7 H; Z  g
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# W3 e. o" t/ i( l9 s1 {; a+ w& D
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 G+ \5 R9 z  h& D* W        }# p3 l2 b. W) w! d& c
}// end of class ProgramCompareMenu$ M& Q( F) B( M, }# Z6 a

( l; r( w1 x( o1 B: A9 C' a5 U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 _5 A3 q- J3 k: H& O4 v3 j
//          AuthorisedUsers.java          Provided by: DRS
8 W6 i  ~. u5 V6 t* {//                ' b4 [5 R/ s/ a6 J* R, Q$ ^9 m+ q
//         Program shell for Assignment 2
3 m  F1 T4 _$ b3 w/ W  w5 [! F1 {//
1 H. ?1 W" k# H, b0 k" g//         Represents facts about an AuthorisedUser
: Q# N( y/ g9 t2 W$ D/ ~1 x6 R6 P//********************************************************************  H# L, ~  g: S7 T) f1 M3 _+ Y

4 I! x5 E/ r- z6 xpublic class AuthorisedUsers
0 K# P. q' M) x6 p  L    {9 x3 N) V6 S3 C, G/ ?# j
: G6 W5 @, F# m' b3 B3 D' s7 U8 P
        //-----------------------------------------------------------------
6 z' X2 O$ R, ?: Q, s7 L/ I        // Constructor
: p7 q1 |$ I/ I7 h* M" o        //-----------------------------------------------------------------
1 G0 C  a* M; y; h! v
; a4 M2 s/ m% p( h        public AuthorisedUsers()3 B! y5 x! X0 B" F3 p$ _
                {
; x, I; Q, f8 A. o8 ?4 @- }; J; y) ?                }- a' c* t3 R% ?1 w5 c3 }9 o: N, Y1 }
. ?, b/ T! `4 E- f: X& o
        //-----------------------------------------------------------------1 |: |% o: l' K0 H1 E8 O( {. e
        // Method for testing that class has been reached
- W& h) X/ m/ x7 Z        //-----------------------------------------------------------------        6 Y" G; W* m! b
        public boolean AuthorisedUsersReached()( l$ L) i+ p# v  z- @
                {
* ^( ]; ^1 U( t! U                        return true;                       
$ V+ ]' A" T6 o5 r- C4 Y                }; k( G% |% m# L( m3 v
               
; @/ z% z9 v3 c1 [    } // end of class AuthorisedUsers) k- P. H! ^7 A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
7 Q" C6 z& l+ a) P. V+ P0 aShanghai - 2007
! f6 p, c$ Z2 WAssignment 27 n4 s2 {$ Z8 N* @. |8 m: N$ ]
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)
/ t, S4 H9 C2 q4 ~+ e2 a3 ]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.& V; S- S8 D4 L, h2 K& f1 O
The staff must be able to:
  U; C: t1 D% W Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.; s# {) i- L; L3 d5 b& p; Z
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.5 H4 P* n0 Y) A' |& L
 The interface should provide a menu so that the staff can:
6 ~2 B! u) a1 q& e/ K; xa) Enter the names of the two Java program files to be compared; k( f4 c9 S* W: Y' ]- E
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
; g4 M1 K9 [( T* Y4 m+ K5 |' J3 j** 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).
+ n9 y, t" {. i) p1 z) {& P' z1 |BSA104 Business Programming – 2007: Assignment 2, b/ [8 P7 ]' s- f$ H8 I9 Z
Page 2 of 5
  {- F' C2 J6 O8 xb) Print out to the screen all the lines of code that are the same
1 ?  n: C# I: L, U& c* O  ^) d Include the name of the file and the line number of the code being printed for each of the two files
# a( K3 H1 e% n/ F" T6 Mc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 h0 W3 o, _3 r- G
 the name, username and department of the user
! H1 Z8 v& `: M! J* L1 ? the statistics of the comparison
- O# }; ?" ^* b- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
# n8 Z& {) D$ ` the recommendation for further checking
+ j% l, k8 b2 H0 u: ^- 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) i7 T) _- g# M0 \+ C, H
 the names of the two files compared) H3 L& C5 @. N7 X$ x
d) Leave the program (exit)
* C$ i/ q# P  TThe ProgramCompare class: (Total maximum 20 marks available)  Z6 q7 g. ~, x1 e  |' `
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)
. S. w3 \3 G7 K2 [" ka) provide an error message if the files are not found or there is a problem opening them
3 H! ^4 b+ U  O" e$ _b) compare each line of code
( U! V( K2 ?! F# Nc) print out the lines that are the same
# v5 q: N* v$ Q/ nd) count the number of lines compared / lines the same
9 p  b; y9 K4 {6 [* @; L5 a" bThe AuthorisedUsers class: (Total maximum 20 marks available)1 [, J& R6 S8 d) N; h4 j* j2 \. e
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)
$ Q1 `1 \5 c9 V4. Provide methods to:& z5 t4 ~$ A# N0 E6 d4 [; _) P
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
: L# _2 {: n6 D2 i  eb) return the name of the authorised user
1 `9 j2 e5 D5 I% \! T) Yc) return the name of the department of the authorised user6 z/ S, |7 L; L% J
Individual Data (Maximum 20 marks available)
# H' m8 v, [8 R+ o8 q* G3 T6 D* z: ]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.# O: a  \  q' R$ _1 p
Documentation (Maximum 10 marks available)
1 E( k  B% f/ v* D$ U9 Y" i9 s6. 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.
0 [2 Q( X8 t7 u7 }BSA104 Business Programming – 2007: Assignment 2( ^. M) L+ M& b$ m. d- h" Q5 V$ Y4 j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了% O1 z. n# ~2 T2 X* M( ^
不过你要翻JAVA的类库说明。你有下载没有?
) ^5 ^+ B# ~0 n' f查询关于对比的函数。貌似关键字是contrast,还有compare
: s* \$ l; V- i8 W
. m5 V3 C. T% q. \* }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 x! `6 I/ p- @; J$ U* d+ q痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* w" x! o3 K0 G: T1 v可以下载到的 是 jdk-1_X_0-doc
* Y! s2 x9 M% y0 \: n% z$ N2 \/ {' }; U# l9 s0 h& [- P! c8 b
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-2 03:26

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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