找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1338|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " N- F. y* o8 C) W: ] d/ e" U/ q & R: v6 Y( l( z1 t$ ?- U
回复

使用道具 举报

 楼主| 发表于 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 F4 M6 w+ I9 s: G) D' Z//  ProgramCompare.java         Provided by: DRS9 f# i3 f; Z# ]0 d  }1 |1 i
//
* u) I- R, n  T//  Program shell for Assignment 2' z: o; p4 w0 [) u
//6 o6 N' K; V$ D% G$ }  u
//  Compares two text files line by line
  t! ~$ u" X6 T/ T//*********************************************************************
, h. I& e0 K! Z# q# L9 W: n1 C! S+ U% {7 C5 p& O
import java.io.*;. H6 @5 F# p2 F5 q
) `8 {( {: G# S% R! B
public class ProgramCompare
0 V( _. \( M4 S3 T{7 n( a. v0 j9 F
        //-----------------------------------------------------------------
/ }7 g* ~) _0 X6 _# O, `8 l        // Constructor1 O7 V! o1 z* Q6 z
        //-----------------------------------------------------------------
2 t* O) A, @1 N/ x        public ProgramCompare()
# W; [. u- w% |' e/ E2 F        {
& u2 E* L6 p4 t* O/ P/ U( V- s+ x        }
1 m: V9 `1 l# B% T" K3 p- @2 ~( y( {3 m4 j
        //-----------------------------------------------------------------/ f2 ]9 D  M7 a' B
        // Method for testing that class has been reached7 x; P, B' g9 h0 f- g& B. D
        //-----------------------------------------------------------------       
8 Y  I2 ]  W8 `9 N  n2 X2 \3 R; E2 L3 N9 N( N
        public boolean ProgramCompareReached()        
, M" K4 L8 W$ }  O( U4 B9 n3 A        {: {& v3 n; {7 F: _
      try , S' C: t! |- z0 t% B8 {% @( Q
   {         / j# q% |4 W4 K5 m: n) }$ K
                       
9 `8 P2 {5 V: j: H                //********************************************************************
# r+ ~$ t- ~/ f9 E. s) C& @                // Try-Catch Statement is used to handle exceptions - such as file not found 0 p9 x0 i5 C0 B+ A+ A' Q
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
" {, ?0 y  p$ |, E: D  w                // For more information see page 534 of the textbook" x) C( N7 p6 g7 g( j
                //********************************************************************/ [/ O( }8 E2 ?9 C
                    
' C/ q- {; n* ?        }9 u- l6 C& R) c9 _/ x5 m
             catch (Exception ex) // Exception caught here and message displayed to the screen . |9 X' I7 Y) g$ `) }2 w
          {
. h7 L" [8 \& C                    ex.printStackTrace (System.err);
" ]9 Y% O# l5 G$ {9 j           System.out.println ("Error message goes here"); // Replace this error message with your own         
, S0 z9 Z! a1 j( r) ~0 c        }& k3 w" y9 s3 Z3 {
                return true;9 T3 ]: `' ?% P3 U) m7 b
        }0 W0 C2 B2 t( p; D' g
7 p3 M& |& u9 i0 u* i0 ^
} // end of class ProgramCompare( x: k* @. I6 F6 F
2 S! d! `) c0 a+ m- U# g. b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) C! w; U0 H, K5 w+ h! `# b8 n//  ProgramCompareMenu.java    Provided by: DRS
3 T( O1 H+ B' G2 N9 Q) W//% S" x' N) X/ J# j% b
//  Calls AuthorisedUsers.java and ProgramCompare.java0 d8 O$ h6 s* I5 }
//9 U8 |! ^7 V' ]4 e- S
//  Driver shell for Assignment 2.
. v* z- Q% k! t//********************************************************************4 j$ v3 ~' u5 n# s
+ e8 m) \' n$ @
class ProgramCompareMenu
0 h" y8 _! d0 o. e% _# B{) w; ]; W5 [7 N& ~! L* }
    public static void main (String[] args)
