找回密码
 注册

QQ登录

只需一步,快速开始

查看: 990|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 f2 } r! F% I: w2 i. W8 }8 x 9 t& R2 ~3 e" Y' n* X7 D& i9 J
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& E5 l' B! L/ R//  ProgramCompare.java         Provided by: DRS9 J2 t0 D' C2 v& X. |' y2 f
//
% v$ y# p7 G: B//  Program shell for Assignment 2
4 J* `$ B6 Z4 T/ Y. H8 o: J//
# p) U2 l: A( X//  Compares two text files line by line
! k) ~* w/ h2 i//*********************************************************************, E' d1 r2 T$ s
, t3 y( w9 a) n. g
import java.io.*;
) J: q: m$ y& z: k: U5 V" d+ |9 @' a+ o* S! z# W: ~" Q" j4 a( l( C
public class ProgramCompare. H( G) a8 q9 K2 J6 t- m
{+ Y1 R6 \+ f6 U; W, u6 S
        //-----------------------------------------------------------------/ O5 l5 u4 p4 F. @
        // Constructor
( \& {/ m. i! g' j; K& b        //-----------------------------------------------------------------
9 E; b: O8 C" ^$ r) `        public ProgramCompare()7 u% O! n3 |- |- F9 B1 p
        {
) L* z1 k. Q. j        }9 v/ w3 k+ p  b" ^* S8 _  O1 w
, e7 a9 @) f0 y$ Y3 J* ?' }% y
        //-----------------------------------------------------------------6 K/ R4 Q0 v* l" w
        // Method for testing that class has been reached
7 Y& h# \; @" i9 Y5 X        //-----------------------------------------------------------------        , B: W5 s) w$ A. ?

5 x* G* O: N% C* \        public boolean ProgramCompareReached()         & N: \/ b* Y0 C* s7 S6 A+ d
        {
" Z7 l( ?) Q8 o6 w# a      try
' Y6 U9 T9 |$ x: \! |$ r6 A   {         ( i2 t3 ^5 l" Z7 P# Q
                        6 X" P* {1 a9 m% Y
                //********************************************************************
# `2 s+ P+ y5 y9 a: G                // Try-Catch Statement is used to handle exceptions - such as file not found 0 S7 R' `2 Z* F, a& T
                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 D( D7 w. l$ W% B
                // For more information see page 534 of the textbook
4 I$ U. z7 A: `4 Z3 d, r/ J                //********************************************************************9 e  g- L) ^' E; U
                    
8 |3 l0 g$ L% W+ P  h1 u8 ?- o        }6 p: c& T& ?- R4 |) F
             catch (Exception ex) // Exception caught here and message displayed to the screen
' [( n, H+ ]; f6 p4 T* X: W          {' a1 V6 ?5 o& a$ H. z
                    ex.printStackTrace (System.err);
3 y6 a: P5 O% S% }/ }1 W7 m           System.out.println ("Error message goes here"); // Replace this error message with your own          $ d. a1 x$ P4 W7 l; M' d- y( h8 E8 y
        }
4 }" N# q. l7 L9 n- T; L' [                return true;
9 n$ A/ G0 f- p6 [+ i0 T        }3 n/ o* o5 w! O1 r$ }4 o$ ?/ W" I

1 O2 B% O3 f" M} // end of class ProgramCompare! i8 _; Q8 A( `# p6 d) G
1 u- d0 t; A1 e/ E- \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ h# u+ {/ u0 R* f- ^. n3 H//  ProgramCompareMenu.java    Provided by: DRS( ?2 f- L9 K3 `0 u
//' K" O$ {1 V, T4 z1 o
//  Calls AuthorisedUsers.java and ProgramCompare.java
$ j. y' J9 P9 y8 L* _  _//" R' u5 _/ t7 D- C7 T; A9 x5 t
//  Driver shell for Assignment 2.' ]9 m  J6 H% A$ S2 f7 P+ q2 V
//********************************************************************
/ @7 _5 M6 E0 r/ u' z9 r9 a# x/ V  u6 K5 G! F, b+ c
class ProgramCompareMenu
( U0 J4 v# I5 f6 g# J{4 v$ g. g6 X$ B
    public static void main (String[] args)8 `0 \% S3 F. A  C* ?/ `* N& l
            {- }. J* w' R. K. _0 k2 Q0 ^4 m
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable' m5 y& O( Q2 D' w
                ProgramCompare reached1 = new ProgramCompare(); 5 ]; r. [6 a' ?9 j3 j' l7 P+ P
                AuthorisedUsers reached2 = new AuthorisedUsers();       
# v( O( I. u; A* r                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());& H8 W+ V0 `3 ]1 r7 X1 Q6 h
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
, ]; u7 ~& W% g; I% V' E' `        }- V6 G0 h( E  A0 p+ {( s+ v
}// end of class ProgramCompareMenu
% k) e8 d3 Z8 C; `
, i  B* Z( `  V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
& e3 }- b0 U2 V; k: }  t/ @  c% E9 ]7 i//          AuthorisedUsers.java          Provided by: DRS
) r- m* [* B6 x; N4 L//               
5 C$ Y% k! j2 ]6 Z5 L& Y//         Program shell for Assignment 2
/ a) G9 K( T0 H! H//1 U; A! w" p1 n! `0 u" S) ]
//         Represents facts about an AuthorisedUser( G. o/ {, ?$ y' M% h
//********************************************************************
9 A; E' p$ w6 _9 ~
6 I$ q8 n; L) z" Y  q# V9 g3 n) |public class AuthorisedUsers
) V. Z' [% X8 l  o  m" F( \    {( R' Q+ W: l3 N5 v# A! ?
- q- }. P1 b! n" g2 @6 C9 p( C
        //-----------------------------------------------------------------
