找回密码
 注册

QQ登录

只需一步,快速开始

查看: 974|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 S O( k+ `: p! r5 r z, S1 N; a 9 b0 s7 d' K) w. E" U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. g0 ?! Z' e# f. Z/ S: H* L3 }//  ProgramCompare.java         Provided by: DRS$ H& c- W4 G2 [5 }: f" H
//
0 d' j5 G$ Q0 e//  Program shell for Assignment 2! q' Z: ]1 f& N- R$ g
//
6 _$ S# r+ [  i! m//  Compares two text files line by line
9 f9 K4 j. ^! c% C# b3 }% q. {; }9 G//*********************************************************************1 o) j6 n( u- D) d5 c0 a

  I, T2 V! W; y+ ?" iimport java.io.*;0 Q5 S7 o0 G' `) B
; r" G# C" l7 f, g
public class ProgramCompare0 r( c, e8 Z% j$ [3 [7 J2 u# Z
{
& t/ J: E4 Q0 s2 R        //-----------------------------------------------------------------* [0 @, v2 z: b/ u# ~8 _. S7 @1 B
        // Constructor$ p, f" b; l* \; C) a9 B
        //-----------------------------------------------------------------) Y( Y9 a7 X% ?0 S: r- q+ [  O% {( T
        public ProgramCompare()
& G' w1 u9 c# i& J        {% c$ k; t2 w8 A* ?6 l9 y8 t
        }" M8 N6 a4 i2 q

0 l1 K" G7 R6 v        //-----------------------------------------------------------------1 g' V! y7 N8 w- `2 a
        // Method for testing that class has been reached+ c* C0 H3 [  C/ l- o: j# ~! {7 Q
        //-----------------------------------------------------------------        4 j- @" o8 D4 }: Q! I
7 G. x4 P4 q7 W0 z) ^7 a- m
        public boolean ProgramCompareReached()         # `/ l! n9 r7 d; v$ a! ?
        {) A- t7 H. X! [. P6 u% [% I
      try
* e: s' w" G: w/ o: s. J  V   {        
* F/ Y9 U: n, e8 _9 I2 b2 R                        * `: o0 i5 q1 Y7 D; V4 r
                //********************************************************************. [" B  V2 c( K- P- W+ R
                // Try-Catch Statement is used to handle exceptions - such as file not found $ U2 w& ?: ?7 y: @, m6 e6 x' K
                // Reading the files will need to be placed inside a Try-Catch - just like this one!, G1 ^3 O0 `0 M* w. _
                // For more information see page 534 of the textbook/ U. [" _& F3 b3 V) o, I5 a8 ?
                //********************************************************************1 }( c& u) i1 a- @
                     / x+ g. b' H. O1 F" C
        }" x) z) W5 K3 H6 N/ W6 E
             catch (Exception ex) // Exception caught here and message displayed to the screen
) f* M! g, x& Y: d          {+ t0 o- w8 M  {9 G/ |) S/ o
                    ex.printStackTrace (System.err);- c  ?4 o# @7 i* }
           System.out.println ("Error message goes here"); // Replace this error message with your own         
* R5 X* }- U2 x        }. u6 R* F$ e( C# P
                return true;4 c# ?$ u4 v% J  j
        }
. |. b5 |% K' G1 \1 j, h9 C
9 {. t" ^* p3 z# {! Y} // end of class ProgramCompare
( ^6 G; }$ T: ]. V2 `
* T: t2 Q% R' A. T9 J, i: w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& n" Z0 o3 s1 q* B' u
//  ProgramCompareMenu.java    Provided by: DRS$ T. _7 s5 k8 p1 \
//
- c* M( f  u  s//  Calls AuthorisedUsers.java and ProgramCompare.java- O3 o( b/ |: o) q. T+ f8 J8 P
//
7 q! h0 {' G* X* T$ f//  Driver shell for Assignment 2.. M& Q% f! j. z
//********************************************************************; L, M5 S% J7 U( `

" d8 E- _# T- L* T6 g0 tclass ProgramCompareMenu1 a$ j2 c% w/ z
{
7 {# e0 W, \' f- B6 }8 P    public static void main (String[] args)5 K; g9 @! Y9 K% q9 U
            {
7 {2 n' o- g. @" q! b                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 J" k) A7 a* H
                ProgramCompare reached1 = new ProgramCompare(); 8 v# }8 C9 ~* b
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- g, A7 M4 H9 N/ E+ j                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 H$ ?1 z8 G5 M( l* Z: ?" K: }; g                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& a2 H% {% Q0 D% \( n        }
+ l$ \% V1 |/ _" j; }3 a}// end of class ProgramCompareMenu
. h6 |$ c( N( r$ G4 v9 n: D, M. |
8 }2 I4 f+ h& `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************* N3 z0 g# ^5 F$ Q: _
//          AuthorisedUsers.java          Provided by: DRS* V% ?. R  P4 H$ J2 P' {% E7 x( R
//                & @$ ^) _8 H$ f( }! {% D
//         Program shell for Assignment 2! \' G9 n0 W7 f+ T; p
//
  O/ ]' u  a/ O//         Represents facts about an AuthorisedUser- L( {. i# O% K! G1 H* D/ l: Y
//********************************************************************5 _8 O% c5 a4 O
2 ~6 b  K# [8 r
public class AuthorisedUsers* w9 f' g- A- C1 S0 J
    {
) s6 K' @1 C5 |( T0 Q2 V* [  s; \2 @, U8 n: L
        //-----------------------------------------------------------------  |# a5 z3 w/ L8 s
        // Constructor) _& g7 D: I; @) m
        //-----------------------------------------------------------------
! e* p* ?6 t. v7 U* S5 `- M
6 p( {1 Z) y; S( N- J        public AuthorisedUsers()
  V6 X' q4 q$ [! K3 I                {5 H; e( E& A/ ~- i' C
                }; i9 L( w* O) [, f& Y9 x1 [% X% |  s
! {. U8 V" \5 K
        //-----------------------------------------------------------------
9 ?7 z$ _# c9 |* b( f* j        // Method for testing that class has been reached
  J3 t) p5 ^9 [        //-----------------------------------------------------------------        2 R8 o( e4 F: R. J' H) N+ R* L; q
        public boolean AuthorisedUsersReached(): s8 U" N3 b& }! h3 `
                {
7 v# H+ m( p; {+ }* P/ c  e                        return true;                       
# }' a1 U% A7 b  S  \1 F6 I                }' w& A7 Q& ?7 ]+ n" P
               
) n7 Z6 w- G, Z& c- E+ @2 ^+ S& [. x    } // end of class AuthorisedUsers
/ p+ U* F( B4 S8 L+ E6 a& S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ f3 \( p' Z1 T' R3 D; QShanghai - 20072 K) d; ~+ K4 X$ x  `
Assignment 2
( X2 z/ r# ~* _, M: P2 EDeadline 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): B* _& O; C2 L; h7 X# R5 [
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.
. {; h# E! W5 `# g. i. _9 r! }' G' ?6 kThe staff must be able to:7 }2 `# y7 g  }: \! u" l  q/ |
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ h* i" B2 C+ e& }3 a$ \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.
+ W8 g& k4 v4 x/ R The interface should provide a menu so that the staff can:
, p7 q% E% X4 b" z; ca) Enter the names of the two Java program files to be compared
/ ]' u5 |+ U. R9 N6 c/ y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 N0 _8 [$ c7 m& b+ B+ N5 f- C** 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).& e# C1 x, H2 t5 ~) m% W
BSA104 Business Programming – 2007: Assignment 24 _) o5 t: E# V0 _8 [
Page 2 of 56 H* r6 @0 `; H) i6 w
b) Print out to the screen all the lines of code that are the same4 x" B% B* E: L# Y7 s7 E
 Include the name of the file and the line number of the code being printed for each of the two files! W2 x& R% E/ V% L% ?: X
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 V# A2 D% K! f1 A6 u/ i
 the name, username and department of the user
# ~4 ]4 u3 L. N% Q the statistics of the comparison
) e. G/ ?2 M4 e+ k" O0 s; o- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% _4 s/ `# c. R5 ?4 h the recommendation for further checking
. F0 h  r8 o) @: Z- 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
# K1 M. \3 Q* x* D the names of the two files compared
/ n- _; ~! Q( T& ^6 B9 Yd) Leave the program (exit): m* n! q( d9 G4 A' M( V1 m$ H7 N
The ProgramCompare class: (Total maximum 20 marks available). u9 \6 B# y9 T7 R7 W" 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)/ P9 K# l; B% M: U$ _
a) provide an error message if the files are not found or there is a problem opening them
) A+ C, D( H4 u1 \; db) compare each line of code
; c1 p8 c1 E) rc) print out the lines that are the same
5 o9 {% ~$ y( E: s2 z5 H' S2 [d) count the number of lines compared / lines the same( X% S: z2 K) e9 \
The AuthorisedUsers class: (Total maximum 20 marks available)% z" D, r7 s: z' [# j% A
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)
) J0 u6 G4 N. e& N4. Provide methods to:# h$ Z. X$ c. c* t
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
3 t  X- f0 s8 @9 h3 Bb) return the name of the authorised user( _7 B# @5 z# W  B" O$ Z) u
c) return the name of the department of the authorised user
: ~) {8 l- G7 z9 \Individual Data (Maximum 20 marks available)0 [9 a0 X0 v" }8 ?4 {, y- g7 y" G
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+ x$ X; l8 T5 w$ e6 ], f: iDocumentation (Maximum 10 marks available)) w6 ?3 U# t% t! R$ `
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.
& z6 ]( x6 l& B2 h& @+ aBSA104 Business Programming – 2007: Assignment 26 q5 e% ]# T9 A9 m& t5 m* c' Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
: I5 S* N3 W  X: ~, @7 ]6 l. f  U不过你要翻JAVA的类库说明。你有下载没有?" h) Q$ ~- J) J' d+ c2 c. x
查询关于对比的函数。貌似关键字是contrast,还有compare
& j. \6 {" J+ X6 H9 X; [0 U2 f5 J" g8 J1 t  B) G
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -6 s4 \. |4 {5 L7 t
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 o' q8 r. j  K2 q# E可以下载到的 是 jdk-1_X_0-doc
4 j1 P8 O. X" P
! M' `6 p+ R: |" s, c" \* _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-29 11:11

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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