找回密码
 注册

QQ登录

只需一步,快速开始

查看: 928|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - L& |: u4 R' J! f# A C# `- Z9 t" B
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
9 t+ y1 [( f) w2 P. l- B//  ProgramCompare.java         Provided by: DRS
; V+ A: p! E- j  R/ w//) t& x3 c+ D$ B' D5 n8 W* Y
//  Program shell for Assignment 2
0 }5 s. G7 }; U, J9 M* x) [3 K//  d" Q: `& j* l0 @1 H
//  Compares two text files line by line
$ b( W' x/ }+ s4 V3 T5 M0 N//*********************************************************************
2 f- f& [) K; Q4 z* j# O- w1 ~, u& @: k) G
import java.io.*;# r0 p1 R, d# s9 g1 T# T5 f3 i

9 H6 P2 f7 k4 Z; y( S* F  [public class ProgramCompare
$ g# e8 D0 S0 j3 ?. O) y! K9 E/ Z{
; l, p) A5 z& s$ _1 I        //-----------------------------------------------------------------* m9 u* q2 o0 C( @$ H8 h) f) e& W
        // Constructor9 z* X3 g! c# D7 i! B+ r
        //-----------------------------------------------------------------
/ j6 x+ G: l) u1 j6 [: f$ @        public ProgramCompare(); o* W/ v: }5 \1 I2 f
        {
. R% A! b- ~  e! f8 n7 X: p        }
/ R0 K$ {+ @5 P2 x" F. ?
; b# x5 ~4 r2 Q, v& ~( M        //-----------------------------------------------------------------
$ z0 c6 }  z/ @, w( k1 s; L# }" _- m, V& V        // Method for testing that class has been reached
3 u: T" n  g+ t8 F7 d6 I2 r/ k        //-----------------------------------------------------------------       
# Y. h) x" u# x4 {8 I+ ]- G  k6 D0 ?3 I; e
        public boolean ProgramCompareReached()        
- T) C; m8 J1 V# {' P        {
. F9 l* _7 i9 p( M8 I" m      try . [. ]7 Q4 |7 h2 r: ^+ h1 I5 T
   {        
* p+ }2 w+ S% _' O+ k" p- _                        ( B5 S5 _, A( U6 w- K5 [4 D- }( F: \) [
                //********************************************************************
0 V: D7 W* n( d                // Try-Catch Statement is used to handle exceptions - such as file not found
+ I4 y6 @  R) _* \( |  [                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 {; Z+ s& _" ]4 [6 v( p                // For more information see page 534 of the textbook
6 p! w4 v$ G0 t! g7 Z1 r* ^                //********************************************************************' U9 r( H- q  e4 @- s. c0 i9 C
                     - x  ~8 |) }0 D4 h0 x2 m
        }
3 p( g; Y1 u4 ^7 M' u             catch (Exception ex) // Exception caught here and message displayed to the screen
# d, f" P+ t0 z& Z          {1 S" L) ]" X0 `) a  P$ t9 Q
                    ex.printStackTrace (System.err);6 K5 i1 P$ s: L  I0 ~6 U
           System.out.println ("Error message goes here"); // Replace this error message with your own         
1 l1 b! z% Q: K! \/ S& n7 A  r        }7 f7 H( R" g0 N2 a
                return true;* ~3 {" ]# H" B: d" B, [8 W
        }9 o# ?; T( F7 p& k$ h& B& f2 }+ D
' d6 i$ j# h% u7 [2 s2 `# r" T9 l
} // end of class ProgramCompare7 f. u" n! S, u% M; W* m3 R" V4 h

* m, B% d' m6 y3 `5 |* c) l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ l4 M1 l% G2 X( ^  v  G- X
//  ProgramCompareMenu.java    Provided by: DRS2 a. z2 K9 ~* N6 {8 d% q" Q1 e
//# [" e* T6 O: P; w' e' J' w; B8 ?
//  Calls AuthorisedUsers.java and ProgramCompare.java% q) e6 v* e2 m' o! ?0 h& G
//7 y6 W" b( k8 X9 G5 R0 r
//  Driver shell for Assignment 2.# i7 J. R5 T/ u( R( {- l9 G/ m
//********************************************************************
2 F. C5 O; }% K! M! Y* N
1 V7 W4 g+ D# C$ i  H! p9 ?! Yclass ProgramCompareMenu7 Y& w9 Y4 V5 A4 v* B- P
{7 N( f1 J7 ^7 ~; I1 j/ ^
    public static void main (String[] args)$ U. o  L: |* S; c& ]
            {
9 k5 P  O) A: H* g; F* q2 S                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 U: \# Y% d- Y1 \# c                ProgramCompare reached1 = new ProgramCompare();
0 j# _" U- s, ]; ~                AuthorisedUsers reached2 = new AuthorisedUsers();        4 b2 h+ U! p; x2 @
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: L. h& V" o8 \7 N  P4 `" v3 C0 k
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # f% g7 B, q4 ^  v7 u6 W) Q
        }7 P2 M1 x, t' m. E/ Z* K
}// end of class ProgramCompareMenu
4 b) d/ r1 Z  I/ ]5 R
2 [; t( g5 `1 D5 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 R  }$ [/ n8 m0 H
//          AuthorisedUsers.java          Provided by: DRS/ q8 I/ V4 a- i1 t1 N. R5 Z
//               
4 q) w; G# x6 H4 S//         Program shell for Assignment 2; Y- N) `$ X5 s. Z3 x, z" S
//" L5 J* F% U1 }5 }9 [
//         Represents facts about an AuthorisedUser# X& ?, s- t" H" U
//********************************************************************
  ~2 @6 C0 n( u# ~5 J" W8 ]' [# E1 D! ^3 B5 j) h
public class AuthorisedUsers( `( i* Z# ]) n' v
    {8 r' z; M! B) i: I6 K9 @* m

# H; W/ ~; a$ r8 N6 m        //-----------------------------------------------------------------) a2 v5 G" Z% ~' W. j; f
        // Constructor* M; h8 h$ y3 o- b: T/ B
        //-----------------------------------------------------------------
( ]8 l1 w8 J+ J
8 z$ Q/ C% @% d2 N" p2 K        public AuthorisedUsers()9 c; V, ~7 L/ p$ f, F
                {4 t7 F: p0 x' K
                }
  B- {# @( i8 P
* o: d9 B' d6 m. y1 O, g& I- i        //-----------------------------------------------------------------
1 k# L# j* D* r2 a9 x        // Method for testing that class has been reached
& L+ O1 Q  x6 G/ w        //-----------------------------------------------------------------        8 a+ R4 R2 X( |% V  S, [
        public boolean AuthorisedUsersReached()" e  o9 M# H# t* `9 e
                {+ T0 b/ `( K% [  x1 _& b
                        return true;                       
7 L# ~. R/ y" I& p                }) A( {3 ~+ f+ y0 D  W  H( c  j
               
( a2 C# ~% _6 E9 N/ g+ [$ P    } // end of class AuthorisedUsers1 l' D5 r& P1 ~0 G; p
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming; L' p- y9 T# m3 h0 o- m" g, c% ~& @
Shanghai - 2007  u4 r9 G8 v+ L5 [
Assignment 2* U) Y& i3 ?( g& H* L0 [
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)4 Q! b' G' {  u+ x  _  C, s2 E
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.1 f+ |. K' k) e( x3 B; P. `; T
The staff must be able to:- {" N: Z8 b4 ?" a- K4 J
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! b6 X" q1 `$ @8 K6 ^+ ]  I5 b3 A# B
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.$ B5 W3 _' b% G( V$ o
 The interface should provide a menu so that the staff can:
% g, v1 X5 G9 G( \& g; va) Enter the names of the two Java program files to be compared
# l3 K% O' l5 p. @ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 y! }' y) f4 T0 q4 H
** 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).
( j8 y5 B; {; i4 ^' b. DBSA104 Business Programming – 2007: Assignment 2
2 E- B5 I8 e" @) dPage 2 of 5% s1 e- B4 a+ t9 T% @7 e  X" C9 K% h
b) Print out to the screen all the lines of code that are the same6 Z1 I- o! b8 n! q9 X8 E6 g1 a7 }
 Include the name of the file and the line number of the code being printed for each of the two files
- j6 c! y- S) c. _+ J6 x( h  K) Fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 |% ^" r$ ^% x1 c8 | the name, username and department of the user
( \. w' n* F) w/ j! Y2 h% j; s the statistics of the comparison+ R; W' t) }/ A8 e9 F- v, `
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ G  c0 A. S* Y! ?4 G
 the recommendation for further checking
; S% b; z/ P" I* z( I: S3 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
; J. B3 \3 O) G& }6 t. H( u8 g the names of the two files compared
7 w9 f8 O% b  u* jd) Leave the program (exit)+ A9 f6 T4 ]. b1 f$ U
The ProgramCompare class: (Total maximum 20 marks available)
, k! e- z  `2 B2 v& v% M$ n0 ]) a2. 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)( s1 B3 [2 X. E5 n. u9 k
a) provide an error message if the files are not found or there is a problem opening them% T) Q  L, P- V* Y- c7 w
b) compare each line of code7 f. e+ V& M7 }; }$ V! k& y* B& r
c) print out the lines that are the same
. _5 o. U3 z3 v) Xd) count the number of lines compared / lines the same2 M% J% b" k+ f$ f$ x/ g
The AuthorisedUsers class: (Total maximum 20 marks available)$ `% X4 Q( U$ T" g# 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)
$ U: w) \$ f; @$ ?6 f3 ]4 V/ z4. Provide methods to:: K2 Z9 h" b+ p  v$ @# v
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 match9 x& X" \1 r& y6 y% ?. k# r& V
b) return the name of the authorised user
/ o; U: X% D; m1 F9 r2 O& e7 |c) return the name of the department of the authorised user" p0 R9 n* r, F" `
Individual Data (Maximum 20 marks available)
+ v8 n5 i7 G' k5. 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.
% s4 J% ^" k7 x, GDocumentation (Maximum 10 marks available)! \# i* S" g2 V2 M6 X/ d: n6 J. b
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.
! \. J6 s% _, L2 u9 RBSA104 Business Programming – 2007: Assignment 2
+ G$ E2 U1 U. h: LPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 U+ @) O9 T2 [) n; Y0 G
不过你要翻JAVA的类库说明。你有下载没有?
9 W7 R$ a# w0 r- r1 r查询关于对比的函数。貌似关键字是contrast,还有compare
4 ?- k" A* Q7 Q$ M
- y1 b5 |3 d) ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 \+ j) K7 v; Z$ C- R5 h6 e
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  ?1 `, K8 {' @可以下载到的 是 jdk-1_X_0-doc, a# E7 m) m2 P4 ?) H5 z
" O0 i. F# Z! \: ]# B; E: M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-3 12:17

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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