找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1238|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 i. v7 i* e3 V2 L% _ 0 d/ j' ]0 G2 h0 M! w, K# K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************, {, c1 C% c. z
//  ProgramCompare.java         Provided by: DRS
" d1 b' F# Y9 L, l+ {1 e* N$ \//
: F% J. K# D9 B7 N: l" D  t//  Program shell for Assignment 2  A8 }; x9 O, m; J2 u6 V
//
) ]- D- j" L* c$ P: P5 _; w//  Compares two text files line by line# j% r2 q/ a: p# I; C
//*********************************************************************
0 [6 P- |, w, }$ l3 k! h' \
- y/ }( o9 h6 }* Mimport java.io.*;
  P0 L1 U5 l7 ]$ G) I2 H9 |* _3 W3 f5 l  @/ Y7 j0 c
public class ProgramCompare1 `+ M% S+ L* n6 D* r1 V
{" k9 V) l) ?2 P
        //-----------------------------------------------------------------
3 O! o' b2 z- W8 m8 ~        // Constructor8 I  ]& _3 |! e
        //-----------------------------------------------------------------5 O% L7 U& s: n+ z  |
        public ProgramCompare()4 {/ Q+ g. b3 M3 E( [
        {0 ?- u4 c0 \: s
        }
, \4 \7 H4 ~, P) t: Z; v7 O5 n) F/ r6 t, T  ?
        //-----------------------------------------------------------------
4 a; F8 w2 b7 B9 E1 t" A/ Z% n- U        // Method for testing that class has been reached4 {# T. X1 Q1 J/ H) }  b. p- ^
        //-----------------------------------------------------------------       
2 P0 T2 c  p  }8 O! K0 X% P* X7 P9 I* p. O* b; t# i
        public boolean ProgramCompareReached()         2 t2 m) a: \+ Q2 M. m  f
        {
- S4 n7 L1 \& b      try
  P2 |& R% ?0 Q, ^   {        
! H( Z: J; x4 Q' e                       
! X! q5 X; M7 }! I$ f                //********************************************************************
; _6 `' `% }% U; v" A                // Try-Catch Statement is used to handle exceptions - such as file not found & ?. |, R9 V% L, [! a9 N1 z/ n+ s
                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ a1 F- t# e" Y+ P) c( j8 o! j+ e2 r
                // For more information see page 534 of the textbook
) |$ K' R8 ?/ @2 L8 `& r                //********************************************************************
9 A  B) p! y  ~. o- O                     6 b: {6 E3 j& N/ V+ C$ b
        }
/ `6 v& w& V- y& q& q7 ^* C             catch (Exception ex) // Exception caught here and message displayed to the screen 0 E# Z$ X8 [7 h' ^4 c+ w& K
          {" A3 |# }) ]" ]! B# i9 Z, p
                    ex.printStackTrace (System.err);  d8 r" R1 M% S
           System.out.println ("Error message goes here"); // Replace this error message with your own         
! Y0 h  r8 Z; j$ Y  C2 O  r; G        }+ o* f+ V3 J. }, I) b
                return true;
* J) `8 [6 K" \2 f        }
7 a% W* p# q5 s; k. L. c7 t/ L& n* R9 K9 j" t
} // end of class ProgramCompare# J" E; u8 L5 O; x; m* @: l. D

