找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1832|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 : W, y( R0 e& j+ [- }% m& W9 b * `9 J" Q' R6 J' G2 e# S ]% Q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
" g" P- d$ z  }1 ?8 m//  ProgramCompare.java         Provided by: DRS/ x3 s$ `4 ~( S; a
//7 q8 `; Q& G1 G: l  U
//  Program shell for Assignment 2! T* ^; Y* X8 t' m1 [
//
1 `2 e# Q$ A- n8 |4 U) X* T$ ], P//  Compares two text files line by line: ~7 U8 d2 h6 J7 _# u; \9 Q
//*********************************************************************
- K/ L  i# r6 N- K1 L/ G, z; ^, f6 ?7 ^7 s
import java.io.*;) a( y) M) _) T4 D* n8 u" \

) }. \9 Y& ^( t: C) s$ Wpublic class ProgramCompare
" L' j8 g& {' i9 v{4 w- o6 P) X) n5 N' @! q! M0 ~
        //-----------------------------------------------------------------/ _" h0 i4 {. }8 G- ?
        // Constructor+ g: ]: g9 \6 Z& X& M" e# U
        //-----------------------------------------------------------------
1 Z9 b3 ^. C+ u        public ProgramCompare()
- o# @: Y% v6 P1 O7 p/ L        {) O1 i( }. n# O4 S+ t
        }
8 z: u% S( l9 b: f6 H0 y* N$ o8 X8 w$ h
        //-----------------------------------------------------------------, ^$ c& g+ ]$ l4 u- V4 x) I
        // Method for testing that class has been reached  |! a5 X. i% K( S3 r4 q8 @
        //-----------------------------------------------------------------       
' o7 y3 y3 T! M. J
) l5 D) U% T* X& |* M5 \8 J! w9 d        public boolean ProgramCompareReached()        
: Y, P9 R7 W) Q- u- w        {3 K( ?9 E( `5 v+ L2 m& I- Q
      try ! W) @( Z" |9 O: ], I3 ?
   {        
" b6 V: j3 e" Y- Q5 j: M                       
0 Z. ~9 F6 F6 U8 ^! n" y( s2 P                //********************************************************************6 Q, r: @+ ]2 r! t3 @
                // Try-Catch Statement is used to handle exceptions - such as file not found
2 j6 U0 H$ S) p2 Y                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. N& Z/ ?9 T% D( ]/ Q4 e$ r5 P4 m                // For more information see page 534 of the textbook4 c0 N+ {) S0 ~! R+ T: W
                //********************************************************************
% ]4 v. z$ I1 V3 @9 c- B6 u# B                    
; X7 G+ m& M- N; C0 M+ P        }
4 A4 p& w5 U  t7 B2 r( s             catch (Exception ex) // Exception caught here and message displayed to the screen 4 q  n6 N8 o( y* p8 l3 y- R
          {
8 A# \7 ]" Y# c' ]$ k% y4 E                    ex.printStackTrace (System.err);
! M4 c) D! ]( P% t# E- F0 d, {# f8 a/ L           System.out.println ("Error message goes here"); // Replace this error message with your own          & h6 ~/ N- j9 v' a8 f9 \/ l
        }( _: E6 ^5 q2 S  \& Y7 B
                return true;. O% P, G0 R' D
        }6 c. u+ V( v6 k: R$ N* \
# ^1 a  d4 ]. T( k5 Z( A; ]
} // end of class ProgramCompare
8 K9 d. Q. W5 W: u) k6 Y" l
# y# [. _' o: m) o* O$ D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" _5 _; J/ c2 x3 |3 j
//  ProgramCompareMenu.java    Provided by: DRS
" k- G! J+ }! C//9 j$ f: J) H' f8 ]+ t: u
//  Calls AuthorisedUsers.java and ProgramCompare.java
5 @9 Y& l( R7 d" z6 v//
4 ^& g6 }4 i' ^6 D! U4 t//  Driver shell for Assignment 2.
' T+ c. p: T& O/ g# G4 b//********************************************************************
, c2 M! U4 o+ ^/ [
8 l1 o( p9 K$ {0 B6 {3 v9 ^- Aclass ProgramCompareMenu3 ]+ R7 ?  g$ h- a4 h
{
. Q+ j* [0 ~1 w- N    public static void main (String[] args)/ Y+ T3 y! Z0 e& E- o+ a$ {& N
            {
8 G- g0 B* x$ v9 `6 |! H1 o3 D                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! ~% c/ K( R  S  S* J                ProgramCompare reached1 = new ProgramCompare();
: R/ z9 t8 }8 `# A5 c4 a                AuthorisedUsers reached2 = new AuthorisedUsers();        4 g7 ]/ O3 ^, J+ m. A
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 v4 l( i! s# N$ W3 _* }/ W
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! d2 P( D0 k2 |; d9 T# @        }0 t7 t) |. E  X) p
}// end of class ProgramCompareMenu
7 r7 g: a8 g9 [& `5 Y) \5 \" D: m2 ~  e3 M; i
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
) E2 o0 ?+ b" o$ \! o$ {( j) W2 G6 d8 {//          AuthorisedUsers.java          Provided by: DRS0 j: q5 l+ M* t: B
//               
" V1 d. E2 s* f* R) `. E//         Program shell for Assignment 2& t$ k* k: ^4 _1 M$ P! S
//& x% ^4 n. s) Z6 r
//         Represents facts about an AuthorisedUser' }2 G! u+ _/ @2 W2 q6 |+ ~/ J
//********************************************************************
: ]5 t& ?8 |5 U' D! C9 C8 ?- @3 N$ u
public class AuthorisedUsers. h, i! }+ L, T% @  e: E+ u1 z
    {9 v1 b" m5 J0 ]5 W% k
4 n2 o& {& ?* _7 {
        //-----------------------------------------------------------------6 Z* L- B# a/ w* m
        // Constructor
, K4 b) q2 t! f( [9 @" b3 [        //-----------------------------------------------------------------$ c! b$ k0 P, w0 n& O! S; r! n

; j& c* {1 \' h/ y0 K0 a- n2 x4 ^* L        public AuthorisedUsers()
, l7 v' P' m9 o2 S0 J                {. c0 [, Y& `* v" w' f1 h
                }  J3 k) @: F' L( s2 n

9 [( {% E9 T- C9 }/ z$ H# i; R        //-----------------------------------------------------------------9 |: j) ~/ }  l; V, [/ ]
        // Method for testing that class has been reached
" S! q2 r- c" |/ F& B/ K        //-----------------------------------------------------------------        2 M( |1 S4 Y( ^; B
        public boolean AuthorisedUsersReached()3 S, ^! O  `8 D( u) ^9 b* U! w
                {; n* w; ]' P# }. h) h( h
                        return true;                       
5 R! D3 G7 P; \- L/ _$ M. U+ l( I$ ?5 ^                }! d" K( b" ]( H4 N
               
2 d/ X1 J# N) A    } // end of class AuthorisedUsers1 v" F7 j% W$ U2 Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 d7 C0 }& o# Z/ F
Shanghai - 2007
1 q. Y1 ~6 _# I& F3 H1 g6 ?Assignment 25 q: x1 D) P4 v
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)7 ?0 d" j" E6 H, r9 c) G$ a3 s' J6 {
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 P( i1 q2 z3 p9 \The staff must be able to:
2 C. V7 a+ M! h' H2 l Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' c- J. M' T9 V0 D' p2 ]5 ?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.
3 k+ x1 C4 X) M# ` The interface should provide a menu so that the staff can:
1 @$ @4 w/ C* oa) Enter the names of the two Java program files to be compared) W  O+ `! E9 b2 J' v
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 ^# `: H' q2 }0 t3 o** 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).
9 N4 Y. c3 ]4 g3 z& F# |BSA104 Business Programming – 2007: Assignment 28 I4 f' Z3 G$ o" M# q" |
Page 2 of 5
3 y( B, a" R. p$ O3 V6 V0 V$ hb) Print out to the screen all the lines of code that are the same
, I  ~( Z& m7 z0 q Include the name of the file and the line number of the code being printed for each of the two files) l" i5 G0 R7 @, C, }
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! j1 E3 u, L- O" J" g) Q$ d the name, username and department of the user
1 b6 x3 ~8 l3 W9 {1 E" ~7 _4 ^ the statistics of the comparison0 j) M2 o( r4 w' K/ o
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
9 r3 Z) p1 i  b; N2 Q+ y) }# m the recommendation for further checking
/ Y- D* ?6 W/ x$ r: B5 _. p- 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' x6 k8 W5 J9 I  V
 the names of the two files compared
6 z& m' v! H9 D4 ?0 k; Yd) Leave the program (exit)
' T0 [6 i8 P, @( t7 q+ NThe ProgramCompare class: (Total maximum 20 marks available)
" V- R# |) X: j% [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 L, J5 Z5 b" [a) provide an error message if the files are not found or there is a problem opening them; w# U: M4 m! n' J1 ]( s( p0 E1 e  B
b) compare each line of code
- |+ ]3 y# ~8 u( @1 i* sc) print out the lines that are the same
2 r% D) A! U2 D$ ud) count the number of lines compared / lines the same( i( e2 m+ H3 D# R' q
The AuthorisedUsers class: (Total maximum 20 marks available); N, z3 z& r( o2 D
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)
7 W8 T6 s7 n. |& A! i4. Provide methods to:
; a+ V! K, d/ \4 na) 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
# v5 v2 C0 o  mb) return the name of the authorised user+ n1 A) k  R2 G
c) return the name of the department of the authorised user
3 M  D8 U, K# D1 b' }3 b8 TIndividual Data (Maximum 20 marks available)
/ M( T* @: [) @- o5. 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.' \: y- J* l' ^" A3 [! ]: x/ a
Documentation (Maximum 10 marks available)9 |, ^+ v3 L- v
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.- O3 l+ k9 i) B# B4 t+ j4 r" j
BSA104 Business Programming – 2007: Assignment 2+ N6 t. @3 ~: D9 [2 }) |7 e+ V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 r( U9 L4 d  h: P8 b. L
不过你要翻JAVA的类库说明。你有下载没有?
- O1 ]' G3 X7 Q8 }* A  E# g3 T" N查询关于对比的函数。貌似关键字是contrast,还有compare
1 l3 ?) ~: y$ m9 q3 @8 r6 @% D% X  R' p: @, l3 e& ?
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 p) q- t8 F* N" S+ {* {' D
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! z$ h. [" s1 M
可以下载到的 是 jdk-1_X_0-doc
. o6 g! B, Y9 h8 b% q1 u( I9 m; e- Q4 m" z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-16 08:08

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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