找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1805|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! k: [' T8 f& a3 v) Z3 }: i- p- A8 [4 a* }1 _; q# O, \
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
$ Z2 ?0 }3 A: B" {& `2 Z//  ProgramCompare.java         Provided by: DRS7 y. P! c0 n. h& S' K$ O
//7 q! n- n- F' g) O. i% x7 i7 i
//  Program shell for Assignment 2" n0 }( k2 l% ?
//, K' u3 ]2 l1 z) j  \. {
//  Compares two text files line by line
9 M. k7 P+ `, p- [* i//*********************************************************************- h  R' n. [. I! [0 d

# `% x) z: V. V8 F$ x" M, z1 W' ]import java.io.*;% _. ~6 m0 d2 p

( I8 @( y0 e5 apublic class ProgramCompare
: i# M; C8 e. {5 q& G5 F8 i{
7 I: a4 O1 m, Y* M        //-----------------------------------------------------------------
4 ~. e. f# P, R9 c: X+ N9 Q1 ~        // Constructor
; h/ b0 f# D! y( u/ r( S        //-----------------------------------------------------------------
$ ~! `$ c4 O, n        public ProgramCompare()2 @1 c5 v: R  @+ T* U
        {& ^" t* l1 d6 o
        }
/ Z4 X6 G% m( t6 O0 k3 H" b4 D- S$ C" v0 ]# M# E0 I
        //-----------------------------------------------------------------  E' Q) Y7 r' U1 U9 \' {8 b
        // Method for testing that class has been reached
1 \/ f6 x/ s: f        //-----------------------------------------------------------------       
& A& m" d5 _8 z" q% u
  w0 E7 _* ]6 a' ?( j( H% n        public boolean ProgramCompareReached()         * T  u6 W9 T9 m+ S* p9 x
        {
, w6 w" o/ \; V& y      try 7 p  A1 a4 K/ _& j  k* ]+ j% d
   {         4 G% }7 R; S9 y/ z! u0 l2 C
                       
! I( N5 \1 y2 Q' X5 S                //********************************************************************
( ]4 R! ]: z* o; n# i$ {. n                // Try-Catch Statement is used to handle exceptions - such as file not found " f2 C; L3 l$ u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
0 d9 K: Z$ k# l" v1 e( v                // For more information see page 534 of the textbook) X* X: N1 {  W2 l
                //********************************************************************5 T  B7 V- J# r  k5 \
                    
  _- k/ ^: {" o8 T" b1 d8 `* z        }- q& a9 ]7 u* Y( G8 P; x" ]
             catch (Exception ex) // Exception caught here and message displayed to the screen
2 ?8 Z3 s3 B9 Q* X) g7 ?8 x          {" G* a( w$ S) v' M, I  z
                    ex.printStackTrace (System.err);
& ]3 [% y; ^# {2 x, Q* \; L           System.out.println ("Error message goes here"); // Replace this error message with your own         
3 g2 N6 N5 P5 r7 c$ N' k+ T        }
3 j5 G/ P' G4 n+ f. S: D0 ]" @                return true;4 G  B$ t: ~# e' O8 ^
        }
' V, p/ R4 p; T7 Q3 c: Q/ b7 K) l7 `4 Y, f2 f) W
} // end of class ProgramCompare. n6 y# K1 Q( i

# f- P( q# ?7 y6 K5 B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; ]1 M5 p% ^$ x  T( J! K
//  ProgramCompareMenu.java    Provided by: DRS
3 K) u8 r9 M$ K- }2 G/ D//
% b2 x7 u  v- I: ?//  Calls AuthorisedUsers.java and ProgramCompare.java
# R! j7 {7 ?; I8 e- B% t//" I* c& T, o# u/ o8 d7 P
//  Driver shell for Assignment 2.6 [6 ^1 w) `+ F) Z+ c6 B
//********************************************************************- j6 t3 s% ?' A

, X6 b( W- v% s# Zclass ProgramCompareMenu: x; x; y5 H3 z* ?* P: A  @
{9 o/ B" w* A8 [
    public static void main (String[] args)+ a) Y6 K$ m/ Y) f# g# y- I
            {" l$ f- {% D" L: ]3 P5 E
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 K3 k6 t1 n3 e4 S0 e6 ~
                ProgramCompare reached1 = new ProgramCompare(); ! B+ v$ _0 V8 z0 r& h7 b* h0 Z
                AuthorisedUsers reached2 = new AuthorisedUsers();       
