找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1843|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急( `3 Y: B @7 X5 J) Q7 ^& p9 A1 e8 K8 E 5 W$ Y4 n; e+ g+ J2 B( Z; N& G Z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  S* b/ x8 G8 q8 w- m
//  ProgramCompare.java         Provided by: DRS
+ \; _) s8 |! s8 t7 c6 ]//  L0 s0 M) v$ I: v) Z0 [
//  Program shell for Assignment 2
0 Z) t9 k6 M1 }3 |//
# m9 ?0 l  |- ], a2 f+ i0 {6 n//  Compares two text files line by line4 w; {& S2 N2 U" p9 w& p2 P
//*********************************************************************
) u/ i2 C8 [% i9 j4 @
0 J5 I4 S; ]6 i/ Y0 _" N1 _import java.io.*;
3 a+ k& g# u% b2 i8 l5 G
* W3 X  ]1 X. L; }3 T: npublic class ProgramCompare' r/ O( t  x1 \. K: S' @2 ~
{/ S: s2 F8 v: Z( w$ O6 X8 }1 c$ n7 E; J
        //-----------------------------------------------------------------
+ f7 Q! U# O) q9 C2 [        // Constructor5 S, \3 ]# l0 W. k5 @% |/ F# ~% G
        //-----------------------------------------------------------------" m1 y$ U! w4 }: U! }9 Z
        public ProgramCompare()
  G9 q! g  u, f! A        {
2 J2 W+ }9 w" n# U* D3 k        }
. g  c0 X6 W* `
  e6 [) P5 |$ _( J. U7 W/ }; M        //-----------------------------------------------------------------& K0 f! O6 z3 V9 _- n
        // Method for testing that class has been reached) t5 U( g, E* \$ }! K  X1 d$ D
        //-----------------------------------------------------------------       
& H. ~3 a- J5 Y" J; o0 ]! @$ n7 q5 |- t1 W# ^; G  f1 f
        public boolean ProgramCompareReached()         / c4 T. j3 t$ B/ `7 E2 x0 E2 \
        {
+ J' P, E3 O. S0 D& O      try * G, ?7 R; F# i4 r
   {        
3 G  x! j1 }( Z# o" q2 x& W                        + y0 j! }& k( s  Z
                //********************************************************************
" Q0 @% F7 S) q, V; F9 V                // Try-Catch Statement is used to handle exceptions - such as file not found & \# A! \1 v6 f2 ^
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- a) p- V2 ^# z0 h9 u" _7 T
                // For more information see page 534 of the textbook
0 [6 h% U/ v9 i0 m9 E- Z  u9 G2 C                //********************************************************************9 n5 N/ I" V; D" Y
                     # o8 z, i* y* M# v; r8 ]2 X
        }" V* x; Y! F7 S; _8 m
             catch (Exception ex) // Exception caught here and message displayed to the screen 7 T7 ]0 f" G; G2 O- X1 e
          {
& p  `  B( R9 L6 R5 V9 m. [  L                    ex.printStackTrace (System.err);
7 |* s# }- T% ^% M& x- c           System.out.println ("Error message goes here"); // Replace this error message with your own         
; v  A, K! A6 u& O  \        }
* K$ W! y, x& q. r) q. e0 T                return true;7 g% {& O3 D1 d& G* I3 L
        }/ m3 o. d8 B' b0 G0 ^& z
% H& z5 M2 b. n& t! e4 y. b
} // end of class ProgramCompare
& Q; a3 {1 ]/ R
' |9 M6 h# O5 P% R. p1 h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 R6 `( _8 \. k7 Y' J1 w0 {7 b3 n9 p8 F//  ProgramCompareMenu.java    Provided by: DRS* ?3 y: I+ x. }0 G9 h
//
# j% j8 a1 {- ]//  Calls AuthorisedUsers.java and ProgramCompare.java0 \8 i9 J3 I3 K; a* z1 z
//
" R4 ?" S. c0 I4 f. N6 p: l" p//  Driver shell for Assignment 2.) u6 [, S, O5 q- h$ Y  P: h
//********************************************************************8 d! ~/ Q. e$ R
% U2 b" e( h; e+ ?0 Z2 ~) M+ b- `/ Z
class ProgramCompareMenu" \! c4 N9 _, V! w  ]- V
{
! X, _9 X) Z$ T: o% }- h3 B& G    public static void main (String[] args)9 f1 A+ A/ n# e* s' s
            {; {& v2 v1 M- V1 E- z3 Y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable" w, z; H; @8 U: x7 M( R9 o7 F  o5 q# D
                ProgramCompare reached1 = new ProgramCompare();
& T# U, \6 V) ~7 a" n( Y                AuthorisedUsers reached2 = new AuthorisedUsers();        * Q2 N( p, U: n5 S7 S: r6 E- T
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) O7 j7 x% J' w; q  q0 x9 n                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  V8 A" d  V5 j% [9 @        }" k7 `; S9 P( m0 }1 }3 w: M, s% T
}// end of class ProgramCompareMenu9 {* F; g2 A1 T' R0 d( w& Y

