找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1734|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 `* e! s* r5 [, B / R" x l6 g h1 Z0 c/ R( | M
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
$ T6 }! ]; ]7 I0 n# ?//  ProgramCompare.java         Provided by: DRS
! K. |1 B% O3 @3 t2 |( c1 c' Z8 f% i//7 L8 j& F6 ]3 Q5 g% t
//  Program shell for Assignment 2) h- o' Y4 ]8 ?& N/ i# _& d
//! u) d3 `5 k1 f9 V. ^% s! Q$ R
//  Compares two text files line by line
4 |1 E* v# {! t/ X$ w5 r//*********************************************************************
$ C( i2 L- ~) G# v' t' `3 ]% ?& ~& n
import java.io.*;4 E5 q1 v3 X9 |7 L8 W
8 I2 ~: I) q) f) o4 X# [3 @
public class ProgramCompare
) r) \8 l9 h* u( s) J4 T{/ Q4 |1 d4 f; I5 Q
        //-----------------------------------------------------------------
5 y, a& \- _% J; w9 }        // Constructor: ?# Q9 I4 q) f, J5 A! r
        //-----------------------------------------------------------------; C2 M9 O& Q: A" C$ S( o
        public ProgramCompare()
+ M* |' k  {+ x" @: r* n; E& ?7 J        {
' z9 q9 q) B$ ^        }# C5 l  s2 m( m( c9 H. F
6 E% T4 }! T9 r! @
        //-----------------------------------------------------------------5 l; X  D7 h. R$ b* K
        // Method for testing that class has been reached5 u4 E" d" r& f# Q( W8 N
        //-----------------------------------------------------------------        9 e1 s7 i, j% P% d! [
" j* v$ H! u: q/ X/ o
        public boolean ProgramCompareReached()        
" n( Y# D  m0 P" i) v0 ?* X        {
* \3 B( J. M) D- J1 a9 [      try 5 @4 d" S7 \) }5 s3 A
   {        
, J; t9 e# v& z. w# t# l$ X! U                       
- T* Y. A$ Q0 ?* z" n" F/ z                //********************************************************************7 y4 Y% O2 N) R( i5 r# z
                // Try-Catch Statement is used to handle exceptions - such as file not found 2 x. V# k3 y. g
                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 I6 k/ r* J: x8 Q
                // For more information see page 534 of the textbook
/ d6 H' Y' ]0 A  ~1 i                //********************************************************************( Y& a7 b( }' ~2 Y2 i* ]' ~0 l
                     # v0 Y0 f* ?( _* O* r+ l6 v
        }
. `6 }  W8 U% R             catch (Exception ex) // Exception caught here and message displayed to the screen
2 H& k  D+ t- ?7 G! O9 F% x          {
+ J) ]% P% T2 j' O8 N; G2 ]                    ex.printStackTrace (System.err);
) F% M1 }- R! N' o0 t           System.out.println ("Error message goes here"); // Replace this error message with your own          ; ^3 ^5 }0 O& {0 V/ |: R& r4 e
        }0 [$ L* G4 p- i1 I3 O: t% T
                return true;
! }. k, F. T" P/ A9 t        }
  H) ?9 J. u8 R! n3 y
! M7 J/ t; U- k& O/ O' X7 F} // end of class ProgramCompare
# s5 X) @+ U* A0 X" _; \& W, S8 W+ ^3 R7 ^1 N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 }9 _& c- M/ m- D. N& u//  ProgramCompareMenu.java    Provided by: DRS) A- p5 {# I7 O
//
7 }0 o9 S( r( K" h; f//  Calls AuthorisedUsers.java and ProgramCompare.java3 Q6 k. s- W' k
//
3 H  [% E; _9 Q, g! N. p//  Driver shell for Assignment 2.* {0 H; h) w0 ~4 W  F
//********************************************************************
8 z; I1 ^. B2 [; u) J/ x7 P) z0 U/ e6 N3 |
class ProgramCompareMenu
+ p( |6 V) f0 |" I{# ]8 x2 B: @8 P+ J( N" r& ]( C; M: @
    public static void main (String[] args)1 z# w' `) X# v
            {3 N* Z9 ]! m# @8 ^+ V
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
  i9 |, E5 [* m* i% j/ h0 V                ProgramCompare reached1 = new ProgramCompare();
2 c# {( z% w; ^( ~                AuthorisedUsers reached2 = new AuthorisedUsers();        : X/ L; ~' O  \, I% |2 F* o  `  Z0 ~
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 _! Z+ z0 G4 v1 t" L/ ?# x& h3 M
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 n% U" Z# @4 y* G2 D6 t        }/ _% B6 B. ^& {+ \. i) U
}// end of class ProgramCompareMenu
, q& l2 P& Y9 I4 g# P, U
8 |9 M% n! h* d+ P# Z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
8 c& a$ q2 u- ]7 l  [% g9 w//          AuthorisedUsers.java          Provided by: DRS
: M1 s, n5 k7 @//                ; g4 {2 s! {' k0 \' C% }  ?
//         Program shell for Assignment 2/ H% f3 N; X. u& m4 w5 f
//
) b$ D: P& U7 g3 |//         Represents facts about an AuthorisedUser% P' ]0 W) c3 S4 D4 }, B! ?
//********************************************************************5 X4 y- q$ t9 ^6 H: v3 U. G: q# P

