找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1457|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * f+ y) V* a, d2 b m 1 W R1 y+ W# g2 ]+ _
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************: @1 D% P1 u, |% T+ x& F
//  ProgramCompare.java         Provided by: DRS* G4 e5 ^& G7 l" C
//
6 P* ~8 ]# P- d9 q- F//  Program shell for Assignment 2& P1 j1 R, |& _% `; }: B9 k' H
//0 V# H3 b1 C" q: s4 b, S! d( r" l
//  Compares two text files line by line5 u3 R9 @: S6 q  d( X! D
//*********************************************************************
- s$ f+ B" W9 S; p  N7 _7 J0 p$ q% M( h7 J) `  a2 A* v
import java.io.*;& w, F, p4 p7 H5 r* B
( Q! U- z/ c" A4 \: o0 A
public class ProgramCompare
& b+ H5 }8 [+ R7 I8 ?{  n/ I% G- [/ B$ N9 [
        //-----------------------------------------------------------------" }* O3 N% L2 S& M5 t- q* x
        // Constructor+ U' x1 T* ^- G$ p; M
        //-----------------------------------------------------------------
& A( _. c; N% G8 J& K" O; M  C        public ProgramCompare()
2 u; |4 g7 y( h* X; Y- j2 t        {' G; ^9 O2 v9 [5 \; W
        }) v' Z4 k- M! j
* \% e+ G, o8 V8 \- r* Z
        //-----------------------------------------------------------------
- W% K% f# |6 @6 y        // Method for testing that class has been reached' j. W3 R5 P4 _. C$ @7 j" H
        //-----------------------------------------------------------------        % f. C8 x6 k( j
+ e. h" s; P! S( q, f* M
        public boolean ProgramCompareReached()         / d5 ?) A+ y  R# E2 G" S) K
        {
) @+ ~7 v* X8 k% p" A. g7 w% e% p4 b      try
) H1 U7 G/ P, N2 ?. q6 d6 R5 E   {        
+ L' J6 ?1 e) p                        8 n5 J* H$ z6 m5 Z' B; k* p
                //********************************************************************
# k: B9 M5 G; M- \                // Try-Catch Statement is used to handle exceptions - such as file not found
" g( X7 i& C; |5 n' d$ I                // Reading the files will need to be placed inside a Try-Catch - just like this one!( W; A- y( [7 l1 b2 ~' h
                // For more information see page 534 of the textbook
# Y6 a+ J, U# M2 R; p- j                //********************************************************************
) F! H+ i, I5 `/ {) n2 Y1 [+ M* I                     / V8 V1 ~% S* S2 o) P
        }% s4 M- O1 t# n2 }" V1 y
             catch (Exception ex) // Exception caught here and message displayed to the screen 8 W; o! j' j; x6 ^
          {
+ n+ }$ q7 d* t3 `' N8 D                    ex.printStackTrace (System.err);
, S" N1 N3 J- B' a           System.out.println ("Error message goes here"); // Replace this error message with your own          3 |$ V5 s5 Q1 q0 N
        }
# x+ ]0 \7 ?0 t" L/ I                return true;
9 w& t: U, C/ \! F        }
5 Z4 X# e& y2 h8 h1 m# O) P' \* L! x2 F
} // end of class ProgramCompare
; t/ g# J9 L3 n' p  ?+ Y& i8 O$ @0 v% ~; R; S
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& m7 A% h4 m0 W0 c3 |$ ?  O) m
//  ProgramCompareMenu.java    Provided by: DRS+ Z7 A( F& x8 m: \/ K) n5 h' x
//' p# l( h/ r3 m3 I1 V& f/ w
//  Calls AuthorisedUsers.java and ProgramCompare.java
" k% d5 U: H) ~4 V//
: t7 l- _' J' j$ l% E$ z" m8 D/ @//  Driver shell for Assignment 2.
2 [1 Y! `4 f+ K; {0 V, C//********************************************************************* `3 ~5 y4 k3 p* K4 S" N

) C* X2 g* i2 ]0 N+ x' eclass ProgramCompareMenu
1 C% Z- }( E9 E& K( s; u+ v) t9 T% A{- o$ f# z, d7 z0 l0 y5 y  M
    public static void main (String[] args)
3 r4 t7 [1 P6 Z# X- J5 {+ Y            {
$ y9 \) ~" t/ ~. y                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 |' Z! s+ |/ n8 s/ t
                ProgramCompare reached1 = new ProgramCompare();
+ M' C/ e8 d! L0 |& z0 c0 ~8 |                AuthorisedUsers reached2 = new AuthorisedUsers();       
7 a+ x& `& _4 ~0 b                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());$ L0 l8 N! P+ f3 C
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / U3 r; `2 n. Q) L/ A
        }8 U& N# c/ u5 |& R& a$ X
}// end of class ProgramCompareMenu
9 P  g# z- s& ^, U, N+ E3 r# ?/ r
& [: u, Q$ [) A; o8 m# _% G//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
/ Y2 [$ F7 \  w/ @# m" [0 N0 E//          AuthorisedUsers.java          Provided by: DRS2 K5 f; H( `' R5 }: C: `7 e
//               
: d1 D$ l% H( Y! {3 d: D//         Program shell for Assignment 2
' p- y& j8 |* |/ n5 A2 E; H8 ?- f1 |1 N//" p. }# d6 v7 g7 l& \% v
//         Represents facts about an AuthorisedUser
. d, g4 z) g# \1 [//********************************************************************
5 Q( W# }, Z8 m- D% Q; R% q
: q6 T. c# d- ^public class AuthorisedUsers
! b# `1 V0 `4 h$ x# g    {
' v. [9 ], V0 E# ?( C+ O$ I
8 E7 \5 j* b; z5 j. \        //-----------------------------------------------------------------* A, I/ o# c, ~+ k) M
        // Constructor9 ~$ P# Q) X+ a! a# F  L
        //-----------------------------------------------------------------
$ u2 r. L1 N6 d' U" \4 l9 y  H+ M, D& L: ~; c4 l* k" e$ {* Z0 d
        public AuthorisedUsers()$ ~* \; V4 r* j$ T% K
                {
  _: m) ^9 ?+ U                }! F- M/ X4 I, N  O0 P
* Y+ }" ?( P0 z1 i
        //-----------------------------------------------------------------/ ^  D8 n: ]+ o, V* U; l
        // Method for testing that class has been reached" m! c7 _! j/ \! a
        //-----------------------------------------------------------------       
0 X7 L- n" E+ k, {        public boolean AuthorisedUsersReached()# U& @0 f& g$ n% w0 B+ ~) A
                {9 K5 t9 W0 {  ?( v2 U* X
                        return true;                        7 {& x+ w' Y' I0 }+ y5 K! M7 ^) ^
                }2 T- w+ e( W8 g3 j0 d5 q
                ' p( {& T3 m7 [* z6 ?8 |1 s
    } // end of class AuthorisedUsers
1 P- V/ y# R. }: m7 q4 ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 _5 U3 `) M3 ]7 b- K/ D( UShanghai - 2007
5 B( N2 u9 E) ]4 p* e: U1 ~Assignment 2
. X* C4 A4 h/ b8 U7 [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)
9 l2 e; N& _7 ]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.
% R  V& f5 k$ E( o- c  |The staff must be able to:% L3 a! S% D; v  x1 y% H$ r4 E! P" V
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 @( w/ B. {' d/ k6 q+ y& q& g  E1. 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.
& _7 }, U; {7 S+ |, P The interface should provide a menu so that the staff can:' x* {! n! ~" w8 |0 g. x
a) Enter the names of the two Java program files to be compared0 T' q# o0 Z9 X: I  J% X
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
, B+ o3 |7 G3 @; \4 `** 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).
9 v- d+ e3 L4 ^8 ~2 F" UBSA104 Business Programming – 2007: Assignment 2
- w3 l! L( d% _, S7 |Page 2 of 5: {% G. b8 n% x! H1 v) {
b) Print out to the screen all the lines of code that are the same
6 d' I6 ]5 ]" ~1 r Include the name of the file and the line number of the code being printed for each of the two files
, c6 k6 q) t2 ^c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 W( K6 C* F5 D: W! d7 x
 the name, username and department of the user2 t2 l3 R0 W. b& E. X
 the statistics of the comparison
/ p. v$ s2 w% _1 d4 M; l1 L- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different$ ?! L9 L  x8 l- l6 Q. w, ]
 the recommendation for further checking
1 [4 x2 I9 Y$ K4 M- 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
( Q/ p( ]5 P8 ]& n- s the names of the two files compared
- k9 H& b5 c0 Qd) Leave the program (exit)8 U4 N1 u0 t4 z% B
The ProgramCompare class: (Total maximum 20 marks available)
  O7 v6 c  x* |1 v" x8 m2. 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)0 J2 L+ n1 b3 C9 F; y1 N6 |, h
a) provide an error message if the files are not found or there is a problem opening them
% O; t; D. T* o0 d! t* Lb) compare each line of code9 {0 V! a: P" V% L& n( I3 y
c) print out the lines that are the same
& u9 @. E) f; W9 W% _3 Z- Sd) count the number of lines compared / lines the same
% E/ P) W7 g5 i/ w, @The AuthorisedUsers class: (Total maximum 20 marks available)5 v3 n7 o+ h& Z! h8 f$ R
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)$ v. T8 d" D# O5 M, {  H0 B: k# d1 b" L
4. Provide methods to:1 H' E" o/ H( ?% M( U
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
# L8 T5 h9 x7 ab) return the name of the authorised user4 e/ t- H! h! \$ W6 G1 k
c) return the name of the department of the authorised user! I+ w- Q- m# n1 h" h
Individual Data (Maximum 20 marks available)
5 S' {7 {/ d. p! ^5 m  e" g5. 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., ^; N4 t' `+ n- V8 p3 c* W
Documentation (Maximum 10 marks available)+ C! b+ o; c: x& u- J
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.5 x; b! c  L3 I+ H3 s
BSA104 Business Programming – 2007: Assignment 24 b- A! T$ l7 j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 k+ J+ H/ [! \# K5 l
不过你要翻JAVA的类库说明。你有下载没有?
& r' _  b" F' E: u3 I# Z0 l1 z查询关于对比的函数。貌似关键字是contrast,还有compare6 `. W; a% `5 W" ~& t4 f8 f

' P! j: p" K9 N& I6 q8 x3 A[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
5 l' H' D# C0 y. z) {' |痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。+ S# x6 X; p2 Q, q7 ^" f* p
可以下载到的 是 jdk-1_X_0-doc' B5 Q. l% b: F  h# U+ @8 }: ]. c
) U% G2 e6 O' t2 x% w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-14 19:10

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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