找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1612|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 b& S; p( `$ X0 ^- i7 O" h $ o. ]& u! p9 z0 s1 [( y, H
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( C! A1 n6 x0 A//  ProgramCompare.java         Provided by: DRS! Y5 K8 L8 o6 X; o' ]$ Q" g* D
//% w3 ~! V7 Q& h$ D2 r1 v
//  Program shell for Assignment 2
6 ~& H$ n; t/ n/ p9 H% c//; N8 v. [" Z  u+ X3 j4 F0 B1 X2 ]4 L
//  Compares two text files line by line( |( j/ z2 E- V, V8 E
//*********************************************************************
) k3 h! d8 F  p- b2 o' h2 W# k* q$ d2 m$ ~
import java.io.*;
6 E% ~; J6 M8 E# L" k1 M* T3 K
/ K( W+ e  T6 T# wpublic class ProgramCompare" _5 ?1 o/ h1 r$ D# n. D; m/ V* y
{
* h3 {0 ^8 t, W0 v; F6 ?        //-----------------------------------------------------------------3 F2 Z0 s7 ^% b% s2 m0 j
        // Constructor
  Y4 ]$ I( Z* D; G        //-----------------------------------------------------------------
, d, z+ b: j% ]( d1 D2 ~  J        public ProgramCompare()6 K# l/ H# Y8 k% ?+ _
        {* b1 q: [5 A* _
        }* C) B) |: K7 R+ Q: r( n
; t0 h4 B5 y& t- h
        //-----------------------------------------------------------------* ~$ w4 Z- ?% O& ?& G
        // Method for testing that class has been reached- x& ]3 e2 T7 d; K. s/ B% O3 L
        //-----------------------------------------------------------------       
+ r! |8 q4 S, a' c3 d: w
4 V1 }* O4 L4 F, `' B( [: h        public boolean ProgramCompareReached()         . M1 `' ~' i' N! p( J
        {
! C% G) u9 O: q3 t) t      try + d/ E3 X$ b" `: i* q4 d
   {        
( z1 o/ [2 Y2 o# k                        1 {& s. F, l) `4 M( M3 q
                //********************************************************************
; |" p5 Q2 [4 \4 p6 A* _+ g: g                // Try-Catch Statement is used to handle exceptions - such as file not found 4 _2 r8 E8 i7 A! f. M+ ]
                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 s: E1 J& y  Y$ n
                // For more information see page 534 of the textbook' V' R* b/ n. f& _, h: C2 c* Z, X; ?
                //********************************************************************9 I9 F9 `  e. }( }. y! `8 Q
                     ; l; b1 A) J" M5 g- v" ?
        }' W, {- r5 o, s/ |% U  f
             catch (Exception ex) // Exception caught here and message displayed to the screen : {% ]3 b0 L0 i8 F+ T! |6 l; M
          {
  V) f5 ^% A: ]! Q9 ?, e  q                    ex.printStackTrace (System.err);% v+ i4 r7 l5 `/ Q1 Z0 B
           System.out.println ("Error message goes here"); // Replace this error message with your own          ) {  J8 w" p' j' W4 i( y
        }" T9 X4 A  W7 {6 h4 D
                return true;
1 q3 @5 U5 A6 O0 f        }
* \! N. u& b# F/ I- e; W( b
) g& S- a. U6 ?* Y4 L2 W9 u} // end of class ProgramCompare# h( A: a$ Y! J

' e/ y" Y& R8 w! h" y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 p  u  g6 L4 s- F& U
//  ProgramCompareMenu.java    Provided by: DRS2 u+ I; b  u( U6 \3 P) A7 {% ^+ `
//
. j* ?8 P9 ^$ }! k1 t. ]- q//  Calls AuthorisedUsers.java and ProgramCompare.java/ g! s6 X/ ^0 P. s" i
//
+ T7 F5 U, O7 k4 `* K2 {//  Driver shell for Assignment 2.1 H/ x7 f" q5 k1 J% M
//********************************************************************
4 ^; G" s$ K0 R$ X
' `1 k' R# q3 Y: zclass ProgramCompareMenu
% J4 B/ x; \5 x  f! p" d{
! |% Z% c8 C7 l3 ?* y. F    public static void main (String[] args)
3 B8 W" c9 y/ c5 h  f6 ^            {- ^2 J5 m. [' r! [
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& }) ?" l1 A) B! e) U
                ProgramCompare reached1 = new ProgramCompare(); 0 B$ `, e$ r% ]' D
                AuthorisedUsers reached2 = new AuthorisedUsers();        6 b* V' l7 w6 [0 O7 o; n; b) U+ [# i
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) Y' y: v- a8 R/ Y) E9 b" ~5 \% H" Z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          B/ F# P+ C) I9 E
        }
3 |  i8 U/ G" a3 C' z) \( @8 l}// end of class ProgramCompareMenu
7 W( i5 A, x! i0 J  m9 m: W
/ E7 W+ r  f' t$ g& ~. U- R( F* T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
% ^; `+ a& j7 }//          AuthorisedUsers.java          Provided by: DRS5 j1 k( C; i0 z0 _* E
//                0 H+ W2 n: p, G
//         Program shell for Assignment 2
6 t1 U7 {8 p" L3 t2 J' y//
" m4 }( x" I" W( O) p7 a6 \9 d//         Represents facts about an AuthorisedUser1 |! n$ N' m9 r- S
//********************************************************************& D9 \; Y& n1 {6 x5 {3 k

; w; N6 w' D% B1 R" ipublic class AuthorisedUsers
) J7 X$ U7 t4 g0 Y" [    {
+ {' S" ~( G8 I) d' i
) w- U& I  @5 w& W        //-----------------------------------------------------------------& Z" e2 o4 D1 F* y4 \
        // Constructor$ q. q4 c, `5 G
        //-----------------------------------------------------------------) W- i- D; n4 V0 b

) K7 ?, a' \) ^. R( c        public AuthorisedUsers()
3 I1 S: X$ S* I. h+ r                {3 r/ s  d  X8 |
                }: u; f1 D1 L& D+ j7 g. g8 c2 k
