找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1341|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 @0 \: {9 v6 L' z4 H , Y0 E; @: y2 N. ?* ^# z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( Q% N& F/ ^$ \$ [//  ProgramCompare.java         Provided by: DRS/ R* T8 b0 m1 L) m
//
8 l1 y8 I" v7 o' O- J/ `//  Program shell for Assignment 2
- q9 W7 P) m1 p. {. K7 H. i//
" k$ a% {7 @/ o//  Compares two text files line by line
5 f5 i1 f' |' |+ t: s: C//*********************************************************************
' Z- o8 P: R% ~% }! b& Q" D
, W; x* F. k- B; k. H" b4 Ximport java.io.*;
  L, ?/ Z) ?" u. T' p& [7 I- B, p3 L# x+ E/ B
public class ProgramCompare
3 D6 X. V  [4 T7 }, f7 p{
* w* i( b! |0 C! b' N  z        //-----------------------------------------------------------------
: x& x8 F' D3 ~/ @$ n        // Constructor* V5 A! u2 @2 M0 y, t+ g; _
        //-----------------------------------------------------------------: m3 T0 e2 _2 o  p8 U$ Q
        public ProgramCompare()
/ M. q' b4 x* T( C/ M        {) f  a& J. V2 n" e
        }
% w! \7 {" ]( ~2 _' l* V6 z1 f+ E$ f# Y9 i0 w1 R0 S' ?
        //-----------------------------------------------------------------
3 Z0 V$ D8 B/ Z        // Method for testing that class has been reached+ A* ]4 R* [8 R: F
        //-----------------------------------------------------------------       
: S- ]: ~+ J. I" F! \: h
* J$ M, `1 ^4 E5 c        public boolean ProgramCompareReached()        
/ I# q% e1 g7 _; l# J; C/ f0 R! _        {
( X: t+ x6 e/ T8 k" x      try
( C- Y0 d2 q% g" h6 a   {        
& H, ~! O5 ]  L% n                        + g8 z) E5 H% Z+ v
                //********************************************************************
3 Q  a# b2 T- t, v" d, }                // Try-Catch Statement is used to handle exceptions - such as file not found
: U0 }: `: |% \) }. W                // Reading the files will need to be placed inside a Try-Catch - just like this one!( T* V8 p8 @1 ?  ?9 s5 n
                // For more information see page 534 of the textbook1 J$ C$ _; `7 v0 S  Q
                //********************************************************************+ e" B8 z/ H$ b. {& D+ b1 q( |
                    
