找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1234|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - @/ }) D5 X9 K- R+ S$ t& ^ k9 X, q+ G2 a7 H% W+ L
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 t& P9 z2 l" q! s5 B
//  ProgramCompare.java         Provided by: DRS4 r) \8 P6 \9 @$ {+ v' a
//
# h  x! S2 P! d" A- D; P+ `8 b' K//  Program shell for Assignment 2- A( c# Y& Y& @4 L! h6 r- K3 _
//& o+ f! Q) N7 \4 |/ Z! P
//  Compares two text files line by line8 T2 y5 h. ^6 M! ~& g
//*********************************************************************$ W7 [0 U/ N7 [8 v6 [! |- W

- \5 w2 o" A5 gimport java.io.*;
- Q* h0 _8 L6 k' o4 k0 s) [* z3 x3 ~
public class ProgramCompare
- }8 X' y: c7 @7 t6 e" H5 S{
5 p! f9 Q; Q: K# o* L2 ^        //-----------------------------------------------------------------1 I5 S* Q$ i  [% l. W: V" |
        // Constructor: t) B- K, S( H
        //-----------------------------------------------------------------
) B) a8 w/ p; U& U0 s7 h        public ProgramCompare()
% }4 d/ |0 o- H8 F1 i; Y! w6 c        {' C# k9 K' d8 e
        }
7 ~' I/ o! h- k
; f( T  o: U1 }. D1 {2 P        //-----------------------------------------------------------------( S, K7 a& u) Z9 o2 o4 _
        // Method for testing that class has been reached- A# z$ b$ d% V
        //-----------------------------------------------------------------       
2 I3 `  A9 H, `4 ?8 G& H$ w: [
        public boolean ProgramCompareReached()        
' a1 R5 M8 x4 H) t/ X9 D# t1 t$ U        {
6 c! `" E& v6 \3 P7 o& W$ ^2 w      try
6 ?% r9 n6 n8 X! u, h* G   {        
% @" A) |4 h$ A( S) y) ^; [                        $ T6 _& ^2 j, F: ^
                //********************************************************************7 x4 l. x3 }3 P" @+ j# }
                // Try-Catch Statement is used to handle exceptions - such as file not found
/ y% l4 Y. E  C; U                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 O- N6 r- P/ ~' M: t8 E" [
                // For more information see page 534 of the textbook
& ^7 w4 x$ W, _* u+ T                //********************************************************************, B/ g- K8 t, O& H; @- X% n' H
                    
7 R) y. b0 B* y  [+ a6 q) Z        }
! C+ Z  r' L' K8 N6 ~             catch (Exception ex) // Exception caught here and message displayed to the screen 9 M5 L7 z# G1 w, Z9 D1 T
          {
+ p, c) O# {) g8 Z5 N6 R( D& P                    ex.printStackTrace (System.err);
/ f5 C" C3 M2 n. r7 l, Y           System.out.println ("Error message goes here"); // Replace this error message with your own          * U+ f. d* q; e, j+ t' k4 C
        }/ {+ l' C# T, f& d5 D* K8 R: k
                return true;
3 v' Q! V  [4 ]3 W5 U( J2 Y        }
' y) T: P6 N* [4 m* [6 y6 c4 i4 R% U5 U* ^2 r) M% E
} // end of class ProgramCompare
5 u# e' X# z! [7 e1 X
/ o$ ~5 L! {# K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 E) n4 U3 |8 b; f  X//  ProgramCompareMenu.java    Provided by: DRS
4 W$ K. w* ]; X9 [% r- }//$ R* Q& K; m+ U) L
//  Calls AuthorisedUsers.java and ProgramCompare.java0 J* h0 M  i0 N+ T
//! P0 |0 R3 f% ^3 ?% Q
//  Driver shell for Assignment 2.6 a( L& q4 G# U# g
//********************************************************************- h$ F% r0 T3 J8 W- g9 f/ X
* _" o+ i! I2 N4 P) L
class ProgramCompareMenu
. d! U( E5 Y6 |7 T{
" l6 ]/ n/ H/ [! G: S4 v; }: T    public static void main (String[] args)
7 Z) {. R. F# V6 q- @' a- S) Z            {; @  P0 y1 y4 ?8 N$ ^2 Z) f
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable$ S" L# s+ f7 z/ ~
                ProgramCompare reached1 = new ProgramCompare(); # X1 p: W  c5 M  L( p! ]
                AuthorisedUsers reached2 = new AuthorisedUsers();        8 a0 T4 t! g: ]5 Q6 Q# ?; B1 f
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());) L9 q. X+ G: c
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
+ n+ m2 n: G7 S% W        }
/ k7 Y. K: N* J% ?; O7 {}// end of class ProgramCompareMenu5 N$ F1 d* n$ @0 j5 U
* @' x7 Q1 U. T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
( v: W. z2 z7 |1 P$ ^1 F//          AuthorisedUsers.java          Provided by: DRS
- M- X- Y1 B$ \/ L//               
# T% s# c9 {- E& V+ U, J//         Program shell for Assignment 2
& B9 n: ?. [2 s* Y//7 Q1 ]# X$ I3 ?3 I
//         Represents facts about an AuthorisedUser- y$ F9 r" E/ i- @7 }9 k
//********************************************************************/ H* ^5 p7 b% p- R4 [$ J& X* \
- f6 C: D' U% T1 k7 b4 i
public class AuthorisedUsers5 |/ f+ ]0 _1 F; ]5 P* I- g
    {
& y7 n; B, l1 n, `- ]
$ W$ `+ o. Y( q' `3 ?5 d        //-----------------------------------------------------------------
) T9 D& N  o1 ?' @        // Constructor8 F* b6 Y0 q) e& D1 |- z
        //-----------------------------------------------------------------( o! o( R7 h, t- F- O- [