8 l; `* t" C  _$ T
        //-----------------------------------------------------------------9 j3 I2 {( B' o% o' R) ]. z- k' C
        // Method for testing that class has been reached
1 F/ S' c) ^4 {! }% N1 w. J0 ^- y" G        //-----------------------------------------------------------------        / D8 t4 f0 C8 i: e2 p' _5 E
        public boolean AuthorisedUsersReached()( i# c8 Y2 ?1 x8 g6 M
                {
7 K9 ~0 F$ h! [) N3 @& u2 Y                        return true;                        * @! r0 B5 S  e6 N
                }* q7 C) k2 U6 z! s1 n* z
               
. u% {- n* {" p6 J6 _    } // end of class AuthorisedUsers
* t' I7 k5 o8 E* a/ |: b; W8 u/ u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 K9 W  d1 Q  w, x! B) k
Shanghai - 20075 x5 {7 ?$ A/ ~# m( l1 t. [' U+ L9 U
Assignment 2* V" j1 V9 [5 t/ D  \% ?' H
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)
$ t7 l9 _- }7 S5 G4 D+ ^8 X/ r1. 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.
8 Z. Q: ^% d# N7 Q# G/ ^The staff must be able to:
" ~$ H/ b+ U1 j  ^$ S$ `/ S0 {" ] Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., n6 s6 i5 i' y2 P  i
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.% [# I) ?0 {/ L9 B$ t2 X; }
 The interface should provide a menu so that the staff can:
2 C- v' w8 e6 A( @/ D* Oa) Enter the names of the two Java program files to be compared
. P0 i8 b' H& ^9 d$ V9 t+ ` For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 }, P* @# I( `/ w& z3 y1 V! x
** 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* k9 v3 R8 f# F( nBSA104 Business Programming – 2007: Assignment 2* V/ u( n/ O7 W. A: M, {  A
Page 2 of 5
5 }% _. u, T+ A* z7 r; L& j, ~b) Print out to the screen all the lines of code that are the same7 t* L  z4 D$ d. q6 W+ u5 b, J4 G
 Include the name of the file and the line number of the code being printed for each of the two files, U( O4 V$ l, K2 Q8 n
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
1 v0 z0 b7 k/ g& X" f the name, username and department of the user/ F5 e4 p0 a9 C5 |6 }& i) u  r9 h
 the statistics of the comparison' H# {; V) M8 z. ?+ O9 u1 Z  k) {# f
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# L% i( s+ E/ N/ B# q* S% E3 g
 the recommendation for further checking) g# c, p0 O0 p  t) J2 |/ `
- 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) `' S) V$ ~* A
 the names of the two files compared
; N; o" U# l( f: \d) Leave the program (exit)2 G( O% f, @: x+ h& P7 S
The ProgramCompare class: (Total maximum 20 marks available)1 y1 H. d) I  x; a7 Y/ 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)
1 H* m, m7 \4 h1 p5 U8 i& ua) provide an error message if the files are not found or there is a problem opening them
, Q, D; B6 U1 e# ib) compare each line of code' ]/ O- {- A4 e4 ?" n. W+ z
c) print out the lines that are the same& P2 G* {. F! x% X( g7 q  Z
d) count the number of lines compared / lines the same- ]" Y* K9 E4 ^$ C* S. B1 Z& y
The AuthorisedUsers class: (Total maximum 20 marks available)
- |$ W  ]8 ]4 v3 B# |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)
- M  h) B1 b( M4. Provide methods to:" _1 V* H1 t" m4 ]* L1 U! Q+ Q
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% \# h8 }$ Z4 y2 E% C, q+ l
b) return the name of the authorised user. i4 i8 K- \  P( X1 _7 K* N5 \
c) return the name of the department of the authorised user
/ }  r! S& V8 F. ~9 c+ l+ L/ h/ JIndividual Data (Maximum 20 marks available)) @+ J' [& p% O* R( J  D1 K  I2 r
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.
; b% V' i( F: Z3 }$ ~) O3 BDocumentation (Maximum 10 marks available): `/ Q' C& V0 [5 @2 U1 E; {
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., g. J1 @( r$ h4 p9 d
BSA104 Business Programming – 2007: Assignment 2
/ i+ n: E0 D4 F1 EPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& j: W( O8 U3 [  U不过你要翻JAVA的类库说明。你有下载没有?1 H- n2 i- s6 X. o$ ?5 |( k3 q' n
查询关于对比的函数。貌似关键字是contrast,还有compare. {$ l( t% L  {. p: _0 c
. q! z, p2 I1 |$ n. G
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# @! o3 A6 J" {: k
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 l0 i0 q; E  q1 f
可以下载到的 是 jdk-1_X_0-doc+ }) ~% o2 g; _' d+ w; a

& w9 G- B9 u& o1 K5 m/ \[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-7 15:05

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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