找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1415|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 : b+ I3 w: T: m " x& r4 Z6 Q, ~. f$ S6 B
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& Y# A/ A% V: n  |0 h//  ProgramCompare.java         Provided by: DRS
6 k7 ?# p- |. y$ N0 h) A' C//, z( O* W; W" y5 a5 w  F7 h; I3 b
//  Program shell for Assignment 24 c4 W! X4 x/ i3 N) ?
//
8 J6 i! m- \9 {( b* Z1 r; b& |//  Compares two text files line by line
; {1 n, \4 N( n6 z' ]//*********************************************************************
# A# w3 c8 J- k
8 f1 J/ j; `2 J1 m7 J. b: cimport java.io.*;
0 b2 I7 `" ^* P7 N1 z! Y% |! ]% N: j
public class ProgramCompare
4 h8 P% h* A6 w* j8 ~# J{
; h- H+ D9 j) f( M, @; d) v        //-----------------------------------------------------------------
( a3 C/ `. ^' W, s" }+ x( p/ w* r& w        // Constructor9 W& j" c# ], L" h( o/ p  z
        //-----------------------------------------------------------------
, J- g" U+ [, w1 Y, a        public ProgramCompare()
* M3 K% E* O4 r& c: [  \& j7 a        {
) u. e! p- K( ^0 ]% c        }) n6 _  Q4 @" Z& ?

& \9 c, D3 A4 ^9 F0 K6 k) r        //-----------------------------------------------------------------* \  b) g5 d. ?5 E
        // Method for testing that class has been reached8 k% o  i) ^- B8 k+ }: E
        //-----------------------------------------------------------------        6 Q! i- E) Q- b5 S8 a4 b

) T9 b9 b9 v+ f7 C+ Z. z: I2 a        public boolean ProgramCompareReached()         7 k7 ?% h1 M$ q" x4 T. v& X
        {
4 a0 d+ U) j& i3 B  N      try
) w' o6 q5 Q7 s, ^# `* C   {           Z8 N9 r% r# j' Q- ~
                        ! O0 y* ^* `/ N( ?' ]7 \
                //********************************************************************
+ e# ~3 j& _# o' C+ I                // Try-Catch Statement is used to handle exceptions - such as file not found
; {1 {0 A9 l8 N                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 W: i6 J5 a  [2 ~
                // For more information see page 534 of the textbook2 d" j1 B3 m! u/ R2 b: M$ x
                //********************************************************************
% ]+ Y6 E$ f! i/ l9 ]                     $ c3 f5 @' H; S6 S$ s( P: G
        }3 t* U% a: @7 h
             catch (Exception ex) // Exception caught here and message displayed to the screen $ w; r1 O+ Y7 v* T0 ^4 X! r
          {7 D3 k0 G/ Z2 r# n, r7 D
                    ex.printStackTrace (System.err);
% z3 ^" g3 G3 d4 l3 N           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 {3 |8 |2 A3 s! c        }
" ?4 ~. \5 L/ g                return true;  I9 j8 q) I8 r# h
        }2 z0 O4 A4 w1 H+ R. O& t4 P
6 L3 P! J: v  s" }' M; {
} // end of class ProgramCompare: u+ H& F9 z2 I1 p* S- i3 W
" e; G, [$ N' E( e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" y, d3 H# A% W. [* g+ G/ F+ H//  ProgramCompareMenu.java    Provided by: DRS
' X4 m/ A  \& H8 p6 D" H//9 _8 A3 E1 Y! ?" f
//  Calls AuthorisedUsers.java and ProgramCompare.java
: o$ I4 K/ B+ _; [: x//
, Q6 v* D. l2 I, d4 z8 p//  Driver shell for Assignment 2.7 d' @. e7 \" b0 S! y5 j1 G
//********************************************************************" E% C- L7 g8 ?& Z9 W

, G' c3 L. g* R+ o0 X" P: i( yclass ProgramCompareMenu
1 a; h; t( }, d9 V{
% X4 H% W# D5 d% u8 }: \+ a    public static void main (String[] args)( C/ D3 e$ A% O- x$ x% @
            {
2 m( A2 s. f2 F3 K$ _( S                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 u; \5 ^6 b) E1 Z: H; {                ProgramCompare reached1 = new ProgramCompare(); , y% m4 @& a8 V5 w0 v1 S
                AuthorisedUsers reached2 = new AuthorisedUsers();        3 G& Y4 f9 P% Y' L7 t1 H$ c
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
1 ?% D* P. L( a: B' f5 ~                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ; j9 _# l: R' u2 H
        }: j6 Q- K, e$ l/ B1 n
}// end of class ProgramCompareMenu
6 A$ m! T2 Y: B) F) ?2 L' J2 g& L! S4 i( E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 _3 c$ }  u' c  i$ h# u: A7 e//          AuthorisedUsers.java          Provided by: DRS. D. d& k+ u. j7 w7 o2 p
//                3 S% `5 p& H6 c. J/ u
//         Program shell for Assignment 2
- I$ ?6 T% G* T. z+ w$ A* m4 P//
3 ?/ q: w/ U' m3 ~% d% X$ e* M//         Represents facts about an AuthorisedUser
1 k0 Z/ z+ g3 b6 h3 ]) X% d//********************************************************************
( y* _+ Y7 Q- T) X" b5 Q& N3 W9 h; f  _8 b9 v1 {+ c
public class AuthorisedUsers
3 a6 }& Q5 e! P5 x: |1 h: N    {
3 C% w# Y  |% D
0 g' I5 w9 Z1 l% v0 s- M) `        //-----------------------------------------------------------------
* r4 J( x+ U7 f: j3 d        // Constructor
; [5 {) y/ r$ N, L: C+ G3 y- h$ |        //-----------------------------------------------------------------
. Q5 f1 Y7 z5 z/ _% Y3 q# C  w8 o: n; j
        public AuthorisedUsers(). Z5 h# w% i' N& c( m8 a- I
                {
2 q; v. s- \3 _, ?                }& X  K$ g: T; a# v
( R$ p, ^; K2 @* c8 }* ]- h
        //-----------------------------------------------------------------
) m' t* c% p: y2 J        // Method for testing that class has been reached  F0 I9 v+ ?/ n
        //-----------------------------------------------------------------       
0 c& Q9 T* j" ]7 l( @1 S2 p. E        public boolean AuthorisedUsersReached(), ~2 N7 [3 \6 l9 F/ X7 @- E8 s
                {
" X( ^" Z8 p) m+ g5 L2 k3 _2 I                        return true;                       
5 @! W4 R/ s6 _                }5 r. R9 A* V# Q' b" \
               
4 k2 M  b$ P! u4 c' p: R; U    } // end of class AuthorisedUsers! N- q% g$ v2 s) e, J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, l/ B5 y2 F" M* ]+ [& ~Shanghai - 2007
8 [% E+ S+ [! E1 l- uAssignment 2& u: m( r1 O- D; [
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)
* L5 F) D# A2 b6 x5 G1. 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.
% E  d- d4 g+ i- J) k7 `The staff must be able to:4 t- S3 f' T' m5 r' c
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 U% O! ]3 p( c# H1. 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.) A. W  s3 J1 I% }9 l1 u
 The interface should provide a menu so that the staff can:
. c  D, t1 l; t1 na) Enter the names of the two Java program files to be compared
: ^! r0 n; Q! c- K' Q- F; ~! k For this assignment, it will be assumed that the two Java program files are in the same folder as your program.& [' I# J4 O5 z2 @. V3 A$ n3 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).
1 p- E% N4 }5 T3 K2 Z( @6 eBSA104 Business Programming – 2007: Assignment 2! B4 Q% p8 O! n# f
Page 2 of 5; {8 M8 f( T# E: m
b) Print out to the screen all the lines of code that are the same1 i  }! Q- u1 L$ ~
 Include the name of the file and the line number of the code being printed for each of the two files4 [. i& Q5 o  q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* h2 N- e4 s8 U0 g the name, username and department of the user
7 c+ _; e1 {6 O! T" O6 R1 a the statistics of the comparison: W; t4 L7 f* r9 D  H6 e
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different* _8 E$ w& V+ c
 the recommendation for further checking6 X. U& r  t9 h! h+ V7 I+ s
- 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
' ]3 L! v0 O- M! k6 K the names of the two files compared
: v# i' E9 }% `! l$ ~d) Leave the program (exit)
, W7 i, \0 Y% a8 ~0 fThe ProgramCompare class: (Total maximum 20 marks available)
, A* I8 U' h* \5 @/ h# y$ H2. 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)
% L: |. _, q1 q- I4 r9 ]a) provide an error message if the files are not found or there is a problem opening them
3 i/ j. ]/ S& c; ^b) compare each line of code
$ X3 h0 k2 Z  S3 A( Gc) print out the lines that are the same5 @& b- Z! ~- f: `- J4 M$ a
d) count the number of lines compared / lines the same2 G+ k2 M7 ~3 |* J( s6 n0 e
The AuthorisedUsers class: (Total maximum 20 marks available)
" e* X0 s+ y' y1 O% A/ R: `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)
; Q3 M% H1 h* o8 D! A7 k& ^4. Provide methods to:
1 {$ i* o* D* Ea) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match7 n5 w* P( u; r" o9 q' K7 L
b) return the name of the authorised user) U1 D" H; Z8 N# u3 A% c% d* [, }
c) return the name of the department of the authorised user
9 y1 ~, ]& J0 eIndividual Data (Maximum 20 marks available)  j6 `0 X. Z& }' P4 C# z3 V
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.# F6 G8 E1 y* J* A9 p. B# K9 F
Documentation (Maximum 10 marks available)
+ _+ D6 _* D; Q  ]9 T6 h& \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.
3 D- S+ R/ W* C, [$ b1 S2 R  CBSA104 Business Programming – 2007: Assignment 21 E9 u: N" l7 }2 R% N# q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了; U' ^: A3 ?& ^' {) H+ D
不过你要翻JAVA的类库说明。你有下载没有?
: H4 `- h, n0 _/ Q" n6 h查询关于对比的函数。貌似关键字是contrast,还有compare
/ p9 _" ^$ w5 s. |$ U8 G0 A5 s: W: t0 P; C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 A" I) S5 O/ a/ M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 {7 e' F( c7 E) B, k9 t3 S. n2 e
可以下载到的 是 jdk-1_X_0-doc6 p2 n& @9 C3 z3 z: C

4 z5 D7 w- ?2 x3 B  h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-25 12:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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