: i2 c' `, |% J# U$ V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 O# l9 x1 d0 O6 X//          AuthorisedUsers.java          Provided by: DRS* U+ h4 K) T* C5 G
//                : w- W" _4 @" s$ J4 ]
//         Program shell for Assignment 2* K+ S6 W; q) R( w# N  h+ P* l) L
//; n$ |4 ?3 y8 L1 z+ u/ d4 _/ P- Z
//         Represents facts about an AuthorisedUser
7 C4 _5 I& i$ G& C! k. o//********************************************************************
2 {' i2 V$ n1 M) I% G: u* [8 B$ w0 d
public class AuthorisedUsers
; n0 N; ~8 S5 e) K8 W4 f    {
( \/ Q( A/ i; X/ `9 o# D; M* ~$ a; H4 S' X( p! G
        //-----------------------------------------------------------------, F# d- }5 i5 y  |* o2 {# o
        // Constructor& L- C6 z) `+ H  P' Q0 T
        //-----------------------------------------------------------------$ y, I# f" ]% u+ m/ H

( ?$ v/ C0 s5 S  m! z! O7 W5 |9 d) W        public AuthorisedUsers()
6 Q* F* l( [+ \4 ~0 S) L                {) {: e+ i% `7 k9 |: V+ ?8 ^
                }
* c9 N8 n7 x. \; ]
2 l* F3 U2 M" V) y5 x        //-----------------------------------------------------------------  F. ^/ Q; A( X0 a6 m; H4 l5 b- {
        // Method for testing that class has been reached4 x* R8 C8 E4 Q! T# K
        //-----------------------------------------------------------------        3 a) M1 X( p% c! Y0 I% y. k
        public boolean AuthorisedUsersReached()5 ]* ^+ B6 n; |; E
                {
7 I' F' J( B! }* @                        return true;                          A3 }8 H* G: N7 O& g2 ~0 l4 z
                }
1 w$ |8 }# \) i9 J               
/ i' Z7 K9 R# l$ l7 ^6 p    } // end of class AuthorisedUsers
# a# V* g  b% }  p, G7 y$ q7 {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ S' y) M; |  u8 G4 `9 r2 NShanghai - 2007  K9 Y! J+ B4 Z1 v5 X
Assignment 2
! h5 G6 V7 F; g! q3 z& V* MDeadline 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)
; G! j3 C, I. n3 U! B! A1. 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.
& |3 U* r, o' p4 _3 [The staff must be able to:
; {) |; q" l! B* j% s1 ]1 z3 i Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.0 S) D. X: V! w6 y& @% [2 t
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.
1 z+ B7 ]8 E7 Q+ k The interface should provide a menu so that the staff can:
# F8 |" @6 }! y% |( F3 Xa) Enter the names of the two Java program files to be compared
( v$ b5 t" H( _9 ] For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 F+ i( z7 M% _2 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).
5 K1 p8 d- M7 j% aBSA104 Business Programming – 2007: Assignment 22 t# a) r6 W' l  E5 L& T' |
Page 2 of 52 m4 V; i2 X- x) A' ]! _
b) Print out to the screen all the lines of code that are the same. Q$ c2 O1 a& r. `
 Include the name of the file and the line number of the code being printed for each of the two files
/ U% G% ?- H; |" L; }0 N$ m& cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared7 ^" ?" G0 I0 w1 j+ g" k
 the name, username and department of the user9 O) H; w2 @, O* t
 the statistics of the comparison
6 K' F/ o2 _0 G2 V- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: \' n7 g; t' G4 U. l
 the recommendation for further checking
3 K  P: C; ]" ~7 i7 P& P- 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
$ }/ r- e/ e% ~- _- ~4 r3 w the names of the two files compared
' A7 |+ J5 Z5 Y; t2 n, ~* a. Gd) Leave the program (exit)
) H) c1 H# P8 o* e6 b' ]  |! tThe ProgramCompare class: (Total maximum 20 marks available)8 n5 F# [) V$ s1 d* T3 ^1 W+ D
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)4 ]* W* ]7 D' _0 p/ I
a) provide an error message if the files are not found or there is a problem opening them
* E9 D1 p: [% xb) compare each line of code
! d. j9 `7 [: K  h3 z  a5 Kc) print out the lines that are the same' c$ a6 w! p5 c& m8 @( v1 l
d) count the number of lines compared / lines the same
/ I1 |( }2 G+ C, L6 E3 Z- b9 JThe AuthorisedUsers class: (Total maximum 20 marks available)9 m5 Y! n& y0 r, r4 M
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)7 I8 J6 o1 }& N! A
4. Provide methods to:0 u, ^* f5 s9 U9 S; 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 match; c/ a1 T9 ]' a! x5 v" d
b) return the name of the authorised user4 [) _& l5 }2 y+ m# o" l  i+ z0 I# u
c) return the name of the department of the authorised user
& f5 _$ p" J, ~Individual Data (Maximum 20 marks available)
& M6 L7 ^/ P/ U, W! s* `9 B5. 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 i1 B( k* v5 H4 I" v8 `% LDocumentation (Maximum 10 marks available)3 Z0 h/ W# K  Q( ?# l
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.8 I0 z3 B/ E+ k0 O4 ~
BSA104 Business Programming – 2007: Assignment 2
) `1 |; g* o0 sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ d6 g# f  R& X; t, y! M
不过你要翻JAVA的类库说明。你有下载没有?6 |% x2 Z% x/ e- q" C: H
查询关于对比的函数。貌似关键字是contrast,还有compare1 R6 n* [3 T; A$ V. n  ^# M

: ?+ j3 l1 H2 X# U# P* c% B[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# m: m0 s6 s8 y8 O: y+ r. s, Q- h痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 a4 e  o+ z" M/ W# g
可以下载到的 是 jdk-1_X_0-doc, g. ]: p" _1 W$ a/ P' L* H  Y
; e% M2 C- n8 G$ D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-19 03:27

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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