找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1810|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% V5 J1 a0 |; i8 c0 D* L$ n) { % z' H- K; F! H7 a! w: G: _- |
回复

使用道具 举报

 楼主| 发表于 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( @( M. K) u! F8 x7 Z! Z7 \7 ]
//  ProgramCompare.java         Provided by: DRS3 T( q  x( j- B, P
//
5 q' t: J  g/ L% {/ \; ~9 @! s7 e//  Program shell for Assignment 2  a2 S* G. Z: h' Q: a$ p5 {
//" _' j( D! J, }5 ]5 i0 B
//  Compares two text files line by line
+ T8 ?: m1 p; o1 J//*********************************************************************
$ i1 ?1 C1 O+ Z2 P
4 S$ @" T+ R& T' c; Dimport java.io.*;* L* ^4 h5 }7 y

7 z/ s8 d4 T: T, [; epublic class ProgramCompare
# [7 W2 @: t. t8 Q' c! F{
( J" \9 c7 H) D. i. n; p        //-----------------------------------------------------------------) J2 x; D; }' j( r# E  X
        // Constructor
6 n( @$ l' G* o/ C: Z' ?) k        //-----------------------------------------------------------------1 l* ], G/ U7 e! |* q0 n; w6 Z- F
        public ProgramCompare()
, \- D" v" P( [2 J4 O        {7 n! D# W9 f  M+ i
        }
  W. A, M6 V  z% M0 A, |4 |9 P7 G& r. d9 Q  S4 p
        //-----------------------------------------------------------------
9 {3 X9 f7 d7 l  i, a& J        // Method for testing that class has been reached! F* }, ]$ R2 K% }- w, v- S
        //-----------------------------------------------------------------       
/ a# P. v1 Z8 b7 s6 s/ A- c2 P2 L* Z* O8 {
        public boolean ProgramCompareReached()         8 D/ _2 A) R7 j8 f. X8 @! k
        {. |3 P3 P7 A% |
      try # d2 q5 |2 b# j: F5 c
   {        
; K# I0 c' p4 A8 Q                       
+ r6 ]0 c6 s8 U5 }9 E) F                //********************************************************************  _% u) l" U- F  v* f5 D- H
                // Try-Catch Statement is used to handle exceptions - such as file not found & @' s8 Q/ h8 a. V$ S
                // Reading the files will need to be placed inside a Try-Catch - just like this one!. V: G: M! @. S2 Q, e5 \4 M) t
                // For more information see page 534 of the textbook
# Y! x0 ~% v" T$ G/ w                //********************************************************************
, B: ~3 R  c. b) Z7 q3 k% l                    
3 K3 n+ X  b9 L+ Q0 W) a) o- |9 L        }, V9 C$ Z0 X/ Q) j7 O, J7 r
             catch (Exception ex) // Exception caught here and message displayed to the screen
. V) ~! P% d* d) R' B8 S          {& l/ B! U& Y5 m7 m) H* H
                    ex.printStackTrace (System.err);& _+ u' Y2 V8 n% T4 o* g% [8 j! l6 J
           System.out.println ("Error message goes here"); // Replace this error message with your own         
) z2 [9 E" A; ]8 J/ N# k  u! Z        }
( I( m: ]3 P( G- r4 V                return true;
: A$ @6 s* ?# G9 f; c8 b1 n# j        }
7 t/ b! o; Y; ^6 R3 h
$ V% o0 J6 _8 b2 V7 q) U} // end of class ProgramCompare
. l% [4 W) Q% D8 t& ?3 }. r
- y9 K: u- w2 q$ U2 F: Q& o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
: k7 `6 h8 X  G* r/ M//  ProgramCompareMenu.java    Provided by: DRS
1 ~/ A5 Q/ u0 o0 l9 g' Z3 b$ [//$ E' y4 v/ a# R% F( z7 v8 s
//  Calls AuthorisedUsers.java and ProgramCompare.java
; ~7 N( I. M6 a4 ]//
6 y. g4 R# s) h1 G//  Driver shell for Assignment 2.2 r4 @" O+ v  b2 R# {6 C; G
//********************************************************************/ A6 ?  e1 e/ g; Y  h

; ~, k, U8 K7 o/ ?* J' Fclass ProgramCompareMenu6 w" F) s* X/ c7 C$ \5 U! B
{7 r3 c  ?8 H  |6 J* G
    public static void main (String[] args)
% i% \) C& K( |6 D            {- N& m& r. e- q: f6 r5 H
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% Z. ]% q7 h8 v$ T( L. a9 s                ProgramCompare reached1 = new ProgramCompare(); 3 V2 \" s5 f9 C" Z& G
                AuthorisedUsers reached2 = new AuthorisedUsers();       
7 K. Q+ ]" k1 W0 Y                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  D7 [/ i8 h2 ?3 e! z6 _4 Q                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , O& i6 |$ c1 f) u
        }: f3 v! r1 v! g2 L, L1 x& }% e% p
}// end of class ProgramCompareMenu  H8 C7 T' |. Q& D5 |# {

; P( f+ W! f" S  J" T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: v0 d& r! f8 M( j' h. N+ g) ~//          AuthorisedUsers.java          Provided by: DRS
* V2 f6 d' D- Z7 b  ^! p//                8 I7 S( E3 c. j  {2 E, o
//         Program shell for Assignment 2% O8 B! _( z8 T* R
//7 y3 f; T  ]2 l" B! c
//         Represents facts about an AuthorisedUser
9 x. R* o- M; L7 S  D5 q' t1 C  f, p//********************************************************************
- h( l1 W) N5 M) d" q. Y+ x+ i* h6 ~3 p5 e& |3 a
public class AuthorisedUsers+ _0 S3 O6 k' d! b, o
    {7 Z" C6 |) X9 F  l1 ]
3 B6 k( g9 T+ @' q  y- o1 I9 }
        //-----------------------------------------------------------------& T, @% d. b. {) ^) h: V6 e+ s
        // Constructor
) j+ E% C2 D3 m/ r( E' `" [0 }        //-----------------------------------------------------------------* e$ n% d  j/ P