: k9 M3 q( S0 p' B  r5 j        }' s9 Z# N" }5 p" e& ?, o# u0 e! ]0 K
             catch (Exception ex) // Exception caught here and message displayed to the screen
, X( p  l% D1 p          {
& \. e* n& h- _& Q7 d, n6 n2 ?                    ex.printStackTrace (System.err);! j0 F- d& d  e0 `4 |/ N( q' T9 b
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- N0 l/ x# F  c+ i( a" Y- E        }
1 Z) h4 \+ t8 E! T7 O" w; n                return true;) T; ~$ D) d4 ^3 C, b% j/ a, I$ G, S1 Q
        }( a9 x0 o' _/ f

3 I2 ?3 a- r8 b% ^1 B2 @+ r9 `- f} // end of class ProgramCompare* T& y0 V3 s* M/ [
) q* C  V- E5 |+ ~+ O2 B- ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************* r0 v9 N2 v9 ~7 s  l# _' J# i
//  ProgramCompareMenu.java    Provided by: DRS! w" ]4 i; `1 M0 ^+ O
//: g& }1 H8 S9 X1 @2 @) a. H, d
//  Calls AuthorisedUsers.java and ProgramCompare.java$ f( t' r: S* Z0 y; o$ c0 s' r- n
//
  G; t* x; t' g( {% [//  Driver shell for Assignment 2., V1 [: z0 H9 ~& i. s7 H
//********************************************************************
/ L6 P, ^3 P" }" J& h$ k0 ^4 F+ d
$ ], T7 _/ h6 o1 s- wclass ProgramCompareMenu" E, f6 g8 }- Q/ K, |% O
{
8 _& O! I& W- g2 v    public static void main (String[] args)
4 ?: e0 B- G  Q3 Q2 K            {! X  O- k+ V1 V  e3 B& M
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 y4 R3 }5 O2 N* r  [9 M) a
                ProgramCompare reached1 = new ProgramCompare();
1 T4 A1 w3 b" M                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 J7 e/ G& V0 y0 T4 u8 ]                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# U  X( M. U0 v  }+ U/ j/ S* D
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. m* P; m1 _1 {* h/ r4 i! f- k        }
- q" ^3 u+ H/ L. {4 H6 p}// end of class ProgramCompareMenu
, r$ R9 K, t* [. X2 j; S, P# p9 t+ f& V  `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 a! I% H( c; i1 Y2 O; x" A
//          AuthorisedUsers.java          Provided by: DRS* s5 V9 M: S* Q- b) z! P
//               
! z: d2 X5 F5 _( N7 `//         Program shell for Assignment 2
) k, G$ m+ y) `//
% p) z4 V3 X5 y* e* I3 Y//         Represents facts about an AuthorisedUser
: p6 n( Z( h( t, w' p//********************************************************************6 p& s4 `  W# }
" ~* A6 Z$ D7 W/ @" W. V8 a
public class AuthorisedUsers' F) }  L1 {# }4 q- I8 O; p, _/ w
    {9 \. e  a: A) \, D: N9 f  a

/ M+ k- _' I! d2 N+ I        //-----------------------------------------------------------------
7 p4 }1 L; a4 S3 U% j        // Constructor
7 e$ N& K% E$ p/ o' p- f0 }        //-----------------------------------------------------------------
( d2 r* c' f4 @3 h1 f  z; U. g" |( {: U3 G+ q8 u
        public AuthorisedUsers()
+ d* ]* Y: O+ X5 g                {
( n, N+ W3 s5 f0 h; J! U                }
& W: v- D' v' }8 o9 p! }. n5 |4 o
        //-----------------------------------------------------------------
% }' m  D6 Q: P# j2 n. P        // Method for testing that class has been reached
' }4 n, C0 K, i3 t" X        //-----------------------------------------------------------------       
; F  L; a! E. h- n; o& k. V9 x        public boolean AuthorisedUsersReached()' o7 Y* b$ ?7 P8 I# V+ I+ x) v1 W" D
                {
. e, T* `$ b/ Y- k3 `  {( y, S                        return true;                        9 a; A; \* u6 }6 r9 c7 @
                }
5 ]+ a1 _/ x& k/ j* U: b# j                ) A3 t- H" }+ ~4 s. r2 Y# T' f
    } // end of class AuthorisedUsers! _$ d" l+ j7 x& v, P# ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 I; ?5 l; Z$ y1 O; xShanghai - 2007
6 N$ g: |2 V; i) u" d! u  t/ \Assignment 2
0 V. i, \+ i1 I0 ]8 b- vDeadline 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)2 z7 o1 P0 G6 N% y
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.6 n; t' q% ^. q
The staff must be able to:5 Q5 i( A: c3 I  M5 B
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
$ o: j  j2 r- k$ T. D( S1. 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.: U1 k" R. Y1 ~3 y& e- U
 The interface should provide a menu so that the staff can:" l) _  O  f! q6 [9 X
a) Enter the names of the two Java program files to be compared# ?4 L% z1 \. o7 Z
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- b; L1 \3 ~1 D, u1 A  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).
$ h+ [1 K* B5 ^BSA104 Business Programming – 2007: Assignment 2
% u( I6 _* u6 JPage 2 of 5/ k* K* E& m; a9 z
b) Print out to the screen all the lines of code that are the same
4 x. y" `4 {1 B2 g Include the name of the file and the line number of the code being printed for each of the two files
/ H! A% N' g. K7 s/ t* [c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 L$ i) i( r, R6 w! n
 the name, username and department of the user  ^5 ^* @# y' t, m0 h" B1 y
 the statistics of the comparison, d* h' W) O8 G# L% G
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
; l. T3 w4 F6 o; r. ?7 n) d. d1 S the recommendation for further checking
; ~- @3 a5 k, ?) l% S- 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
4 B  {* k1 i) a4 c! g the names of the two files compared
2 J; ?" H! M! _  |% [/ ^- x, ~8 Td) Leave the program (exit)7 @, x4 N9 U% J( W  S' P
The ProgramCompare class: (Total maximum 20 marks available)2 b! G. r3 I" ~. Q0 U' i9 u
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)
4 j2 |2 G; L8 J6 r& C& D' g* wa) provide an error message if the files are not found or there is a problem opening them
' k0 W$ b& @0 u1 _( s. E& rb) compare each line of code
8 p6 `+ [$ K- M- V- e/ [  L) z. Hc) print out the lines that are the same# [8 x# b5 |+ m+ Z9 z# T
d) count the number of lines compared / lines the same. M5 l: p. {4 ^$ A
The AuthorisedUsers class: (Total maximum 20 marks available)) U$ ^) k7 A6 F
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)
3 g: q5 I. p" K4. Provide methods to:* `, q5 T3 E, L
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
, N; y2 a$ p: u$ zb) return the name of the authorised user
1 V: W% r1 X9 wc) return the name of the department of the authorised user
3 o$ \4 E' n( G0 y' `& s8 ~3 \Individual Data (Maximum 20 marks available): r0 E; d  N+ }& ^. c2 t
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.
2 ~& g2 P8 o' g3 q0 Q, l" j5 BDocumentation (Maximum 10 marks available)8 T4 \. o) T" R) @3 z4 C
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.
3 [& C! b& C% G9 F) ?; V9 w4 S. \BSA104 Business Programming – 2007: Assignment 2
8 G! n' u. _. H: B3 w- \Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
9 m- L) ]$ c6 X. s, ~不过你要翻JAVA的类库说明。你有下载没有?2 w+ _2 L1 M& A( d- k( g1 t+ g/ @
查询关于对比的函数。貌似关键字是contrast,还有compare( M+ D0 M1 g5 U- E& W
  ]7 a9 M. o3 ?2 G$ I
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -! Z2 W. }$ M! v, X/ ^5 I
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
1 D! y, }, S" T可以下载到的 是 jdk-1_X_0-doc
0 z8 s8 H! Z) i& a- [& x6 @! h; Q2 v/ D: W+ j
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-2 23:35

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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