0 ?8 K4 k0 k* b0 K( W3 B$ h                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" O+ l$ V# J$ y! O! p- Z+ T                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 ]) K" F" r0 e, J0 d        }
. T  d" w5 q& U8 [' P}// end of class ProgramCompareMenu
) }) v* ~1 q+ A; A! O
4 l# \/ y, ?  g; b6 Y" D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  d& [1 J& s2 L3 r
//          AuthorisedUsers.java          Provided by: DRS$ S8 t! H4 a4 w$ Z! K
//                ; ?' J/ i  |4 B+ e9 _! Q
//         Program shell for Assignment 2
# `2 w* L; L* i. {5 y* E7 s  L//
1 E) T# `3 r$ u! q7 G8 Y9 u//         Represents facts about an AuthorisedUser
+ {5 X# r5 b' [: ]  O3 L+ F//********************************************************************& @' R! ~# k. d1 A

9 G" {+ `4 B1 z3 V9 ?- jpublic class AuthorisedUsers
$ ]/ g) ~5 R4 b/ [    {
, z0 k8 @& x8 C6 s+ `5 T# Z# X  Q* x
        //-----------------------------------------------------------------
/ E6 ]3 P: B+ F% q0 o" n        // Constructor
. Q& S" R) Q1 E- r& k3 d* b        //------------------------------------------------------------------ |7 {: x; U8 n) n: [3 {% u

3 G, L$ i) \9 {9 ^) E, G# J        public AuthorisedUsers()# O1 e2 b# }+ c, }0 Q. |8 A) u
                {1 N2 p1 \: `7 a/ A0 E, C
                }" c1 H- @. @' U

9 B& `7 G4 Y1 [) u& ~2 A6 e        //-----------------------------------------------------------------
1 u9 Q9 f0 y9 |  J$ m. a        // Method for testing that class has been reached
/ u: g8 x% z7 g# i        //-----------------------------------------------------------------        ( T$ Q; J! k5 c" A9 O, r: L* r
        public boolean AuthorisedUsersReached()
) q- L& |' n' Q. @/ Q6 |* _                {
* n1 Y" b$ [5 Z8 W  @- n* j                        return true;                        ( ~4 O7 _. s9 P! s5 D( |* T, D6 M
                }  _5 e( h. D  P; v; b0 d5 n
               
# k: }/ o. C: F% z- }    } // end of class AuthorisedUsers
$ s4 e0 @! n$ X6 H7 f/ f7 v& w  U: }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
% K5 l- x8 E" qShanghai - 2007
% g# r$ f! z# W! f3 Z5 w, |Assignment 2
; T5 f( ~5 U, M/ r4 BDeadline 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 u+ }* g' v. C' ^3 l7 D2 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.+ [9 f9 O) z0 I; H; u9 d, S8 {
The staff must be able to:
. U! v( i+ L/ t  q: ^- B Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ K: l4 r$ e0 N& I0 r0 _' y0 Q1. 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., Y" R9 Q( g" A: w, I% G
 The interface should provide a menu so that the staff can:
# k& w6 X! K% W. ]/ d# k# Ya) Enter the names of the two Java program files to be compared
) N/ X5 d8 b; w6 n" y. i For this assignment, it will be assumed that the two Java program files are in the same folder as your program.4 c4 c' ?2 [$ U& u9 F6 g( w" `
** 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).* ~% q- U0 O; K( ]8 {
BSA104 Business Programming – 2007: Assignment 2
4 _1 E9 l; m+ }6 XPage 2 of 5
% ]) k* c" ^. F+ _* t% `b) Print out to the screen all the lines of code that are the same9 R( d! c9 p2 b7 q! i: U9 {0 o
 Include the name of the file and the line number of the code being printed for each of the two files1 z0 g, V' o7 g, c6 R8 y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% C' t$ F2 o5 _2 W
 the name, username and department of the user
+ c) U6 s) {: h) B! R( Y! X8 Q the statistics of the comparison
0 E# S. p; ?; n7 n/ D- f- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 k+ B: j( d9 K7 f
 the recommendation for further checking
" ]2 k3 c5 _/ e7 {2 _+ n- 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
" ^# r& f- B( w* x+ n7 N) @" e' z the names of the two files compared+ ~$ h3 W" O' O  E' Y0 n) k
d) Leave the program (exit)- F) g! L8 |6 h1 Y  J% v
The ProgramCompare class: (Total maximum 20 marks available)0 B. _4 B' Z7 l/ l
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 ^, [/ K) B+ h2 \0 _a) provide an error message if the files are not found or there is a problem opening them
+ w4 r- w" e: f( m4 e' k. [b) compare each line of code
& Q0 f6 t, X: n3 \c) print out the lines that are the same
) s5 C+ t  Y5 Q1 dd) count the number of lines compared / lines the same5 l0 q5 w$ b) H+ `8 m+ ^: Q
The AuthorisedUsers class: (Total maximum 20 marks available)
% n- }7 t3 s: D3. 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)! f1 d; }) W; C3 T* s6 N
4. Provide methods to:( l2 M  ~3 o% @5 @* o
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
; l& \- {5 M3 rb) return the name of the authorised user. _9 m) j" U# Q4 C" i4 n3 u
c) return the name of the department of the authorised user
" I2 k1 R6 _! a7 c5 K: YIndividual Data (Maximum 20 marks available)
! @: P& g2 [6 `0 b* x5. 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.' ?5 @' ?. c1 u: r
Documentation (Maximum 10 marks available)
7 |3 G3 \2 ], I) J6. 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.. d3 H1 b! `: V0 {4 D
BSA104 Business Programming – 2007: Assignment 2
- ]% ]7 e, \1 d1 ]) K  @3 fPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
0 }4 f# b1 M4 H/ u不过你要翻JAVA的类库说明。你有下载没有?
, u7 ~/ {! u: |7 L9 K8 W查询关于对比的函数。貌似关键字是contrast,还有compare
- ?7 }- c5 B5 R" n" m4 E, k& N+ a7 Y& ~0 A9 m' `6 R1 B
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -$ J- w4 O& A9 ~+ b: m" Q9 ^& }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 G$ }0 m" R) C* @  k可以下载到的 是 jdk-1_X_0-doc( T) I5 `% G7 N6 ~/ L/ T# l8 T
. \% }( ^/ h: g8 s
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-7 19:38

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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