找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1323|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 H+ y' G- W, Z$ h- V& _4 O5 K. S ; c0 ]- d: t( Y4 @) 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 | 显示全部楼层
//*********************************************************************. k0 w5 e" y; j" L; Q
//  ProgramCompare.java         Provided by: DRS
5 I# ?$ x7 q  l& b//8 ], T5 o  |3 {" Q6 P: A
//  Program shell for Assignment 27 L7 }$ v9 ~9 h: K$ {
//: E! [4 u1 g% Y$ Q
//  Compares two text files line by line- Z% g6 n1 q; b" z/ S
//*********************************************************************% V9 \+ \( l: E; U6 g+ X
( I$ j, ?+ L1 }$ ]9 N
import java.io.*;; D4 J/ N; ?) u

. k0 M6 L1 Y( i5 h( i, g- h, xpublic class ProgramCompare- L' {6 f6 B& ]3 ?+ y
{' |7 L4 \7 q) y8 R$ m2 J3 M
        //-----------------------------------------------------------------% W8 A# d# A% L) A* J: d+ }; |
        // Constructor
" s) g  G$ `1 I" m$ A' }% g+ w3 s        //-----------------------------------------------------------------3 j0 n. H& E. t' h' U1 ^5 P
        public ProgramCompare()
2 m! I; I; \/ A$ N1 v" G        {
6 j& G( c) m* o4 H9 T% X5 }        }: |. q6 [' V3 ]$ g1 g# w

- F1 L1 @" o0 V; M' d+ n        //------------------------------------------------------------------ V$ v1 ~, U3 O8 T2 D% N* j( m
        // Method for testing that class has been reached7 R' ^8 A0 x% I1 [# r
        //-----------------------------------------------------------------        3 u+ v, H: x. o! ]% q: M, K

% w5 L% q* q$ k& z7 H  ]) _        public boolean ProgramCompareReached()        
9 t+ d; e; h7 V* q# |; ]  v# B, i4 u        {# j. j- Q! ^3 K* I8 n+ {6 j
      try
6 [* h) z' D8 t7 H7 r$ F( A" q0 d   {        
- s6 U) I; g5 I1 [                       
" q. k  G9 ]+ c/ S                //********************************************************************7 B- {8 S6 h8 Y% O4 y! x. x
                // Try-Catch Statement is used to handle exceptions - such as file not found 5 ^1 q6 m$ t6 T1 N* i
                // Reading the files will need to be placed inside a Try-Catch - just like this one!: N# W& H# n: }" P- |  F; u' S
                // For more information see page 534 of the textbook4 C; A5 ^" o" ^$ e
                //********************************************************************
% _( D2 H) t' B/ e                     ( R4 R6 Y$ k, P- N
        }
9 \( A' W: Z2 f4 A8 }             catch (Exception ex) // Exception caught here and message displayed to the screen
  m* E) h+ r! g9 f: L4 z0 Q          {
5 I- Q. F& p* z4 t0 k                    ex.printStackTrace (System.err);
5 f( D: b# i6 x$ T2 |: L1 N           System.out.println ("Error message goes here"); // Replace this error message with your own          7 G! }9 C& A: u
        }
# ~1 m/ ?% g) d0 @1 {                return true;+ p/ S* n- X* O0 I' H  r
        }( m  [& I- b0 X2 ]. |; m

2 x; k5 u/ y7 s* j6 k1 `5 q} // end of class ProgramCompare4 e' \8 J/ E" W7 b

; W0 N6 g/ h0 t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 s1 |/ V9 b; G9 }8 J
//  ProgramCompareMenu.java    Provided by: DRS
7 b8 ?) p% c) Z7 i: ?/// }( e- W  P& R) a- j8 t
//  Calls AuthorisedUsers.java and ProgramCompare.java! i5 j: x; F, v& s/ {' x# e/ R
//2 K8 M6 U4 e$ w/ J
//  Driver shell for Assignment 2.  q/ h0 e% n1 r4 b! C
//********************************************************************) U3 h. E: @( w* R5 I' P( O

( K( Y3 w* k1 f/ ]/ f9 L: fclass ProgramCompareMenu  ]. s, B7 i, v( W4 W( `
{
+ I& L" w" I  G# Z; y    public static void main (String[] args). {$ L; K' d/ M  ?
            {5 b# G4 \( K4 ^
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 b9 k+ N' Q# d" [$ Q
                ProgramCompare reached1 = new ProgramCompare(); 7 z5 L. J$ j9 V
                AuthorisedUsers reached2 = new AuthorisedUsers();        ( K" D4 u1 x' C  ^" u1 k. }9 z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());, K' K* C+ z6 r+ c; i4 q
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 F: W: p6 @+ W  ^' C% u
        }
- ~. I7 Y1 W( S6 M1 i+ U}// end of class ProgramCompareMenu* e* w% ]4 I8 \$ U. k- K& y
  M) _$ M; ~$ I0 j) h- ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; H) B& _+ U& h! ~+ _' e' {//          AuthorisedUsers.java          Provided by: DRS
8 e0 o% X6 k" E' m. u* ]2 r//                ' O2 y) V" g. I* p' d. g
//         Program shell for Assignment 2/ m' k$ z' B+ u  A" `' ?
//
, Y; \9 i# ?# W3 q) A//         Represents facts about an AuthorisedUser, q# H& }( ]) H) h; O
//********************************************************************* C2 K" E! e9 T" d! x9 }
; G% S) p$ U  w8 T
public class AuthorisedUsers0 J- {# G5 A4 j: C1 p
    {; R1 N9 b+ l  y4 W% K
! t6 }4 V0 u7 g+ }) q/ r- K
        //-----------------------------------------------------------------+ \! j2 |' H- p4 T: z% e$ X
        // Constructor& s7 ~  ^' K2 a+ ?
        //-----------------------------------------------------------------' A9 K% t  T. W/ a7 v
