找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1072|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 d3 ?$ L) [ }% g2 Y & q* E1 k6 Z2 ~, Q. m, p6 Y; {: ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************6 }7 I1 |/ ^8 G: C) J& O
//  ProgramCompare.java         Provided by: DRS
% `  c6 O. V$ D2 K//
7 v0 d2 k+ o  s7 t4 L" M//  Program shell for Assignment 2
% x' k; \" j3 b+ t//
3 i4 g3 b+ r# b' ]5 H" [" d, p//  Compares two text files line by line
. Y3 W+ A* S  E//*********************************************************************
2 C5 W# S8 p6 Q" Q) o7 B8 ~
3 P0 \6 l% G( i: Bimport java.io.*;  T2 W) M  r( u% G$ H

. r- h1 C* E4 l' S$ Q: |/ cpublic class ProgramCompare: O" R7 N/ j/ F" D7 k
{# n. i; ]5 N1 f+ x5 N9 N
        //-----------------------------------------------------------------
( D* V1 u' \: T* o1 W  l9 J        // Constructor
+ S4 f) q) z8 z* W: L7 U        //-----------------------------------------------------------------( [) @) ]. f. c$ g4 o: |9 j; O8 @8 g
        public ProgramCompare()  z) \, `2 [. X4 t# C  I
        {, K6 Z4 ?% h/ L" L. |3 J1 a3 Z
        }
, R! f7 Y" J  l( ]0 b9 ^& `9 V# x0 t2 L" a$ z
        //-----------------------------------------------------------------
+ s$ @1 \# d1 l9 s. J        // Method for testing that class has been reached  m! e( G+ Y4 G% `
        //-----------------------------------------------------------------        * q# t4 R7 t( |2 P

3 \  y+ i0 m" m) j; h        public boolean ProgramCompareReached()        
% s9 g" C: K, t7 {: t        {' k( t& G  {+ s( s7 C; t9 B% N
      try + s2 D* t* x( y! x
   {        
" D3 z: i3 n% P                       
, B/ F% `8 {) `; E6 d0 h                //********************************************************************9 g7 q8 j2 F2 C, O, Z
                // Try-Catch Statement is used to handle exceptions - such as file not found , c" `! e5 R3 U7 U% l( O
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ d6 i$ I* g# b/ r# F$ c                // For more information see page 534 of the textbook+ m) ]4 ^$ o* q
                //********************************************************************& N- S8 U* R+ Y; d3 |% ]' q' T
                    
9 \: [* X* F- I        }' P% o( |6 j4 C( Y* t# D
             catch (Exception ex) // Exception caught here and message displayed to the screen
( `7 t1 O* W7 n          {8 C4 l2 Z, S3 t) r. ~6 z2 d
                    ex.printStackTrace (System.err);9 u3 Z+ A# P/ }5 f$ R
           System.out.println ("Error message goes here"); // Replace this error message with your own          / c- ^! W* A$ l8 ]; s' X
        }  j: s, a0 Y, q7 D9 e
                return true;2 _9 x; T7 [3 m
        }  p1 O( D# H* ]+ K2 M' V
, L% T5 k- J. f2 X! K5 e3 M
} // end of class ProgramCompare7 L" {! }9 j/ l2 K
, y( K/ C1 C# q/ O8 o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, j6 V' X0 U1 B//  ProgramCompareMenu.java    Provided by: DRS
  V: C: y' ?: J  E  B0 N//8 J3 p$ V! w# w
//  Calls AuthorisedUsers.java and ProgramCompare.java1 j# X+ y1 [, \8 k; H$ E
//3 r2 L& V: V( Z' i3 u3 U
//  Driver shell for Assignment 2.  Y. E) Y$ w: n9 M  h! h, i5 V. H
//********************************************************************2 W6 e& L0 ^3 ]$ g; f; r2 K

& H  g3 T, y) K9 Pclass ProgramCompareMenu. k; O; C) {& T' Q
{. w, G8 c+ r% B7 J" O' x# q, F* a
    public static void main (String[] args)
# b" ?% g8 T" M* h4 P2 s! c            {, h3 \& W3 g* n
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) e: j0 K4 G/ v: ?( _$ ?                ProgramCompare reached1 = new ProgramCompare();
2 H6 k$ @0 E; x                AuthorisedUsers reached2 = new AuthorisedUsers();          d3 n& _' v% q5 d
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& N( v2 K3 K0 b+ ^0 L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / a: X; H/ a0 w% d- R; q* x
        }
5 Q  |, _" y7 e8 Q$ B" v}// end of class ProgramCompareMenu7 r7 U) G& y# N- m5 O% x" ]9 A" j
. ~6 d) I6 V  q' H& Z) ?8 U- ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************( ^& s( c7 c8 n* N/ e
//          AuthorisedUsers.java          Provided by: DRS. u3 T  k7 ^* _6 r
//                  n3 O4 R  o- Y) `1 a3 s
//         Program shell for Assignment 2
+ x  F; w  i8 _4 p//
8 X1 H# P; v! P1 i8 r" `7 O; z//         Represents facts about an AuthorisedUser& u9 x/ r* o- z0 x
//********************************************************************* Q. R0 p& I$ {- f, A# c
! y+ f. ?- R0 C$ U7 y5 b
public class AuthorisedUsers
2 C* c& B' k0 g% ]) o    {
, B! a& d+ ~1 i  b' H0 C% A
: n& o- \- T# z& V/ b8 c1 L8 `" M# \        //-----------------------------------------------------------------7 \* C' q: i3 j/ m& c( e  Q/ w
        // Constructor. K7 K  s! {9 ^3 @2 m7 a
        //-----------------------------------------------------------------
' \' ]" v1 N6 Y; T2 Z3 U% f4 T% T- K9 F& I
        public AuthorisedUsers()* r' D" P  M9 y9 B4 w3 c3 S
                {9 a" a) q: U7 P; g! [2 s5 \
                }4 S& x# z: D, i+ d
# O  a- g; r7 ?4 V
        //-----------------------------------------------------------------
1 u! \. d) G( y: X1 q        // Method for testing that class has been reached
+ a$ Q+ X5 S  @9 b: C: |6 j        //-----------------------------------------------------------------       
: Z( q- u" ]. T$ R        public boolean AuthorisedUsersReached()
+ c/ P' _2 Q; F9 Y9 o* k* v5 O                {7 p* G2 V/ h/ p( E/ F# e
                        return true;                       
; m# P' x5 y9 X. p                }
% {2 y: l+ q. F1 j/ t3 w               
" M/ x( Z( s6 F0 P/ q6 N    } // end of class AuthorisedUsers
' Y' Z! F( D1 u# g/ \7 ~5 }9 K8 T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
* R, d2 ]0 K! v, O4 hShanghai - 2007$ \! s( p& }9 H; J4 d6 f
Assignment 2
6 i4 ?( x+ {) d8 X9 v* p0 {$ {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)
2 r8 |" |/ O! i$ N* R1. 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.
5 n, E5 H& X7 Q5 s8 g( N! nThe staff must be able to:
. L7 y' r. T& ? Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& S1 ~' r: i* @* s4 Z1. 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.
" D1 [- e5 O( t* F( E: \ The interface should provide a menu so that the staff can:# [- G4 l  i( ]! j9 {+ E
a) Enter the names of the two Java program files to be compared* _4 G: F3 A/ ~% f4 m
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: P. U( _! W1 @* B( G# P8 W* |# M** 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).
6 O/ x1 }; p% |8 p! \BSA104 Business Programming – 2007: Assignment 2
$ F$ |9 k5 X+ aPage 2 of 5
3 g7 ^1 O3 s+ F5 |b) Print out to the screen all the lines of code that are the same/ s7 U/ b/ ~6 e9 c6 o: k& m
 Include the name of the file and the line number of the code being printed for each of the two files
, }! G- `4 c  j2 ~' R3 k$ L  n, Pc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! n  I6 \+ o2 v3 q2 y6 l: |7 m the name, username and department of the user, K# U. V( u4 V8 c; g- a4 f
 the statistics of the comparison! G/ o' [; b; }( x
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
0 _" e  }& w0 w/ w3 B) { the recommendation for further checking
# C: \" Q# `$ ^2 J0 a- m1 ?- 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% F$ h) A6 D, Y2 \# i/ V2 p
 the names of the two files compared6 p4 h/ W' x" }% z* ~$ O2 H. a
d) Leave the program (exit)3 a  ^# h4 h! |$ d! Q- n
The ProgramCompare class: (Total maximum 20 marks available)
: @' q$ d/ s6 n: _, R2. 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): B: ?" e0 M  ?; G0 Q. Z1 v  c
a) provide an error message if the files are not found or there is a problem opening them
' l2 c; D/ n1 ^" g9 D1 @# j9 Hb) compare each line of code( Z+ r) K' {% |5 l  m' z
c) print out the lines that are the same
& A: G( f4 `" E9 Cd) count the number of lines compared / lines the same2 }; q' h8 D6 B8 T* i. N
The AuthorisedUsers class: (Total maximum 20 marks available)
; E0 t7 q( [. g# 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)
! }  j8 K$ o- b4. Provide methods to:
5 A0 V5 p! [# q3 b6 n) e) d$ A3 j7 ha) 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
* ^; h# y# }/ |- g9 [b) return the name of the authorised user
# T. G3 v0 w1 g+ _6 Rc) return the name of the department of the authorised user
) D, p' e& c0 m( }" U# ?* `Individual Data (Maximum 20 marks available), X8 j" K8 U. P- D/ |* P
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.5 n2 V; b( M* _. T
Documentation (Maximum 10 marks available)
# l8 k: a& \! Y& @* f6 E' R6. 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.
7 p7 x1 `% H  A' ^8 BBSA104 Business Programming – 2007: Assignment 2
% ]& r5 @( a% }" Y3 J& hPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% [& H# i0 y3 d1 \不过你要翻JAVA的类库说明。你有下载没有?
2 C% _* @. p- m0 {# e查询关于对比的函数。貌似关键字是contrast,还有compare
& @6 c) d  c8 A* W1 f
0 u' ]$ f- J/ L6 s  |+ V& y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -0 e0 ~* W2 C( H. r  L
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
3 Q0 F& ^+ T4 t8 C- B; O, d可以下载到的 是 jdk-1_X_0-doc: m/ a: m) j/ C
% @) x! i; D% o( U+ n* ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-25 09:26

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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