找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1303|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 S' L- x" O5 Q1 d: j ! c- R U6 x9 Z: c# r) k$ s; X
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; _" u7 ]# U" |# l' K) A& }2 U# I//  ProgramCompare.java         Provided by: DRS) I% l/ l: n, ]; Q, y% P
//! n) M. v/ o7 F" N: A- d; f
//  Program shell for Assignment 2/ T- @6 P( v/ @
//$ N" v' X: W! @6 D9 R1 V$ M& Z
//  Compares two text files line by line& [9 Q& g* B; E. K4 @8 g) H: H9 x6 Y
//*********************************************************************
" D7 Z  {* I$ n3 X% w4 k
9 \6 p% B0 |, k6 fimport java.io.*;
1 Y/ e" S& G0 I
' X0 f( h6 w/ \' e+ Y% s+ kpublic class ProgramCompare
, `/ O) \! l! T6 C7 h6 z' j8 U. Y{
2 D% A, o! x; w5 R9 d        //-----------------------------------------------------------------: J5 a) \% G, Y' t
        // Constructor
0 `7 [6 d9 N8 i3 T3 t& g        //-----------------------------------------------------------------
7 V: h8 m9 ]5 ?) }  h$ ~        public ProgramCompare()9 P6 O4 A( A' ?; G) W1 M5 m& }
        {
0 p/ y. N/ C9 |; J- o, Q0 `        }
' N7 Z& F9 i3 g9 Y) L& O" a+ a, N, l, k7 ]  @/ E% \! ]
        //-----------------------------------------------------------------
" d$ C9 O  H5 Z* G$ A# @5 d+ ~" v        // Method for testing that class has been reached
6 [4 P8 h8 A5 y* r4 M        //-----------------------------------------------------------------       
$ S' m/ M2 n1 G# L7 Y/ d
5 ~$ U, ^- t$ i8 g, K; I4 o        public boolean ProgramCompareReached()         $ \% n+ U. O3 n/ |
        {2 @8 D' P" A* K/ W1 @3 b
      try : c4 S% Z0 M; ~" T& s
   {           M& g1 b' _4 ]/ c1 c* {" ]3 F
                       
9 p' z3 O5 c) A7 b* _) N                //********************************************************************& }7 V. Q  T) h6 }; z
                // Try-Catch Statement is used to handle exceptions - such as file not found + Q: D, Q) a9 P2 e1 q" ]
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- ]0 e, w, R2 o0 D
                // For more information see page 534 of the textbook
/ l* Z) T# [# @6 B( B                //********************************************************************
$ A+ g5 F* \1 |2 z. U                    
$ n; A' V  @- T% w( q/ J        }
+ E- n( f7 m# E7 F             catch (Exception ex) // Exception caught here and message displayed to the screen
8 l+ G" _' {0 U6 v          {
% t, T4 d" f# G4 t* @5 w5 a$ t4 f& S                    ex.printStackTrace (System.err);
$ }2 z5 }4 G$ ?# ?           System.out.println ("Error message goes here"); // Replace this error message with your own          3 {& R" [$ y7 U, r0 Y
        }+ \$ ]+ s, @3 X1 f2 j9 @/ ]
                return true;
4 v% i. l1 `) G0 _* }8 H7 M% ^. p        }0 i% N$ D' v* q! N5 s5 @! n

' a8 B0 Q1 X2 p} // end of class ProgramCompare# h4 ^1 \- a8 g- x! A
6 p: w5 q! D# G8 b: j* K, [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************+ k1 a% e2 {/ r0 T* X2 W
//  ProgramCompareMenu.java    Provided by: DRS
& w; R9 ~8 E  u8 j; J//1 m/ U1 t8 @0 F$ t5 W3 m2 \( Z
//  Calls AuthorisedUsers.java and ProgramCompare.java7 X$ Z6 O+ A- Q" S! T' z; W9 |
//" O$ [. E. Y5 a2 W# D6 _4 U. e$ o! A
//  Driver shell for Assignment 2.( e, T  a- z$ l) V& y/ G0 M1 S, R
//********************************************************************
* C* N' j6 ]# J* W
3 |2 s5 u2 R# ?9 T# k. ?" @  Tclass ProgramCompareMenu: |0 f8 M2 W! n0 z
{. E& b' E5 F% ~; H' f& O
    public static void main (String[] args)
% n$ w, ?+ A0 ~8 p; a            {
* [7 g) ]( R" Q( l+ E/ A3 H2 Q5 |( i9 Z8 k                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: S  O3 w# Z9 ?( R5 ^
                ProgramCompare reached1 = new ProgramCompare(); ! b6 d/ e1 ~4 s
                AuthorisedUsers reached2 = new AuthorisedUsers();        ' O, D3 P2 |- ?" W( J; l2 E# _
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());" U+ J# Y. n. E. S
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 q" _. r4 {+ q2 a, k  Z1 C
        }