9 Q6 O0 P1 g8 i/ P/ @5 R9 z( j        public AuthorisedUsers()
1 b5 J& q- b( O                {
/ Y: g' q9 l; @5 @1 s) e                }/ R; Z! b. m  g# b0 [

3 K: o# m( {7 d* z. I) D! ~9 X4 O        //-----------------------------------------------------------------
2 l8 B9 m" g+ M: h9 A$ C! v  L1 F        // Method for testing that class has been reached
7 `% f9 X3 ]6 b7 Z        //-----------------------------------------------------------------       
$ i$ N5 {/ H) R% r! d& }  c        public boolean AuthorisedUsersReached()
, D' _# _: [3 w- I2 {                {  J) t% n/ A% C
                        return true;                        # V$ ?# ~, X# T; C  h0 w
                }
( S1 I5 ]5 [$ w4 d8 f1 p) R1 r                7 Y/ _* B; k2 o4 j' C: K
    } // end of class AuthorisedUsers
# G4 p8 Y* m0 V+ v% P% `4 m& ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 X/ U3 ~7 g0 P  I% zShanghai - 20070 X) C1 K- @9 z+ \, F3 E
Assignment 2
& M# c3 V& a9 W; `. b6 K6 nDeadline 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)' u$ z5 W: q' {4 r
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 v% t% C2 [0 S9 l
The staff must be able to:% h! ?1 b8 ~) m) T: h! j
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# y: A- @* K! [, q% W, M) K1. 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.
% D% ]% E* x2 j. [# B% {2 r& v: B The interface should provide a menu so that the staff can:1 k5 ]- v4 ~* c5 g" ^3 y
a) Enter the names of the two Java program files to be compared
  n- P: M0 A/ U3 g For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
* b9 ?$ _* j3 {0 C. u: x7 G) s** 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).
1 `. D: x9 b. kBSA104 Business Programming – 2007: Assignment 23 S9 J$ W4 u% v! u2 C" ^% s( g
Page 2 of 58 c! ^+ R4 ^1 c* ]* A
b) Print out to the screen all the lines of code that are the same6 s4 l; S7 W! m( |! x  D4 T/ w
 Include the name of the file and the line number of the code being printed for each of the two files8 z) Z, ~0 a7 D. r  Y% T
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 I  y" e+ N$ d+ `6 n the name, username and department of the user; d1 H, ~0 u0 r" D; `. `. t
 the statistics of the comparison# }% {$ Z  `" W$ H8 O
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" g1 ~! O8 g% w2 f9 V+ @' D- u
 the recommendation for further checking5 t3 w9 k5 }. Z( F1 h$ P4 t# r
- 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
$ j* u5 ?4 ^; C8 R2 a7 U the names of the two files compared
, f  B1 B+ P6 o+ Bd) Leave the program (exit)) n, f6 T- m6 a& l, ^( f
The ProgramCompare class: (Total maximum 20 marks available)( T6 h7 u7 F& n& U# N
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+ v# [' x8 I6 H7 Wa) provide an error message if the files are not found or there is a problem opening them2 [# o1 i8 t. Y' M0 D0 u# m( W' f
b) compare each line of code
. i5 J& E- X. s3 t1 y- L. hc) print out the lines that are the same
( g; o; F, G0 t, {d) count the number of lines compared / lines the same
/ z' e$ K! ^+ u1 @! @, Y9 p  @The AuthorisedUsers class: (Total maximum 20 marks available)
  i3 {. W$ o; b$ U  X+ b3. 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)6 R: Z$ J6 ]" B. U, `
4. Provide methods to:5 t1 M6 n5 U3 Y  k3 H
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
( E, p( k& [& t, H3 t4 y# n6 Cb) return the name of the authorised user
4 t- ^) F  C8 e# U$ u7 ]5 d& Hc) return the name of the department of the authorised user
5 M! P! F  b4 v6 G: Q+ hIndividual Data (Maximum 20 marks available)& a/ J3 Q  H" }
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.
) z0 x  X  Z! EDocumentation (Maximum 10 marks available)
3 t/ N, f, F( ~# I  z( z6. 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.( n& b, C" w. t6 l- [6 }5 f2 A
BSA104 Business Programming – 2007: Assignment 2) W2 E: `$ w" d" z/ I/ Z
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
# {% U3 g) _- r- Q; k: M不过你要翻JAVA的类库说明。你有下载没有?
0 n/ S0 j* _4 a查询关于对比的函数。貌似关键字是contrast,还有compare/ c7 u: m( P  e0 I' s1 p. E

0 {: d  H! Z3 s5 @2 i- }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
" G5 y1 z& X3 q" U( Y$ n' {痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。* M4 G. Z. R1 l  _2 `) d" w
可以下载到的 是 jdk-1_X_0-doc
7 @- N9 s$ m7 e3 r1 y
) X4 i6 `% w  a& U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-26 21:06

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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