, g' z- [0 W$ G8 ^. h
        public AuthorisedUsers()5 r2 _9 S" Y& a, A4 @
                {
  u! ?0 Q" V6 ^+ ]9 ^                }8 @( o( O+ R3 F% O' [- Q

# y; U2 a  N: r4 f# M7 R$ t( ?        //-----------------------------------------------------------------
2 Y. z1 W8 c5 s/ r: Z  V" h        // Method for testing that class has been reached4 f8 L# D9 v. V- ?8 Z9 h
        //-----------------------------------------------------------------        * E( s. G  ]/ R7 X
        public boolean AuthorisedUsersReached()
+ V) i3 q7 y' d2 @8 f                {
- z1 r& T+ [4 F' O8 q1 y                        return true;                       
, {" S) V( S5 `/ e: E! t                }* E4 J: y% F& c2 f' b2 {/ k
                9 I' U. d' t% ^
    } // end of class AuthorisedUsers$ O1 G8 [2 M4 T; u) P- N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming; _- C0 {( a% o) T1 ]+ P( T
Shanghai - 2007$ k, C: Y" M, R- b( U; a: e
Assignment 2; r; V6 u# O' X' E+ w
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)2 R) p+ W+ k0 x+ x
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.
; C; f8 N1 r* }The staff must be able to:' S0 V8 Q6 `" s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 K, ~8 T" i) s- l" B3 m. s* u/ x* v
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.. U5 L& |) |& }+ a0 [# b0 y% w
 The interface should provide a menu so that the staff can:
. n# x0 }% e( X" T$ w* ~0 [9 Da) Enter the names of the two Java program files to be compared2 U( ]2 {2 p1 \; U  u
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: ~8 Z6 e& X( z* t; Q) D** 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).2 t% W& V4 G; w, E% D
BSA104 Business Programming – 2007: Assignment 2" P; m! T% o& {/ X1 D
Page 2 of 5
+ x( u% u& F. d  v1 Db) Print out to the screen all the lines of code that are the same3 q% H8 x. q$ z
 Include the name of the file and the line number of the code being printed for each of the two files! t" `8 \! R+ p% H9 [+ e
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 X8 a7 ]/ h6 M6 f" u9 W
 the name, username and department of the user
1 A) |% K9 y% }& p6 h& }2 E the statistics of the comparison2 |7 j. O9 Y$ @$ b; d* Y* e
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
9 ]. D' Y5 ^9 \' [, j the recommendation for further checking
: K# I* u7 y( F8 q- 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
6 ^. n6 F! `4 v5 ?' _6 h" p( w the names of the two files compared. Q' g# y/ ^: t6 [& `2 b- G
d) Leave the program (exit)! O8 v* x1 D# ?! i3 ]2 D6 _; V' i
The ProgramCompare class: (Total maximum 20 marks available)7 s9 l# i8 d( T
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)
' f6 G+ T4 y1 b; v" Y9 Z* ~; qa) provide an error message if the files are not found or there is a problem opening them
) A: @0 r! k& t3 O" @8 f& t4 pb) compare each line of code2 ~. P& J( ]) n3 B7 r' e
c) print out the lines that are the same- Z8 V( u7 w0 m7 p* a# l  l
d) count the number of lines compared / lines the same
# ^" }6 Q) P6 n. ~; J* {The AuthorisedUsers class: (Total maximum 20 marks available)0 ^6 F1 [" q" V0 O: {
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)
# [$ C5 r  `0 u: a- N4. Provide methods to:
) E% m% I6 T+ g. N& K0 q; La) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match9 N1 s) \* p) R3 S4 s2 ~; ?
b) return the name of the authorised user
. b  C2 B3 O" N+ X9 A4 bc) return the name of the department of the authorised user1 h, L9 A7 A( o: ]2 Q
Individual Data (Maximum 20 marks available)3 ^/ K% X$ M) q. |% l% K* N/ l
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.
8 o' i; G  V5 \Documentation (Maximum 10 marks available)& W: p9 t$ h6 d' w3 U4 m  F
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.2 P. a( q) Q7 \  e8 `! x$ ^3 J
BSA104 Business Programming – 2007: Assignment 2
! ^2 K  c  ~' D9 F. U. qPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* O- O1 ~: O# X; @8 d6 c1 z不过你要翻JAVA的类库说明。你有下载没有?
3 z" A( f' s# o: k0 \查询关于对比的函数。貌似关键字是contrast,还有compare" [1 R- `6 M! s! e! T: T5 F2 z

4 V  c% l% ]) f[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; l; J6 Y0 S! E! }痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ H% P$ H6 e  j0 K  P& p可以下载到的 是 jdk-1_X_0-doc
4 [& T. B( d  Q
0 F8 k- _1 }8 }! b! b! f+ v* t[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-28 22:53

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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