* t: G3 u+ t* r6 P7 r+ N}// end of class ProgramCompareMenu
. [1 U/ W! }( f* o- W! ~& X" n7 P1 d  {6 T0 x! O# s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ p: c) ?% d7 B- m7 ?
//          AuthorisedUsers.java          Provided by: DRS& Y' W' O9 J* G3 \
//               
5 [$ r: i6 Q( o7 C$ n$ h5 ~7 x//         Program shell for Assignment 2
, I5 J% g, U$ J0 L5 [$ G& z1 `/ f//! W' N' O: G# v! a1 w% b  C
//         Represents facts about an AuthorisedUser, q7 P0 v6 ~: q; {5 s' p0 U
//********************************************************************4 l) e# G* I3 L
1 @$ y3 N/ ]* h1 @% G) A/ N
public class AuthorisedUsers
# k' i+ }2 M3 q7 {5 E    {
& p" d7 P! x, y, F3 @4 ?: T6 C
  N; d0 @- W/ ]' A$ u( v* }        //-----------------------------------------------------------------
7 u5 j6 H# M6 Q5 ]        // Constructor' k. Y. e3 h& v" o0 E3 ]# T
        //-----------------------------------------------------------------( c- O# m+ h2 Q
+ }/ c: p$ l9 k
        public AuthorisedUsers()/ q- b- K- W4 U+ {/ P% ~8 f. `
                {/ |/ Q8 a$ K# r5 a4 V
                }
0 Z7 r. v1 o' p" C4 w2 @6 d" n- ?4 g5 S, f) c- z$ X) A, O
        //-----------------------------------------------------------------8 g5 F; \! J, {; m; B/ Z- h
        // Method for testing that class has been reached0 N* R5 \8 A. g  r# {" C
        //-----------------------------------------------------------------       
1 _$ a" l3 ?) ]( I6 T0 L        public boolean AuthorisedUsersReached()7 r5 a" ]+ k7 |* V2 F
                {' s: @. ~8 w1 g. ?8 v  \# A, P
                        return true;                        4 c* |6 Q0 u/ ?' r. E) ?' e
                }
8 T8 }9 n7 J1 H2 E               
9 d" t9 {3 l# S2 t( y# f    } // end of class AuthorisedUsers
/ }4 k" g6 W* J+ L( W/ z( |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% l/ b7 R+ u: P9 V
Shanghai - 2007" u9 T0 |2 [8 y0 z% a% G' H
Assignment 2
" @. }$ g4 n. {9 g$ a% j& A, W7 yDeadline 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)
  m! S" Y6 j( F1. 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.
+ j- l0 p/ Q# N( e! J/ dThe staff must be able to:8 o4 L( Q  r# D
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
5 [3 M1 b) q, ~# g1. 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.1 w% R" _' @3 d
 The interface should provide a menu so that the staff can:' P7 w1 n& o+ u, G/ R1 j3 c- t
a) Enter the names of the two Java program files to be compared
2 Q0 R2 j- N5 q. t( i9 N; j* y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' y/ ~3 u7 ~, i4 }- e4 s6 H
** 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).; u+ o9 h/ {& c6 d4 B
BSA104 Business Programming – 2007: Assignment 2
. O( t! H" x  g5 W- y* FPage 2 of 5
+ i$ @+ D; J+ o' ~1 Vb) Print out to the screen all the lines of code that are the same
/ h& j9 j0 p( E1 c6 N7 f# D+ Z+ f Include the name of the file and the line number of the code being printed for each of the two files
9 @, P) e( a8 {% I! R6 Mc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 K; e/ R" ]& }" b# C( {6 x  s5 g the name, username and department of the user2 T( }* m4 l* p( T6 k: Q
 the statistics of the comparison
" Y+ y( ?4 l  s  ^8 T- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 b$ D, E" \, q) D3 s the recommendation for further checking
& H+ \9 E, C1 {5 K- 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 closely1 q  A1 r* x; u1 D( S
 the names of the two files compared. D6 L# y& f* E8 h) k: }" |2 D
d) Leave the program (exit)
6 K( R8 N( @1 g9 S" XThe ProgramCompare class: (Total maximum 20 marks available). |1 D! B  X; Z1 N# j# r
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)
; h, I" I' ^. S5 }, {6 ya) provide an error message if the files are not found or there is a problem opening them
: @+ v/ P9 @' x4 [9 f/ gb) compare each line of code
5 n7 }2 B" U( v2 A7 u7 o) M. P% B8 lc) print out the lines that are the same; S* d$ g! M$ q/ R, Q
d) count the number of lines compared / lines the same
- L/ q$ x' O' e) [; c* lThe AuthorisedUsers class: (Total maximum 20 marks available)
* ^+ d  U8 P1 K: t3. 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)
& R2 ~- n$ P! ?4. Provide methods to:
0 C8 n6 `# T! B/ g, ia) 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
& Q$ C' E8 x9 V/ G" C; ~b) return the name of the authorised user
5 Q/ A" u' L% c( O( q, x6 `5 _; c  Oc) return the name of the department of the authorised user1 J* L) R! M0 k5 h
Individual Data (Maximum 20 marks available)5 a2 h- V! a! D  |1 k2 ~
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.3 d' M  ^) C2 B) s% A% B  [
Documentation (Maximum 10 marks available)
4 D# |! Z. |9 J; r6. 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.
! w6 T0 B" i0 U" s) u0 B1 ]BSA104 Business Programming – 2007: Assignment 2
4 p1 E1 D- {& j8 z: f* G8 {: D/ l5 _Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了4 p7 v! B( w: M& w; \4 T
不过你要翻JAVA的类库说明。你有下载没有?
% A5 y- ?$ a6 J+ Y9 _$ y查询关于对比的函数。貌似关键字是contrast,还有compare
# R' _5 |- Z, m: p- V' l% Z9 |
, @" ^. T  t  H+ {- k[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
& m0 @1 O  t" j# C/ ?! M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* }2 N7 o: y, ^, I9 ~* M2 ^2 m1 h可以下载到的 是 jdk-1_X_0-doc
% O( e, B6 R; H. v3 f# a1 t. p  V
8 Z8 H0 J1 {1 H. h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-22 04:06

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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