找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1582|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # j) U- a+ C2 }& W7 j9 ~* U0 V 2 [% ^3 q, m' S0 K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 g5 ]! P8 {; L' |
//  ProgramCompare.java         Provided by: DRS$ j0 E- G$ O/ j( z& C4 z3 M
//* E/ i' f1 ^5 p; X/ Z
//  Program shell for Assignment 23 @: Q. M5 Q4 V
//" }  p* D& m4 ?" s! p: l
//  Compares two text files line by line
3 [. m5 S. `" }, z! N//*********************************************************************9 y- E9 E/ p  J( i8 H. m

7 f3 s" B9 y4 t- ~" F( Rimport java.io.*;. |6 k1 B6 e! |/ Z8 |
+ b. k6 c' j7 R# V! h! v( K
public class ProgramCompare
  y6 o6 F2 `7 s1 \: h{
: }2 C: W/ i5 r        //-----------------------------------------------------------------4 I2 A6 `! k: y' f& ~/ F# M
        // Constructor9 @' M1 C: V; \4 b6 f
        //-----------------------------------------------------------------
- n$ B' [0 I5 i- x        public ProgramCompare()
& @+ N; u, Z) K  o6 g& b, X$ L% e        {
# e) W# s6 O& x2 G! `3 B        }
6 n+ d7 @1 t/ [9 m' e0 e7 |
: v- \( u  j4 r5 \7 ]% @9 X" o6 g        //-----------------------------------------------------------------0 c2 H$ f* N1 A( w" a
        // Method for testing that class has been reached2 L+ k6 h) E- X. Z
        //-----------------------------------------------------------------       
( z5 l9 {# Y" C! e4 i! A# m8 Z! [/ ^- K; j7 t6 ?2 [
        public boolean ProgramCompareReached()        
; Y- P7 O6 N( G1 u+ F! a        {! `: l  a: {7 f! v/ u, G0 H7 n0 t2 C$ T$ F
      try
" E4 L) a8 L5 G& `   {         4 n) x( u4 Z) \# ~
                        # q6 {$ K7 u0 O
                //********************************************************************3 K4 |, @1 v8 ~$ K2 U) a
                // Try-Catch Statement is used to handle exceptions - such as file not found
& M5 C2 |7 Q# q, `                // Reading the files will need to be placed inside a Try-Catch - just like this one!
7 f6 G* A/ X" S, J1 C2 L                // For more information see page 534 of the textbook0 v2 B+ K; l8 y" f! {, v$ N
                //********************************************************************' y* W" f3 g0 f' @8 F3 W  m/ b5 I
                    
5 y1 s( x5 Y2 x# g9 q5 t        }
0 E+ r* ^/ P" T& k             catch (Exception ex) // Exception caught here and message displayed to the screen * B6 T. i! @* U
          {) W1 A' e/ a8 R9 G
                    ex.printStackTrace (System.err);
' {, P. g3 ^9 m; g           System.out.println ("Error message goes here"); // Replace this error message with your own         
; K9 c# E6 d8 G% |( D+ G        }
5 N7 F# C* _3 A: B; l                return true;
9 g4 U, U7 T, a# j4 |. p& }        }
( W7 ]! y/ P5 d3 `/ d( a  s
6 C7 |8 n2 H& r& b9 P8 p( \} // end of class ProgramCompare
+ a6 {) }! ]/ B3 _6 L( v/ s$ o8 y! R5 c, {' w% f  `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 I* N* l7 P  W/ ?* ^: E$ ^//  ProgramCompareMenu.java    Provided by: DRS
3 X( P2 f: J' ]7 ]8 m/// ^6 Z; \/ K5 p/ n+ w* [
//  Calls AuthorisedUsers.java and ProgramCompare.java, G3 _: K' @8 H$ `
//
6 p; Y# N" t" m/ E5 s//  Driver shell for Assignment 2.7 j0 ]/ l2 l; N
//********************************************************************
3 e# {# @' V  @2 o, ~9 E) B# h% _& z- B$ w7 e! g" Q
class ProgramCompareMenu
: p6 _0 d/ z9 A{9 m# E$ q4 m+ u% U  r& j
    public static void main (String[] args)' }8 q( _: V( P7 a% T/ G9 h0 K! i
            {4 \. }0 g& A; ^) V; R, G( S
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 Y8 W1 }% g. e: B/ U& r. r
                ProgramCompare reached1 = new ProgramCompare(); " F6 Z; S. U' Q8 ]# X  z& s4 P& W  O: ~
                AuthorisedUsers reached2 = new AuthorisedUsers();        - L" w1 {/ v1 u% Q6 Y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());) s% x& j0 e$ N
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 X8 s6 T- Q, o7 [4 L6 m* Z
        }
+ P! Y! Y, B2 w0 m% N4 R}// end of class ProgramCompareMenu" I' Z) t2 ^$ S9 K! O: L
  D( H. @! {$ |. s1 b8 ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************9 s( U$ k* C  Y+ f( \* h2 J8 m1 C
//          AuthorisedUsers.java          Provided by: DRS  p7 s6 G7 n, `/ t# x1 X5 j
//                ; o# ^* h& n- w# Z7 M
//         Program shell for Assignment 2
5 z  @8 S! _/ `0 E/ ?5 \7 r; S! o3 o//
* G& d; A/ f1 V9 s- R4 {//         Represents facts about an AuthorisedUser5 G5 M4 D& ~0 O# R0 i' Y
//********************************************************************2 j' [) {( N" D

+ B4 {2 N" u. R; Bpublic class AuthorisedUsers) N. \+ @. T1 h. i2 W- O7 \
    {* u, {8 I: H$ e5 p; l+ t6 i& R. ?6 m
2 i1 g/ G* U- Q
        //-----------------------------------------------------------------
4 Y2 \+ P; r! Z: \! E' m3 Q        // Constructor' L* `' N9 ]7 K4 a+ q
        //-----------------------------------------------------------------( P0 h& [# k1 L; v1 b# i! E: r4 {
( m6 j) G0 [9 @" A( |
        public AuthorisedUsers()
  I1 f: e8 A( `+ L* r+ u                {$ x9 E. g$ a7 [
                }& O) h; q: t3 o0 F" C

% [* n3 N# r- S& U        //-----------------------------------------------------------------/ X$ M3 A6 ?- i$ [; q
        // Method for testing that class has been reached
% V- m7 ^* Q- |$ Q        //-----------------------------------------------------------------        ; U7 _# B5 S& `, k
        public boolean AuthorisedUsersReached()
0 U& R( \+ F2 a& I/ z& M9 d. u& e                {
# G* \5 U+ d* l                        return true;                       
/ _% @) i8 C- r$ q1 h                }9 \4 D  e, u9 F- R% O
                * Z8 s& q6 e5 ^
    } // end of class AuthorisedUsers9 |8 e( y6 B' g/ }; Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! |- i0 v7 q! H/ A0 m9 v
Shanghai - 2007
& j9 E+ i' V9 J1 vAssignment 2- K1 H9 C; `* U4 n* }- l
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): x/ A# n$ w% 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.
2 ?6 ]+ o' \; `) l& W0 d: |( YThe staff must be able to:
  P  u0 n# n( A( D+ u6 ^ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.' M! Y; f! n! Q$ P. X; L( m" L8 X
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.
; W+ d3 R, F- L2 y" t# \ The interface should provide a menu so that the staff can:
7 E+ C2 }/ z* f/ n2 Z3 b( _a) Enter the names of the two Java program files to be compared
  d" a8 ]) F' G/ z# P# R8 K For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& T2 |! j8 B! W** 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).
8 A* ?! d. w: ~! m& h$ fBSA104 Business Programming – 2007: Assignment 2
4 b) h% h4 z3 {4 n4 n% y8 tPage 2 of 5
" i3 a9 l4 |1 F* S; v1 X5 Lb) Print out to the screen all the lines of code that are the same
+ k9 v: x  w3 b: I! b# z Include the name of the file and the line number of the code being printed for each of the two files% \$ f" A0 M: P3 g! K/ T' X5 {5 w& y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
( X" t0 G( x7 K3 g' p: z9 t$ O. w the name, username and department of the user9 o; c( p5 ~9 o
 the statistics of the comparison5 }! M2 z# v. K0 t+ f8 Q* D! C
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
: C; r2 j/ X+ y6 z' K3 ~$ a9 s the recommendation for further checking
- }" }+ ]4 u* W, R3 w& a- 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
. I" e. y# z9 E8 z+ A2 w3 e the names of the two files compared
8 z8 m; S! F3 Z6 S: O6 Wd) Leave the program (exit)! e: O) S; {, P# W/ S) L
The ProgramCompare class: (Total maximum 20 marks available)1 m3 v; g3 z5 {& y
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)
1 Z' y- M6 Q* S7 D& S- S8 Ka) provide an error message if the files are not found or there is a problem opening them
+ @$ t* H/ X6 q9 c; Yb) compare each line of code
" X  k0 f- I3 N& E% \- m! Q5 b( }c) print out the lines that are the same: w2 I5 ~* _8 V
d) count the number of lines compared / lines the same" Z, L% M; Y. [. Y5 \$ E! M' N( e
The AuthorisedUsers class: (Total maximum 20 marks available)8 T% S/ [9 N. S4 _" U1 u/ c
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)! Q/ M" A! _& p, c
4. Provide methods to:2 F7 w: `: R  y. P
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 match2 c5 Z* ^5 u# T
b) return the name of the authorised user
4 i7 \. X1 u0 g. Qc) return the name of the department of the authorised user
. W% |1 M; ~! Q, I; \6 O) wIndividual Data (Maximum 20 marks available)+ D7 R/ y4 L& K. H7 {! S
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.+ K3 q  s* {& g
Documentation (Maximum 10 marks available)" T7 J0 x2 k3 k. i/ J5 m
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.. i% D* Y% K# g+ h7 u9 _
BSA104 Business Programming – 2007: Assignment 2
: k3 v, W" }) Y8 O* v: GPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& I2 K2 Y0 \) J
不过你要翻JAVA的类库说明。你有下载没有?' [2 H4 q* R5 Y* ~0 p( M
查询关于对比的函数。貌似关键字是contrast,还有compare
# H2 h, Z8 K; ~1 v2 d9 i$ ?7 T
* t9 ^' h" H' S& T. H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 Z& F! Q! ~) E! ~3 g痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; t, m$ E/ e4 x: N) Z7 O可以下载到的 是 jdk-1_X_0-doc, p; z- m8 b4 T7 j0 a- X& u

# l( S* K1 E. N5 U. g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-27 05:39

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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