找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1613|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # j7 ], B1 r; J& [+ o1 ?' S6 ~3 s }$ w$ j
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************/ Z  S) v) l: l8 V; n' c( g% q
//  ProgramCompare.java         Provided by: DRS
# B: I- q6 G! Q1 A//
6 ~8 b7 h# \8 X& p- d- a- @//  Program shell for Assignment 23 R: b$ t0 E1 U+ l8 w
//5 s& D, A5 s' c* ]' M9 `$ Z
//  Compares two text files line by line0 m. d1 v( Q" G7 a! S: r6 s0 Z
//*********************************************************************5 |' T" o7 I& V% g
" O; h8 E! Y5 h1 X9 X3 H: u
import java.io.*;2 k% K! w+ N- V$ r0 W, j8 l* g) K
( D5 A; D: v. E$ g1 F: J
public class ProgramCompare
5 `+ l. V4 M) S8 r5 h{/ V2 j3 x8 D) ~6 }* ?0 N
        //-----------------------------------------------------------------( R4 j# U- q4 X1 u* U0 e, J
        // Constructor
. K3 [) G. B' U7 ~$ x  n% B        //-----------------------------------------------------------------( _4 J+ L2 g5 K5 r- J, ^5 ^
        public ProgramCompare()
7 H% ]/ ]  X  _7 D2 @, K5 ?4 r; u5 c        {
" h6 v( c8 _# v1 g' E" \/ p        }
9 F! H7 Z' x! N4 N% D. _! i( }
/ I  Z. i5 @# v4 L, V        //-----------------------------------------------------------------
' r  {: W4 p" l9 @6 h6 Z        // Method for testing that class has been reached. Y' s% a$ ~& X; _- q
        //-----------------------------------------------------------------        4 A3 W) _+ `* U$ n- ^6 S& e
) [$ Z- V& ?# M
        public boolean ProgramCompareReached()        
" c4 z5 k7 ?' n7 ^8 X. u9 ~% f        {
& X- Z+ N/ r6 A  B8 j4 a* v; P      try / o$ Y& k/ ^- [5 w( b" \" i% W) l
   {        
2 Y4 R( `4 m- f" {                       
2 h# }( \' c4 T9 e                //********************************************************************
4 m! O, }% ~6 A, L  d                // Try-Catch Statement is used to handle exceptions - such as file not found . p0 Y0 P: j  k. i5 E& e3 j
                // Reading the files will need to be placed inside a Try-Catch - just like this one!5 G  U% m* Y& `1 b& _. d' x
                // For more information see page 534 of the textbook
7 Y7 O) M# p% o% X# ^9 w9 O0 U& V                //********************************************************************
$ B+ R' h9 F5 b5 S8 T                    
, ~/ X: V9 u: [. W6 V7 d: `        }
* `1 O+ l4 I$ \             catch (Exception ex) // Exception caught here and message displayed to the screen
  d! ?2 D6 y# S: I          {0 |" }! P5 j# M9 {
                    ex.printStackTrace (System.err);) x) i' ]% q" _" U8 P
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- J* ^& T4 E2 ^+ E, H- ^        }# U5 {$ {6 {9 j, q
                return true;
$ K/ D& f3 ~: x        }
: M) Y/ X2 M/ z& k( _
. U' K6 Z0 p  C9 M} // end of class ProgramCompare; N& A" L( l4 N' A: o. D

# A  t+ ]8 f5 \, ^* ~+ \1 {9 r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( B" T4 Q  G! z9 I
//  ProgramCompareMenu.java    Provided by: DRS
! ]3 j( U; J; |8 d5 O) I2 N( ~//# l+ ?0 ]. d# }/ Q7 |$ N
//  Calls AuthorisedUsers.java and ProgramCompare.java- z/ j6 n1 y, K8 c9 J2 a( w4 K
//
" N$ S# E2 |# s! x//  Driver shell for Assignment 2.8 Z- U+ e: d! O, D5 q8 M* t) W" h- {
//********************************************************************
& U/ R1 j3 R2 ~5 ]' V  m3 g
  Z3 P: K3 U! d2 i- oclass ProgramCompareMenu
. I( L' u) a% g1 }% m' Y{& G% Y! ?0 t) X) b) j' ~
    public static void main (String[] args)