: ?8 \2 ~( w* P% f# J1 J& J$ \3 q            {1 y3 P- K8 W4 Y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! i: \3 _* t/ P, V2 q# Y' c                ProgramCompare reached1 = new ProgramCompare();
# N" H5 y) l2 L5 N$ r4 R/ F                AuthorisedUsers reached2 = new AuthorisedUsers();        0 a, D# S* m" r6 i' h
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" A1 N/ y$ J( X; z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ j$ Y# W( D0 d' d* y
        }% ?* n! e2 d* j1 J4 r
}// end of class ProgramCompareMenu
0 r$ t1 T; j8 H
8 c$ B. N" ?- E( Q# q  U4 p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
+ Y/ |# V7 W& H7 n+ W( f//          AuthorisedUsers.java          Provided by: DRS$ N9 X* B, W0 c4 ^  \4 w% ^  a
//                8 K. ^* L! e5 I0 J0 o" _
//         Program shell for Assignment 2$ B# Z, u. K% s- `
/// e$ @- z3 m' f, K
//         Represents facts about an AuthorisedUser$ P8 z5 M0 E* W
//********************************************************************
/ F; G1 x+ Y, q( p" Q9 g2 R; l* y- k8 X2 K. ]( s
public class AuthorisedUsers
9 L: g8 I" K! e% e. X    {
( X5 e" D6 r  }6 |* X+ W, H" H0 g0 Z- h! x
        //-----------------------------------------------------------------
" Q" Q0 E* S- `* G$ K        // Constructor+ Q0 e% ]+ |0 U% j: H, U: c& V
        //-----------------------------------------------------------------3 a: S5 B) i% y# Q& V( l
* g% a) t9 i/ n; p
        public AuthorisedUsers()9 M( b+ q6 F( f9 P/ V
                {: T- i* T5 V& J0 ]2 A% F
                }& |* f: d9 Z# i$ [# \% h
& R0 b$ N- s7 S8 T( L
        //-----------------------------------------------------------------
8 p  t1 I5 f) Q5 U0 U% M        // Method for testing that class has been reached3 D3 ^& _5 |. m& v* D9 h
        //-----------------------------------------------------------------        $ {$ q( G# Y9 s: N2 K( |
        public boolean AuthorisedUsersReached()
6 S$ e3 ~: y/ G) S# \( e' V                {
9 Y, R2 q4 L2 x; ~9 p                        return true;                        ! {9 o8 E# ?! w! D
                }* G+ ~8 G& l1 O
               
) ~! F) ]# E: h/ a    } // end of class AuthorisedUsers4 }6 N9 [6 j9 K$ n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 ?$ o/ W4 Q! m- {8 w% `$ kShanghai - 2007
8 V, }5 r6 M9 s# t% @  ^Assignment 2
9 q+ m) F; d9 Q! aDeadline 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)
. X  w; P0 H/ ]2 k6 a# L4 S) ~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.+ X% t* \' E+ m2 E6 h( j( X
The staff must be able to:* T4 G% }- N8 N; t
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 o! K0 N* X6 ^9 S
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.4 X. |2 v5 y, l) G& T! Q3 _
 The interface should provide a menu so that the staff can:
$ j, k0 l- M$ p. V# t5 x" Za) Enter the names of the two Java program files to be compared4 J0 g$ {8 c; O7 E+ N
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 o% Q/ ?2 u! `7 m  i** 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).
: D  H) `0 q$ E% C+ eBSA104 Business Programming – 2007: Assignment 2( _" S7 d- i& y, c
Page 2 of 5
5 m5 D1 D9 y$ ?; R7 q2 j# ~( C% Xb) Print out to the screen all the lines of code that are the same
! U# z% p! E3 {% a Include the name of the file and the line number of the code being printed for each of the two files! d/ T  J( Q2 l+ U
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) p/ {4 `2 @( |# t
 the name, username and department of the user
0 ~# x+ N: b# M8 a4 p the statistics of the comparison
; C' }! A! N$ U- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different3 Z* \4 r. {$ E# M, y  X1 p, x  @( u+ L  m
 the recommendation for further checking) h7 _1 R. c1 @' r( ~! r, P
- 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" j9 U1 u+ U5 u" L
 the names of the two files compared
* P( u, Y( f7 L3 td) Leave the program (exit)
1 h. B6 W& w+ K  @  S) {' hThe ProgramCompare class: (Total maximum 20 marks available)
& I1 W4 j9 u! A3 J3 h4 Q$ b1 S2. 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)$ c# t* u6 @* q4 ?' U( e! }) D
a) provide an error message if the files are not found or there is a problem opening them1 j' o8 Z1 ?! u
b) compare each line of code8 Q8 D* y! C  ^/ a! G" K6 J
c) print out the lines that are the same0 \0 e- u. `4 m, {
d) count the number of lines compared / lines the same8 Z- ?) J. e/ d9 Y
The AuthorisedUsers class: (Total maximum 20 marks available)
: t5 [( G2 H8 B* W8 e2 w/ [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)1 A) k4 I- s/ @2 d/ a* l1 g
4. Provide methods to:# M; P1 H( k; i& o
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& e4 s& d/ r4 P" c) ^% K' X  R
b) return the name of the authorised user+ I6 R  g7 P% ]* `( S3 L: t
c) return the name of the department of the authorised user
6 d3 g7 H( O7 i( }. Q9 cIndividual Data (Maximum 20 marks available)+ s- b7 J  b% l# G' `. e! R" S9 t) K
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.* z( H( e9 N, V7 L* m
Documentation (Maximum 10 marks available)
' X# L/ [& b6 ?/ L2 X2 I6. 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' q( r& v- f3 U* s7 g( ~BSA104 Business Programming – 2007: Assignment 2
2 D% F% [( b! V/ P/ ?; j: _: YPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
3 ]" p  _8 W5 s: n3 A2 r/ c不过你要翻JAVA的类库说明。你有下载没有?
9 P$ V' ~# F0 P' T8 Q查询关于对比的函数。貌似关键字是contrast,还有compare7 K- z" ^/ `$ f- b$ V% V* n

9 I7 }# C& @& w  L6 j" n# d[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
. n3 \! `9 o' |. l4 r3 s$ v$ f痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
2 _* s9 z7 K0 N5 d可以下载到的 是 jdk-1_X_0-doc; e, q8 `- p8 w% O% {+ I, @! _+ Y
6 ]4 }& D1 o6 r0 K+ W/ z. i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-2 00:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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