! r. b6 g, V3 d3 Y" N0 R1 i9 f9 I/ b        public AuthorisedUsers()
" D% W7 p8 R  t# S" z2 V                {
0 x) ^( y; ~8 l! U                }+ j: u) R) Z6 H( a- p) n" K4 k4 v

, o4 y, x- P4 v# I& i  K        //-----------------------------------------------------------------8 p, J2 g2 @1 b# j# m3 @
        // Method for testing that class has been reached7 {8 O$ O; c5 ?8 g, J( R4 [
        //-----------------------------------------------------------------       
2 B( H; h0 h! j, K* g. ?% g        public boolean AuthorisedUsersReached()
& Z# T* Z. K& ^8 D7 F                {
7 F4 c, g$ O2 f                        return true;                       
: ~2 J9 X! W+ }9 Q4 s+ p+ W                }! O6 a% V- \, g4 {' c! e
                : Q& }1 u7 J) A
    } // end of class AuthorisedUsers
# w: k3 X! }2 V# I+ Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming; R+ p- J! S+ L# O% I
Shanghai - 2007& m' l& z6 A  i% `. S5 m- e
Assignment 2  _/ k  q' a- V7 i1 ?
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)1 ~1 c* ]; n8 v; }
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.
) l) X! y! L5 }. Y, b" SThe staff must be able to:
; x& q- p+ N8 c( O* u3 @ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 d; y* {0 y6 P# R8 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.' @, a. l5 _3 r3 B+ f
 The interface should provide a menu so that the staff can:) [' \1 Q; ?, R5 _
a) Enter the names of the two Java program files to be compared' v! D* l& ^- B2 n
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 s) B9 z! l; e8 h! O* d( K
** 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).2 g: |3 \1 h- E$ A4 ?
BSA104 Business Programming – 2007: Assignment 2$ A; Y3 {; p$ W: w7 J4 p
Page 2 of 5
8 G# x9 @2 G. N! nb) Print out to the screen all the lines of code that are the same  K, @0 c9 H$ p" v1 e
 Include the name of the file and the line number of the code being printed for each of the two files  p/ s( f" m. o) @- |
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 a! I) j$ ]" H* A% p the name, username and department of the user
2 M( E5 ~8 g0 x: S the statistics of the comparison% I) L; O; d) a; U) G
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 x1 G1 ^6 a5 X' d, q the recommendation for further checking1 ~' e* W) C8 G8 _' T2 c. S/ O% N* G
- 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, h8 E) `# G4 M8 ]' a+ ^) @
 the names of the two files compared
7 S* y. W9 m2 X+ Od) Leave the program (exit)
) \& l4 {. S/ X9 Y1 P: \7 J, SThe ProgramCompare class: (Total maximum 20 marks available)
! x1 h7 k' U5 c% [+ U2. 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 m8 J7 r6 y+ A0 @3 d
a) provide an error message if the files are not found or there is a problem opening them* s5 c+ r) m4 I; d
b) compare each line of code
7 w/ G* w" U! j& J1 m; _! X7 t% Mc) print out the lines that are the same
& z8 }  ?/ {1 j2 X3 @. r( cd) count the number of lines compared / lines the same
8 |# w: S7 N* g3 e. H8 c4 S  V" E$ P3 _The AuthorisedUsers class: (Total maximum 20 marks available)
' ^2 @) S' x& G2 ]2 H3 y5 d, h3. 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)
! T( `+ I3 G8 U* d1 S, K4. Provide methods to:; e8 i9 P4 m7 |! S
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" X/ B' ~# U2 t
b) return the name of the authorised user
( t3 j+ F$ v( ^1 B8 lc) return the name of the department of the authorised user
2 {2 q8 `9 i. ]- C$ J% i9 {Individual Data (Maximum 20 marks available), [" j0 I) c7 ]& B
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.* W+ k& Q% Z+ k  o5 G- I3 G
Documentation (Maximum 10 marks available)
6 Y. B; z8 l, f6 g. L/ Z6 S6. 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.
. \' ^3 w6 }  ?4 l! TBSA104 Business Programming – 2007: Assignment 2
1 i: h3 @! s% O8 ^% rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# T5 g9 j# v+ O% Q! d/ q
不过你要翻JAVA的类库说明。你有下载没有?( c6 p; ]7 y& Z6 m
查询关于对比的函数。貌似关键字是contrast,还有compare
2 w& s. K# E: K* y9 u( z- h$ w% k) h: O# V. y& a
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ m4 M5 U( P$ F& r; k' i8 Z
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 k6 R( L# z& s
可以下载到的 是 jdk-1_X_0-doc# u+ z# S5 H9 K; a( e: O/ K9 Q

" T8 u) D) u( S% S3 x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-10 00:41

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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