0 p2 |: ^( X1 x" q1 }& }            {
( r+ k& h6 r" U+ S3 D                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 p" l' [# p& |/ _/ X7 A" _6 z4 O                ProgramCompare reached1 = new ProgramCompare();
3 t6 t  U6 @  E8 a5 A6 T/ N. \                AuthorisedUsers reached2 = new AuthorisedUsers();        ) R3 I) `/ O. G
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) u' V. c7 m  T# j" t                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & G4 V* {9 J8 w+ ], f9 V
        }; w# k# ~: v' C3 X% E  x0 I
}// end of class ProgramCompareMenu
6 g6 M1 @+ c/ i. e9 X) q8 k
, E* y9 M& U+ `5 L( h7 p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 _* j1 H: y' P6 Z0 X. U//          AuthorisedUsers.java          Provided by: DRS
* }, ]8 q% ~" O9 @2 v/ F/ A//                , T* u# p, S2 [* T( M) [3 G
//         Program shell for Assignment 2) J0 G, Z) O2 Z9 q
//# X- C% V7 V+ m) A8 `
//         Represents facts about an AuthorisedUser
6 O( H" C) Y$ s- e//********************************************************************5 k/ N" Z+ q, U2 L8 K2 v( h' \
- ~# F# p! Y6 x7 ]5 O& Z6 E$ d. p
public class AuthorisedUsers
' c7 F% p4 b; G8 E% N6 _    {" h) A" o( V7 i1 x

/ l4 G' D/ T: ~        //-----------------------------------------------------------------: a" R1 m! C- n, H: z3 G: j* k
        // Constructor9 \' V" T8 {) d6 @9 Z% i# @# U
        //-----------------------------------------------------------------, R7 J1 B0 ^! c* N$ P0 a6 d

/ G' h6 D" ~. W' v: P* L        public AuthorisedUsers()8 X; s$ H2 g7 R; ?7 y/ S# B
                {
$ }" k+ O$ v# ]0 \+ i3 n) Y& \                }
- y4 `6 K# @2 a6 M" f5 ]3 k9 D4 _9 G" h& `1 t6 B0 n- @
        //-----------------------------------------------------------------# d4 o5 _9 G( `1 @, Q! r
        // Method for testing that class has been reached( _' }3 A$ ?2 `6 R* [
        //-----------------------------------------------------------------        1 W  [2 X7 \# S; Y6 S2 G
        public boolean AuthorisedUsersReached()
" v7 m/ ?, Y; ^  T. Q- _' ~& D                {, F( ]+ f7 J0 R
                        return true;                       
: m$ L* j) G" U                }) M  M5 Z6 a# {3 V- ~# `; M
               
3 q4 n& U8 P$ i4 ?( o+ i    } // end of class AuthorisedUsers
1 j- V/ P0 A/ _! j' r  V1 H! v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
+ U7 x& Y* T5 U2 ~3 gShanghai - 20076 P, [; `4 F, t: B) H
Assignment 2
. s8 \3 u2 ~3 s: c9 DDeadline 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)' d1 ?, G! O& ?) U) _
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.
/ l7 r( f4 W2 c, @! uThe staff must be able to:( N* r% D$ ^" i( s5 U7 l( X0 I
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# d% V( l+ U9 B0 T2 f% q6 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.2 z6 b; [$ i6 o* |% G7 u
 The interface should provide a menu so that the staff can:
! w" ~; z6 c1 P5 g! ga) Enter the names of the two Java program files to be compared8 F$ O$ U  A( W/ g6 q, I
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& V/ \' P6 {5 K( b** 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).
. ~5 `( t- V5 t: [9 P" n' ^BSA104 Business Programming – 2007: Assignment 22 H; F6 f. \! L7 D# p
Page 2 of 55 z/ w. W8 S# a3 p6 E# c
b) Print out to the screen all the lines of code that are the same
/ Z2 M; q  }7 w% Z Include the name of the file and the line number of the code being printed for each of the two files+ h4 S. O8 c7 D0 w- j! A
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# G, q  H1 s6 v! Z3 A# L
 the name, username and department of the user
7 V8 w- c  `# S$ W the statistics of the comparison# ^+ M* G4 [4 C; `( e0 l* X6 A
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 V2 e9 P7 _& X- g) M+ d
 the recommendation for further checking% c2 F9 U2 A% @3 l3 y" v  x+ ~
- 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 ?$ z7 W' a0 E  p9 [6 `" [ the names of the two files compared
3 \' T9 D4 _. D( P& c% Fd) Leave the program (exit): y  l" t9 g. x9 y5 F  `, I3 i
The ProgramCompare class: (Total maximum 20 marks available)$ c. ]# Z& J4 `; g
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)5 ^1 Q: p; N7 k- m1 P
a) provide an error message if the files are not found or there is a problem opening them
. g4 Z1 T8 _+ |" m0 s3 j; u* Zb) compare each line of code+ U" x, Z  e; Q, f' G* ~$ h
c) print out the lines that are the same9 ~3 D) `' K6 X
d) count the number of lines compared / lines the same* Y: V; T. V# l. n- l4 }1 L% i5 d
The AuthorisedUsers class: (Total maximum 20 marks available)
( F1 N- D  b0 V1 w: G, j8 ?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)
1 t8 u  Y- g  F2 Y% g4. Provide methods to:
3 x1 O( m$ j) l. [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
1 v. |0 c' T1 V$ l0 y# eb) return the name of the authorised user
8 h! P: d0 ]. \c) return the name of the department of the authorised user
% y6 B* d9 Q9 \0 y5 e, l+ L  }Individual Data (Maximum 20 marks available)
5 L1 Y3 n9 a" n! R; n5. 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.
9 X% H) e0 x% k4 gDocumentation (Maximum 10 marks available)* u! |2 N3 I* k4 b: 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.
8 ^3 S' ]7 ?6 \7 U: U  m, t7 E7 f3 SBSA104 Business Programming – 2007: Assignment 2' t- o) x+ s0 m5 M/ M4 E
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! s1 X$ I2 o  m* N: ?3 X; Y不过你要翻JAVA的类库说明。你有下载没有?2 H9 B1 \. k" l
查询关于对比的函数。貌似关键字是contrast,还有compare1 F4 {  J- o, u9 u- k& G2 T7 W

) Q  ^9 ?0 m: x' K[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
% M: C, G% T) h% e, m痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 n1 Y. v, H9 H
可以下载到的 是 jdk-1_X_0-doc  I9 q1 g# Z7 w' ?3 [; f

1 F+ u1 o% `7 i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-8 03:50

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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