找回密码
 注册

QQ登录

只需一步,快速开始

查看: 953|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 + j) q5 |* o1 M O2 k2 K5 M0 K g$ l, e; ]; y3 h/ r4 v/ W
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 h" B2 M4 u/ k9 D5 L: x
//  ProgramCompare.java         Provided by: DRS
: q( d) G4 k/ `//
1 x0 y6 l. l5 z3 T$ L( U8 l//  Program shell for Assignment 20 ^) t: [5 ?9 m5 N( ^
//
7 p) s7 {. }; y/ A+ C9 c% v//  Compares two text files line by line
% a$ {, {# _4 Q$ O2 ^: E! q//*********************************************************************
  m" A) O& y  V) W  Z
4 n5 e2 U1 O! X. O& }import java.io.*;3 E  n' J) _4 D  D

; ?% t& C! @- j; F, Z/ wpublic class ProgramCompare
. g2 W% i0 F, t# t{
6 D' r2 ^9 f, `+ Y        //-----------------------------------------------------------------
/ n# O# U% H5 {& F3 I3 S        // Constructor
/ e2 o) K; @1 b+ I7 T        //-----------------------------------------------------------------4 M- y5 Y9 Q' |( _
        public ProgramCompare()1 r9 Z6 ?) x, I2 i
        {
3 s7 t- `' `8 a+ H1 D        }$ d( t2 y4 Z! {: U" c( r

- S! k- e: b  Z+ l& ^" k        //-----------------------------------------------------------------
$ A, ?. {: G* O        // Method for testing that class has been reached
, e( a& m$ {0 c7 k) Z  _        //-----------------------------------------------------------------       
( R, L9 k, ]! H  R6 P. z1 M4 a/ |" O) M) X) Q8 `( P
        public boolean ProgramCompareReached()        
5 G6 A. R  G1 e! m0 l        {
" }. R: T3 f/ k7 T      try 1 ^/ Z9 Z* l# C. x2 k# b& _5 |
   {        
0 o1 r% `+ y2 D( u                       
# U2 i& G+ I/ X9 [' k0 h" D                //********************************************************************$ w- L) H& J8 T1 q. a
                // Try-Catch Statement is used to handle exceptions - such as file not found
: C+ l: I. p& x3 Y7 c- N                // Reading the files will need to be placed inside a Try-Catch - just like this one!; P6 T9 R  `- `) T+ S. Z, ~' f  S
                // For more information see page 534 of the textbook! S7 p2 j2 }* i0 ~+ d% S% A
                //********************************************************************7 B/ O$ h/ G- D
                     ! `' f  E* m1 ?4 I/ P- P
        }
, R$ l7 k" [) N$ V4 Y0 r             catch (Exception ex) // Exception caught here and message displayed to the screen
1 u4 O# u0 D$ s5 S" e* E          {
$ F3 L' l' u% d9 c+ v                    ex.printStackTrace (System.err);
( v; m; F. @$ B/ l- b# U0 q           System.out.println ("Error message goes here"); // Replace this error message with your own         
; V- ^8 Y7 u$ }# B; B        }
- i- P" \+ z) K6 f                return true;
6 O1 ^4 w& _* t, `3 @+ e$ D        }( k/ v( Y) A% a1 U/ K! Q$ J

/ x+ V5 g: H& L2 L8 T! a* g5 Y. |* Y} // end of class ProgramCompare0 ~! f) |& ?$ r) V1 _
/ O: g) b. R1 r5 k# L6 u4 q2 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************7 }& g) M5 ]- w" G' C
//  ProgramCompareMenu.java    Provided by: DRS
9 a- o) p# ?: D- z5 ~7 u- ^//9 s' g1 h/ o. k7 G. t3 h" ]
//  Calls AuthorisedUsers.java and ProgramCompare.java
, e5 K% C4 n; b9 w# w5 l, c//7 H; r  S; f* @  i, ^# M1 p
//  Driver shell for Assignment 2.- A3 q9 o5 p' Z: k8 j
//********************************************************************
1 a" v8 G) ?, l; t
/ Q5 `% _) ~2 j) H3 [- i2 Mclass ProgramCompareMenu: [6 p; e1 u8 W7 B. P9 h
{
; K1 b4 V/ K% K( b    public static void main (String[] args)
2 C, h) `9 w0 B8 N; A            {- t1 l9 q9 W4 C. K4 Y! ^# k
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable$ }5 ~8 s8 v( b% Z
                ProgramCompare reached1 = new ProgramCompare();
3 W& P% N1 ^. e% l2 T( L                AuthorisedUsers reached2 = new AuthorisedUsers();       
! s) o! t& A' G6 k1 e' z* U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, S# ?3 p1 |6 U; n3 @2 Q                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        - X0 H' ^. K. q: A1 m
        }9 w2 g0 j6 e$ D! I! l
}// end of class ProgramCompareMenu$ i" `; U/ i3 t- d# d6 w* D; ^

) ~) a( R' Z" d9 C) c# r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' b/ h% e7 |- n
//          AuthorisedUsers.java          Provided by: DRS
( ?) n1 d2 W8 ]. M, t//                7 c/ V/ g3 ^5 ?. d% r! U& N; S3 A- n
//         Program shell for Assignment 27 Q' |* a8 `! }9 F
//6 s! c) p3 A2 c# m% k% Z6 Z
//         Represents facts about an AuthorisedUser
$ W8 m- \& y4 d! G2 ]+ Q//********************************************************************, L; q" ^/ ~4 y7 H7 E) L7 t  z

+ `3 `8 z/ a. x  X# Wpublic class AuthorisedUsers+ l; _9 ^, f2 y
    {6 ~1 A$ M/ T) R3 @3 ~1 F2 h* o

: X9 @6 z6 Y( _6 F" ~5 Y! B        //-----------------------------------------------------------------3 L) P; g" c$ D" F: m
        // Constructor* x* G5 a- k% N- `7 q1 B1 L
        //-----------------------------------------------------------------
5 R& U3 J0 X5 ?% W& j' ?" X' R4 F2 J! g8 I" Z
        public AuthorisedUsers()
7 _; h5 }* x; n                {- j7 `; F0 ^' r+ m6 [
                }
$ v3 h3 g3 h: h) Q' U0 L
1 _, P7 g/ u5 H        //-----------------------------------------------------------------1 H; A; ?+ d0 J6 F& i8 d9 ~& `
        // Method for testing that class has been reached
  X* k5 f/ I  P/ Q& q' u3 H        //-----------------------------------------------------------------        9 {/ d( l" n4 \
        public boolean AuthorisedUsersReached()& o9 \: s& X  N. ]
                {$ D  E  z, c4 g0 j& [6 S9 M
                        return true;                        1 U4 Y$ s0 j* g4 K9 E5 {
                }
2 i  j# v& b" ^1 s  x5 }                ( o; C( i5 q7 q0 E. Z8 R9 k( f: X
    } // end of class AuthorisedUsers
1 j5 K, I8 S% T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming& T" `' R* \, z$ q9 R1 ^7 W
Shanghai - 2007- @0 Q7 v4 G; @1 L+ @, V: Z
Assignment 2. y, Q8 C& [0 P4 |& l/ u# w
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 ~) h+ o$ T5 L; ?5 d' F3 V: U
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.
8 {& B0 l% K# H: X1 Q; R: N  A" eThe staff must be able to:; b4 m& z5 j: X& d. O4 M/ v
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 L+ R6 ]0 p' w0 V1. 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.* F3 I/ U+ C9 t: S0 D
 The interface should provide a menu so that the staff can:
) c, K+ e# B' i' q5 Va) Enter the names of the two Java program files to be compared
: q( r" B1 E! G& Y( k$ P( x, D; I For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 I* C4 n) E2 z- b& 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).
" G3 f- |6 g* C6 H3 }BSA104 Business Programming – 2007: Assignment 2% `5 t) F& y5 |
Page 2 of 5
/ Y" M) o; @' h; Jb) Print out to the screen all the lines of code that are the same
- ~2 n( q) p9 J9 c1 r. N( Q Include the name of the file and the line number of the code being printed for each of the two files8 q. p+ i7 S; w* e2 x
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% p, G6 z: w% f8 m
 the name, username and department of the user# S( s! H- h/ ^
 the statistics of the comparison3 C; @9 r% t% O1 B
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
+ ^5 T9 g3 I( |4 {- b the recommendation for further checking% X2 t& L% a* A! A
- 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' d. E( @9 w1 c) ^, P
 the names of the two files compared( E+ u( s% I; U" z$ g
d) Leave the program (exit)
. g$ u* X% h" s# d& hThe ProgramCompare class: (Total maximum 20 marks available)
+ j; i8 ]( Z5 c) z: V& i" c; G2. 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)/ X- }' }) k3 f% M9 V
a) provide an error message if the files are not found or there is a problem opening them
$ C3 x; S$ L& }/ L: ^b) compare each line of code
4 |" i$ f# ~8 p" y. ?0 X; a6 Nc) print out the lines that are the same
& f: J! Y! n  t8 f9 B$ D+ kd) count the number of lines compared / lines the same
* q, m  p5 E' h9 l& [9 @9 W. L* m- BThe AuthorisedUsers class: (Total maximum 20 marks available)7 s$ l* \" V' F' }) p% h% g
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)* |/ J& |. ?% r) Q( }9 ]
4. Provide methods to:8 n3 P6 R/ T$ p1 ~% }' ^
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 match8 M8 p: \5 |2 ^' D0 t
b) return the name of the authorised user) M& Q8 F6 F; F7 |, m
c) return the name of the department of the authorised user) S- o+ y0 O' d1 ^
Individual Data (Maximum 20 marks available)2 r7 K% v- ?8 I. T0 }7 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.: g) u" I0 }& A, |+ z( F* d& B
Documentation (Maximum 10 marks available)
, k, `6 ]4 S- S- `- X6. 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 X3 I4 C) ~. w+ _" U0 y0 @- c" H
BSA104 Business Programming – 2007: Assignment 2
7 u/ v: |8 }# |6 I8 a" RPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 k& `% X# |& y% T/ A+ w
不过你要翻JAVA的类库说明。你有下载没有?
6 Y9 Q, e+ b9 R. F查询关于对比的函数。貌似关键字是contrast,还有compare
0 `6 f& ?2 U" J  i0 a4 F7 \
$ i; |8 z" o4 \. y9 R# |. e[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* ^* }3 h$ [" B痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。# m6 K! z9 J/ c& S& {/ v! f' I
可以下载到的 是 jdk-1_X_0-doc2 T) W# D7 H9 R  G" \" Q( D9 f0 Q

9 E- J! Y) i, h9 n' L8 Y  ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-19 11:46

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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