: X. w# D3 u( P4 Qpublic class AuthorisedUsers
0 Q0 w" a  x6 a# |7 y    {: a( H4 R' j/ ~; h

" f$ o& R, L2 J        //-----------------------------------------------------------------4 S/ \1 G* k6 d' c* q6 A. g
        // Constructor
$ a0 M4 p  z1 |        //-----------------------------------------------------------------  h3 F( \$ D0 ?1 `

3 |- z( K6 V2 N; B. S& \" G        public AuthorisedUsers()1 r& C* x3 f* n6 g" q$ ~
                {
3 T* B1 G+ E4 j7 @% Q                }# U8 r0 e5 Y/ ^4 U- A+ C/ A. t( G
& p3 y# j8 V; ?$ E" m
        //-----------------------------------------------------------------1 g# I! T* d4 t9 {) J& E( j# G9 ~1 S/ j/ @
        // Method for testing that class has been reached
# H' F, O( e/ F" w7 i* `- `        //-----------------------------------------------------------------        : p# R5 R" b7 j1 O
        public boolean AuthorisedUsersReached()  q1 I/ R" q5 w3 W# R
                {
+ [7 y1 ~" K( L/ o6 ^                        return true;                        0 ]* i' r' D! h& F  C, [" f1 X
                }/ r; M2 R1 b: h, U9 t  a
               
6 y8 i% }/ i3 Y: Y9 l3 G    } // end of class AuthorisedUsers% Q: w4 w+ ^/ [1 C* E) N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# {% s7 j  ~1 T4 [2 eShanghai - 2007! V% {  W. m; V
Assignment 24 m2 N3 g2 C9 e4 e& X4 ^, a; Y
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)
. ^5 ~! ]7 k. D$ O4 w9 j1. 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.
0 y* {/ k& W% y* OThe staff must be able to:0 Q. W! ~! L+ j8 k
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.( P  N! x: ?/ g  k8 [
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.
' l6 w- |& U$ i6 K The interface should provide a menu so that the staff can:
* _) W2 S7 e/ [7 `a) Enter the names of the two Java program files to be compared8 t$ b7 |, J8 ?3 m3 D0 G
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
  s1 K7 c& e- D4 K$ x6 L** 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).! B/ b, a9 E- r2 z5 {4 k$ [
BSA104 Business Programming – 2007: Assignment 20 D4 Q* o6 c% Q1 N
Page 2 of 5& w: Q; B& j( W, `5 D" c1 J
b) Print out to the screen all the lines of code that are the same
/ r. s: ]8 F/ o  q- b( E Include the name of the file and the line number of the code being printed for each of the two files8 Q# f5 C' ?6 q- L& x3 b% ]- g
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- K1 q3 o  f6 B* a9 X the name, username and department of the user
9 U0 v' d6 {% G% c1 \; `! N- j* i the statistics of the comparison" Q; ~% j! s8 E6 W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, r9 j& `' \: k% ?  `2 l, v7 N0 {4 Y
 the recommendation for further checking& T* n; t/ x7 t# i+ l
- 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! e6 |3 I  s" U' m' f0 g
 the names of the two files compared
9 l! z1 g; F8 {d) Leave the program (exit)0 o. F/ j8 [6 E; J- W' X, X
The ProgramCompare class: (Total maximum 20 marks available)
" U/ Q" `+ s5 x0 e2. 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)
6 Y) d5 O0 ~5 e3 X' ]; Q: [4 @a) provide an error message if the files are not found or there is a problem opening them7 c) m7 x8 r5 }- j
b) compare each line of code- |5 m% c' X% {1 u6 d8 p
c) print out the lines that are the same- Y4 k( j- H3 v3 m' r& {7 I2 T
d) count the number of lines compared / lines the same
3 h9 B! w/ k5 v1 \; U" hThe AuthorisedUsers class: (Total maximum 20 marks available), I0 x! J: O$ j1 _- H5 x1 J9 e
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)
5 S9 c1 ]" b, S! `! U5 Z4. Provide methods to:
$ A8 \+ t# Z) D. y3 P( ra) 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: O0 a& C# y/ a, V9 r
b) return the name of the authorised user( [! x, v5 i% c6 \- N4 T  w
c) return the name of the department of the authorised user
' d# W. A; w( HIndividual Data (Maximum 20 marks available)+ c# H7 x7 ^, 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.; i9 d! U& }/ H$ l
Documentation (Maximum 10 marks available), Q% N0 W& \$ g5 n
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.
* V# c1 R2 V- S( c2 U6 uBSA104 Business Programming – 2007: Assignment 2; c% X* u. P# G: f) Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: Z6 h/ k& w; ~7 \
不过你要翻JAVA的类库说明。你有下载没有?
" c) `* z0 C% k' e; N查询关于对比的函数。貌似关键字是contrast,还有compare/ o% G. y0 e1 t" J3 l, Z
+ t3 C* F8 s6 y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* o( ^! n- g% C7 E8 h. a7 L& l3 ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 _/ y, ^$ v' P( u' |4 ?可以下载到的 是 jdk-1_X_0-doc$ @, b9 y. N; D# h
% }. r1 q8 u, {' f- O( `
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-19 10:13

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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