* c2 M9 {$ R3 V0 Q1 k( j0 {- v: O! }        // Constructor
: K! {1 c+ @& E' B9 Q. @        //-----------------------------------------------------------------3 E1 `) V& g; c& W0 B- u, Z
3 |: o8 \8 D1 U: l  U& Z
        public AuthorisedUsers()
; _8 Z' h& @8 e$ z9 g8 R- N" |8 E) i                {4 w* u* i2 K( `0 g  {% N
                }6 J9 {+ F. {8 Q/ Q; j5 F& w3 _2 b

/ u5 ~& e$ Z. F7 W7 j; G/ {        //-----------------------------------------------------------------
( \* G7 @+ Q7 R: A$ A& e        // Method for testing that class has been reached  `& G/ g& M) H0 @- d6 ~
        //-----------------------------------------------------------------       
8 X4 w5 a% ]9 m) C8 y+ o: J' t' h        public boolean AuthorisedUsersReached()
1 g/ Q$ j8 ]2 c" X1 j                {$ `0 ~5 a5 M+ l: _) U, D
                        return true;                       
0 O3 l; _0 P# y+ b/ r                }$ ?+ B9 C8 Y/ q& ~# Y; |) `+ o
                # O$ D8 T$ Y  U
    } // end of class AuthorisedUsers- P7 U1 m1 {. p( U& ~0 X) K, w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
' K* q# [* @0 V. X/ w3 v% x2 W, u/ S8 [Shanghai - 20076 C8 F) Z2 \; n; w* r- ?
Assignment 2
0 @, _+ `6 M' i! X; t: }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)* q2 r. Z; H2 q7 _2 r- j7 }* C& ^/ l
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.
7 `/ R, a/ @8 T+ FThe staff must be able to:
5 a! j" g9 [: v$ S6 h Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. A  q9 z* R8 M3 C: d6 Z
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.+ {: m9 o7 v: w8 h3 s* G
 The interface should provide a menu so that the staff can:2 O2 r9 {, V8 G3 {$ }+ u" r
a) Enter the names of the two Java program files to be compared
+ j" W, Z. A9 K) X$ A For this assignment, it will be assumed that the two Java program files are in the same folder as your program.# \# L7 m4 m8 Z' `/ J
** 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).
* f  R/ V% b2 a# m1 iBSA104 Business Programming – 2007: Assignment 2
1 G6 p, Y* P. ^% U& i" pPage 2 of 5( x1 _1 H- Z9 ^0 G, l& C
b) Print out to the screen all the lines of code that are the same: l7 ^* M: x# D* a/ a: |0 i
 Include the name of the file and the line number of the code being printed for each of the two files
* I( o1 d9 k- y* I+ w. Dc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! r3 s9 w* L  u the name, username and department of the user
; W+ u$ P% J" D the statistics of the comparison
, A+ [! E: Y* B: L6 y) t$ S0 L- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
  g6 x: [9 H: k3 I, w the recommendation for further checking
% |: z5 e. ~& x+ v1 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
5 i/ F- L4 |% m' _ the names of the two files compared( Y5 h  `" D8 o1 C7 P6 \) V
d) Leave the program (exit), r: {& d/ b- P6 t
The ProgramCompare class: (Total maximum 20 marks available)5 D# Q4 F8 B- [
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)
' L7 l. W' m8 K4 t" F6 c1 Z8 ea) provide an error message if the files are not found or there is a problem opening them
9 k  w& X8 k! u+ X* a& L+ Cb) compare each line of code- ^& _4 m3 O6 }5 l4 R/ O
c) print out the lines that are the same
: a3 j! U# W, S) Wd) count the number of lines compared / lines the same
" G' ]8 A- \" W/ i9 zThe AuthorisedUsers class: (Total maximum 20 marks available)
3 E* \* ^3 v- M4 x: q2 n8 d3. 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)
, K; B/ |0 S- c: K& s3 [' S4. Provide methods to:
! q0 V0 {5 z% l2 _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- V. @( f( b9 v) j1 E& `
b) return the name of the authorised user4 r, O- f  b; h7 g2 w' ?# L
c) return the name of the department of the authorised user
: X5 u1 G4 G" EIndividual Data (Maximum 20 marks available)+ J6 F5 ]! `7 @
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.
* ~; U9 u: k, f, iDocumentation (Maximum 10 marks available)5 y. j8 M, M( E. v0 K
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.- |% ^4 Z3 i. _  Y
BSA104 Business Programming – 2007: Assignment 2
; s0 u- q4 W* n6 EPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了% K; V  x$ ~* i/ m( g
不过你要翻JAVA的类库说明。你有下载没有?4 y& y4 C1 [! n, o$ A: d$ A$ h
查询关于对比的函数。貌似关键字是contrast,还有compare( A, A! \4 j9 {% P( L9 l8 I' ^
, M# x9 P! F" U  r
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -; P+ ^- t; Y1 W: }) f/ _
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 V' w1 `2 Y7 j" W6 }: R
可以下载到的 是 jdk-1_X_0-doc4 c/ `4 Z7 l% m* ]4 r
: A! w: M3 Y1 W
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-3 14:51

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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