找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1448|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急) b: Z1 }. V6 R $ ~: Z; e) q# R: T# Q* z( D& m6 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 | 显示全部楼层
//*********************************************************************- \* G6 r$ ^* T) U; L1 A/ W
//  ProgramCompare.java         Provided by: DRS
+ u3 Z/ p' c% O1 ?6 X//1 d. a# L/ ~) p' y4 ^
//  Program shell for Assignment 21 d1 W  X3 \( |- V# n
//
- T/ @4 b- f' Z//  Compares two text files line by line( H/ K' E  `5 j+ }2 i0 U  J# W* j' b
//*********************************************************************
& m% t& d2 p# W! E/ X) Z( R: \8 _# ?# b; q3 P3 ^, x; C
import java.io.*;
3 g5 Q- I' p/ l
! b- F3 ~" e1 f- j; v' lpublic class ProgramCompare
: k0 q+ g, `- }% T( v7 q; I( C9 U{0 ]% F: I' l/ B
        //-----------------------------------------------------------------
, V5 {. ]' \, T. V        // Constructor" q  |# q2 F+ \& `7 T( W
        //-----------------------------------------------------------------
( [: V5 F+ H9 X! C9 }0 y7 S: r, [( I        public ProgramCompare()- Q" v9 z1 V, @, W$ J
        {
, f! n; A9 w$ _% B) o        }
  i# j6 {) j. s0 c! b* S1 n* I* I" z, V& |: ?
        //-----------------------------------------------------------------$ G/ Q, r9 L2 I$ `& K
        // Method for testing that class has been reached
# Z" V- k2 q8 O        //-----------------------------------------------------------------       
& d$ M* k! Z5 N$ C4 _+ ~9 E) `- g6 K  K" _
        public boolean ProgramCompareReached()        
7 v. w2 I% M$ Q  u) P$ n        {+ E# X# r; ?( r
      try 2 i+ A& s! D0 k+ T* X) Z
   {         . l0 y" q+ [4 M) b+ k; r- U
                       
( a/ N( @, d0 Q, J- P1 Z                //********************************************************************
; U! f; n. z5 f& T2 m- e; i                // Try-Catch Statement is used to handle exceptions - such as file not found ) v% [3 r* p( O& `0 [/ U+ B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
5 [, ?2 J0 a2 s                // For more information see page 534 of the textbook' Y0 `% U0 |+ S
                //********************************************************************
) C2 d! t% H/ \/ h" p- @8 \& Y3 |                    
2 l5 h. _/ b+ ]( S        }
+ K! V# O* J, `& ]3 }             catch (Exception ex) // Exception caught here and message displayed to the screen
- j. {3 w0 j! q! @: D          {
5 ~! {9 q$ }" w) f                    ex.printStackTrace (System.err);, g, }. [3 N2 T2 t1 k6 J. Y( ~
           System.out.println ("Error message goes here"); // Replace this error message with your own         
( C' [& U3 J" B5 N8 q        }3 [- ]- r: |( }0 D# g
                return true;! r2 I  H+ K% n# [7 T
        }
3 g4 Y* O  {- B9 k; D% g6 E
3 Z0 z9 \! o7 X$ C} // end of class ProgramCompare* O7 E. ?: l" {; p3 K
& s/ G; ~( @. d
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 D# _' v# I+ G* |//  ProgramCompareMenu.java    Provided by: DRS
% ?# K2 q' l: s5 A; n% V8 B4 a//
5 @% g" g9 S$ V1 F  Y% s//  Calls AuthorisedUsers.java and ProgramCompare.java; f* f. k, a( y4 g7 T
//
$ b* |7 k& u( q  g//  Driver shell for Assignment 2.1 A6 n8 ~& \6 h% E" I0 T: t
//********************************************************************
0 _( T' g0 a4 t. d
1 U6 N% F* U1 ]; p$ Sclass ProgramCompareMenu
6 E' r! u: B" p+ i{0 V7 S( t5 L( ^5 N7 A2 f* j. b
    public static void main (String[] args)" i6 c, O" N& R$ E! Y
            {
4 G' a0 r% h' P8 C8 J3 N* f                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 V2 D* V) _* x2 w                ProgramCompare reached1 = new ProgramCompare();
, @5 i5 N# O$ I- _( c8 T                AuthorisedUsers reached2 = new AuthorisedUsers();       
  P* G, \6 r/ S, U  {0 _                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- P; t6 `- Z$ ?' h
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- r4 ^8 P5 b4 g: `! f        }
" U) I- ?6 c# S1 l( p7 J" T; r4 ^}// end of class ProgramCompareMenu
0 |' M+ B; X7 n% T
2 h! M7 j3 Y0 _: N8 B8 x$ c& @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 Y& G0 V+ n9 `4 n3 ?  P
//          AuthorisedUsers.java          Provided by: DRS* u4 B8 b+ l1 ]6 ?1 J: E; ]
//                # U% o: j- L/ y8 J( i7 Z' }
//         Program shell for Assignment 2
9 L0 F5 q6 E% I! N* q//+ Q# q3 C3 O+ Z0 N0 H! q& c2 m
//         Represents facts about an AuthorisedUser
# B$ W. F$ v) v( e//********************************************************************
9 Y; c6 u9 @, C. G0 @& k' K, p/ {- e! _$ O* _
public class AuthorisedUsers
  k" K1 H3 k2 w    {5 n1 ~2 F7 P% k0 w
5 [5 H0 {$ }6 R, D, x% V# T$ Q2 H/ ^8 f
        //-----------------------------------------------------------------0 A; ?' v5 p; C9 b' T- q& [
        // Constructor( U1 t; G" ?  o
        //-----------------------------------------------------------------
7 m" T) m1 g. }. ]
9 C+ o9 S2 B# ]) S; `$ ]        public AuthorisedUsers()
1 o$ L) M( ]6 ~                {
+ O7 a! y1 o5 }( I* H                }
% I0 V: F9 O- K8 A" Z) |+ c9 {4 U" G) N4 z
        //-----------------------------------------------------------------' Q. b" z" K7 b; z7 k6 q+ w) s) V# C
        // Method for testing that class has been reached, l) D2 d  o) b1 C1 X( l
        //-----------------------------------------------------------------        7 N9 R! S6 ]" y# W6 T1 k
        public boolean AuthorisedUsersReached()
" _0 B: ]! x1 j1 t                {% W% g7 V+ x5 L% N$ ^( I7 w. b
                        return true;                       
% J0 @; Y5 [9 Z7 t" |                }/ r! `6 ^  r3 c4 z8 I6 n7 G
               
3 N  \, d, Q% Z, C# w7 i    } // end of class AuthorisedUsers9 Y: O1 |1 t- S/ \: g8 J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) P4 I& X; v6 u% N! f: V/ U
Shanghai - 2007
. b  [; i# ?( ^Assignment 2
$ d) T! k: Y* z5 d/ z. P# o. wDeadline 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)8 Q" M7 `$ j) P  B
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.
' `4 O) V, ?) H0 u  X( r. H3 DThe staff must be able to:
  G9 y/ ]* {# K- N7 {) Q2 m Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
) H" P& P+ D% k# C8 h! \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.. J7 ~# Z: n4 c/ e( c
 The interface should provide a menu so that the staff can:4 \* ?6 C5 G# z0 n: |. `* u+ m- c6 a
a) Enter the names of the two Java program files to be compared
& K- s7 w/ x8 y) p% _5 K. }2 X For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( e2 o! g+ n! l
** 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).4 e  G: }4 k+ M4 @/ u
BSA104 Business Programming – 2007: Assignment 2% b5 L1 A, O9 H* T9 f/ q$ @
Page 2 of 5& R- a. N3 w% @* G2 r) s
b) Print out to the screen all the lines of code that are the same
6 Z, D) \, k- e1 u' C0 ] Include the name of the file and the line number of the code being printed for each of the two files; ~! R/ e+ a3 l5 y5 X
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& `! _2 A. m' W- N; S, l; D
 the name, username and department of the user
& ?" a. K: z  P4 {5 \ the statistics of the comparison
* a' Z2 g, J1 T: \- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 a' X$ \' h# n; Y
 the recommendation for further checking) O% t5 v8 s4 Q. M4 ]% O
- 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 closely6 M& w: {# _" U2 {+ O
 the names of the two files compared/ L8 \  L: g9 C8 e4 S# d: l2 t) |- a; \7 W
d) Leave the program (exit)% f6 A0 d/ E8 c! l+ |
The ProgramCompare class: (Total maximum 20 marks available)
) W1 d, A7 M+ b5 \+ b2. 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)& Q6 R& S* u. }
a) provide an error message if the files are not found or there is a problem opening them0 u* O' ~/ m, ~$ X
b) compare each line of code* v2 q( b# b0 D; h% w  f- U
c) print out the lines that are the same: ^( R, f/ q2 j# n) U" k; t, D/ o: Q$ ?
d) count the number of lines compared / lines the same
  d" x$ y+ {( w& zThe AuthorisedUsers class: (Total maximum 20 marks available); ~8 L7 {# ?$ ?" [# h
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)
* K* A' s3 F+ l4 y- u, V/ A4. Provide methods to:3 Z/ I& q+ A$ |
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, z" T7 a9 B4 l5 V$ \
b) return the name of the authorised user7 e' f: [& l" t
c) return the name of the department of the authorised user" Y  _1 U+ t6 h% Q5 z2 y
Individual Data (Maximum 20 marks available)
8 a8 m3 ]3 [0 B! o" a6 f3 }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.
6 X; B" N. ?# Y5 F% ?4 I+ {Documentation (Maximum 10 marks available)$ ~) W) ]8 T: H5 ^: i, V! b
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.
% D8 j  x2 ]5 i5 z- ~  P' A* ?2 \BSA104 Business Programming – 2007: Assignment 2& n0 L1 ]& r8 a/ s- R) o
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! K/ [9 a1 d3 B/ I不过你要翻JAVA的类库说明。你有下载没有?* @# \* T. n/ E3 l4 b- K/ }7 Q
查询关于对比的函数。貌似关键字是contrast,还有compare( `- m3 f8 u- u+ Y+ R
) s* B+ U( l; P$ n- g, s% ~9 ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -- W3 d& E3 Z# h5 f1 d; g# B6 B
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! u; {- o3 o0 F
可以下载到的 是 jdk-1_X_0-doc/ a* K4 ~9 e. s% ^5 ^9 D: R. n

6 u- b% V1 n; t[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-10 00:18

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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