* N7 O7 c. E3 M! ^5 U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- a; d5 n6 a$ w, G- e//  ProgramCompareMenu.java    Provided by: DRS
$ M& z7 ]; H+ Y$ y' m! z//
, z7 m  _% n2 g; ^1 a" b% O$ C% s* v//  Calls AuthorisedUsers.java and ProgramCompare.java
% O# G- c+ m2 u' S2 y1 F//1 C& a* k8 k1 G  W5 y: [) f' s
//  Driver shell for Assignment 2.
. h* `: p  \+ w# F//********************************************************************' i0 h: o7 e6 A# i! C1 k

  p0 ~) a4 t) _- S% Y/ O4 tclass ProgramCompareMenu
- ~' Y5 l7 J* y{
& L; A$ y+ G/ A3 g7 s    public static void main (String[] args)
: `% l+ f, E7 K8 n8 z& M5 ~            {
8 r+ X4 M1 o/ H* W0 }2 i                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 D% V/ n* P4 O& Z7 n; l
                ProgramCompare reached1 = new ProgramCompare(); 7 B# m/ q9 H, ~  d. ?9 l2 q
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 ~4 K' y6 B, y5 r, A7 x' V                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
* [) y) t- t" t+ \7 u6 D  t                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        4 J3 U0 c  m2 w" q
        }) v1 a: n: p. I2 B3 }6 ~2 g
}// end of class ProgramCompareMenu
1 y& R3 s: O0 ?# ?- t4 I
2 }0 k3 B$ g9 b" V/ |" b//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************& `7 x  |) E& N& Y
//          AuthorisedUsers.java          Provided by: DRS
& e3 K6 u6 E8 k5 I* y* c# `//               
, A9 v3 A1 y* A//         Program shell for Assignment 29 {, e8 E9 p9 p( O
//  @* I3 }& f  i) C3 {
//         Represents facts about an AuthorisedUser, z: Q' F6 @$ P" n9 C" O% [2 B8 x
//********************************************************************' V2 N" E2 S0 k$ w
: g, a3 \0 R" M% k
public class AuthorisedUsers% H$ e( J7 }* B5 L& n# P
    {
3 E% q' q0 m+ X
- E! C# [. E: i: K& x        //-----------------------------------------------------------------
  A% e6 a# D6 W# w/ }4 t0 l- O        // Constructor
$ a1 `9 e8 M1 l  X' y        //-----------------------------------------------------------------# v; s7 C$ Y/ n8 x- y
! ?( \4 s1 X6 q: r! m0 z3 o0 J4 e
        public AuthorisedUsers(): ^% C( Q# M, V  {* P
                {# b# g* h- b1 l' p/ P# e7 C
                }
4 E( I+ ?) M) B9 U4 f- G" S0 B$ w7 _0 Q9 m
        //-----------------------------------------------------------------
3 p- ^6 }/ e4 y& ^        // Method for testing that class has been reached
- s+ f/ p9 L  o5 D3 D        //-----------------------------------------------------------------       
$ l$ U8 h) L5 N$ N+ q4 `+ x, I        public boolean AuthorisedUsersReached()3 x3 }- o9 [, X! g/ E) R2 j2 o) Z( m
                {: Y4 Y/ R6 x$ D/ T
                        return true;                       
8 F( r: ?# |* `; K: Y+ [                }
2 d; `# z4 K4 ?9 t; k6 ], u                ) D- Y7 g+ f* r4 O
    } // end of class AuthorisedUsers
+ Q' N, _) R6 M2 K2 u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, U: I/ j/ V! _7 wShanghai - 2007
% X/ C* L$ @: s2 s3 fAssignment 2: e; h; f9 t, \, ]: {  l1 ^) 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); V4 O0 j0 J, l& N; R' Y
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  d7 v% {8 L2 d
The staff must be able to:
5 F& [- u1 S. N Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
- B7 ]* Y- u3 l% Z! X, e. z  S1. 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.
! y1 Q1 ]* ?% B* H% ?! g1 H The interface should provide a menu so that the staff can:& k" f9 Y2 }2 [9 o& Q$ M
a) Enter the names of the two Java program files to be compared+ B. {+ T: y* z4 X
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 |$ J  ~" |* K. R3 K** 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).
% V: V8 B, N" hBSA104 Business Programming – 2007: Assignment 2
2 z) B: @. o! g: ]/ M5 P. YPage 2 of 5
5 k% [: c2 D4 h' Z; B3 p; Yb) Print out to the screen all the lines of code that are the same
/ @6 P, i4 s5 d! ] Include the name of the file and the line number of the code being printed for each of the two files" Y, U( T1 Q- O) ~4 j' O' H$ ~
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 A: M3 p* F6 d% i the name, username and department of the user0 l3 l0 p% S2 `1 T6 ~  H' Y
 the statistics of the comparison! {' q4 a' s( H5 J# p5 z( S; w
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& w: q. m& o, A; L the recommendation for further checking
6 I# O& I. y# V4 Z# 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 closely/ V) t' z& O& ~. w; a, Z
 the names of the two files compared
$ {  M% v3 M6 Z' b/ Q, od) Leave the program (exit)
) B- @" m" o" G0 \  ]  v. V" UThe ProgramCompare class: (Total maximum 20 marks available)7 J2 j7 {9 [3 U7 K! z( a7 y
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)4 t% r' f: F3 a5 X0 N4 {
a) provide an error message if the files are not found or there is a problem opening them1 f' n! B7 X9 L8 e
b) compare each line of code
; V/ ^7 m6 [( P6 ?- Jc) print out the lines that are the same
0 y! n* F) n, ?4 O. D" s# g- hd) count the number of lines compared / lines the same% ?4 W$ u/ \4 k1 R0 C8 f. z
The AuthorisedUsers class: (Total maximum 20 marks available)
4 Z  X, X7 P- C6 V, X3 Z3. 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)4 g, k" V" ?: b3 ], d
4. Provide methods to:
4 M7 ?. p9 w/ v- x8 {' 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 match+ S+ ?+ _1 B: {5 n. d1 h
b) return the name of the authorised user( j; Y6 `8 r0 m' U+ y; p7 H
c) return the name of the department of the authorised user
8 Q, @! G0 j4 x' g% cIndividual Data (Maximum 20 marks available)( l$ H% d6 }: ]+ \' q0 X, P
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.; J' P0 |$ |  x/ ~' j7 T
Documentation (Maximum 10 marks available)" x% \0 }& u0 L7 T
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.: ]! v, \+ c& ]0 i
BSA104 Business Programming – 2007: Assignment 2
9 ]7 s4 H0 V0 h6 N* {, N. ~Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
' K) m% B7 k" `; I( C. ?不过你要翻JAVA的类库说明。你有下载没有?
4 c2 L4 u; Y3 _+ I9 o, l2 a2 W查询关于对比的函数。貌似关键字是contrast,还有compare
4 G0 [: e- z6 G/ F
+ @; h3 i, B6 s7 M3 `1 V" M3 u[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ H$ Q9 T$ ~: u! x; I: |痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: n* v5 q, Z! z- _+ l$ y( S2 h可以下载到的 是 jdk-1_X_0-doc
/ |$ p5 L" U) p: ]" l+ w# m& m- [  z) Y$ g/ M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-28 17:10

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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