找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1767|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 + p) V4 p) J( y5 G! v. |6 V9 i& ^8 a$ D. E
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 s2 w: K& h" `& h
//  ProgramCompare.java         Provided by: DRS
7 @, E: q6 X" V( ]. i//
4 K$ A* s) z( L3 s% Y, ^//  Program shell for Assignment 2
; x/ S5 G3 ~0 S- ]4 R) g; j1 B//% p! Z: z2 Q9 d+ Y# Z
//  Compares two text files line by line
9 K3 i3 P* L4 v2 g) G9 w//*********************************************************************0 }8 x0 w6 P/ o% n6 h) P

2 f6 [! F+ b. U$ [$ yimport java.io.*;4 x! T5 i. n) J+ R7 Q; V& p
9 \; B! H$ x  R6 X
public class ProgramCompare
: y5 x$ x; P1 u- g0 V) n* `{9 [* p) b4 s1 r" w% B
        //-----------------------------------------------------------------
( J- d' ]. b* I$ u1 i; Z        // Constructor# s) H$ ~. W# o3 Y
        //-----------------------------------------------------------------2 f. k5 E" ]; V$ F, N( @1 h2 R6 P
        public ProgramCompare()0 `9 E* c* Y# I1 r. J2 T: q6 q
        {
/ e) c2 F; J2 F5 t        }
8 ~2 E; ^" k( g6 K
0 K& w: H2 `% d7 g        //-----------------------------------------------------------------& }5 X; E% c( b. Z* G4 \+ T9 k
        // Method for testing that class has been reached
) I6 a% G+ X5 Y% l  A        //-----------------------------------------------------------------       
- I. y9 k  i/ ?3 @" m+ _9 g' L- L/ E' g% T
        public boolean ProgramCompareReached()        
0 h) t* S, l8 K        {2 [4 c* u) b/ b) O& s! o/ \2 r
      try
: ]" U1 d2 n6 Q$ X% m- A# v; G. T   {        
& q4 K, p1 @% \( |' C                       
8 i3 ?2 t  w& x* g                //********************************************************************
9 }4 C; S3 Z, [) c                // Try-Catch Statement is used to handle exceptions - such as file not found 3 p" g, G! X) v9 P& y  D
                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 |6 r- |! j1 z1 T2 b! y9 B
                // For more information see page 534 of the textbook: ~, w7 |- u3 y% n$ m  k
                //********************************************************************4 e& r" u' x* ]$ W
                     " P+ Q9 `9 q: c3 _6 g
        }
% C/ H, `7 G! v' V& y7 f             catch (Exception ex) // Exception caught here and message displayed to the screen 5 k5 s& b# ]3 }
          {
9 ?0 Z; {- K: O3 |) _1 _                    ex.printStackTrace (System.err);# ]# S2 T3 g& t. F- A
           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 Y: F4 j1 B& Q3 J/ F8 \/ T: b        }* m' v  O, R) c# Z; t, j  u
                return true;
2 U5 K0 t% r, n1 ]        }5 {* C( S1 s4 C

; W* p, ]/ R, ?' c) C: F* E) Z1 p} // end of class ProgramCompare7 P: A# s" m& V  U7 l% X
. ]+ n' @$ y) ^6 ]: E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 N. K4 q8 R2 c+ |4 `# Z6 C5 a' c
//  ProgramCompareMenu.java    Provided by: DRS: S; _& f- B" g! d  w  M
/// q) i3 K  j! U9 O; n/ P! j
//  Calls AuthorisedUsers.java and ProgramCompare.java
3 S5 K2 ]& p- r6 V( B$ a//
8 e! U; l7 L5 h$ y3 a' s//  Driver shell for Assignment 2.- [8 d. h( J7 ?6 C# ?
//********************************************************************" y, \1 H1 l7 \7 u0 T

" ~( J9 A5 q' v/ N  yclass ProgramCompareMenu+ Q. c- u3 \8 x1 O' `) Q
{3 w' X4 s: b' B( Y, l$ l) `# X- l# ^% K7 P
    public static void main (String[] args)
; n2 \8 N! Q( l; D8 q( b6 F) b            {& l( h7 X( s8 q) t+ u9 V9 M$ W
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable% N1 J) N0 a8 b4 g# y) e9 C6 T
                ProgramCompare reached1 = new ProgramCompare();
2 T& ~0 a9 o0 u9 C& Y9 ]                AuthorisedUsers reached2 = new AuthorisedUsers();        4 ?) Z" f3 G* }8 R/ Y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
$ M7 p0 p$ O; T7 {                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        6 Y8 N' L! f& G2 k# z+ D
        }3 [/ ]: }, k  X9 k% S
}// end of class ProgramCompareMenu; ], d2 g! ?# a* X& B

7 k$ v% ~$ k, z# T( R& K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 u# z3 t6 ?0 ]6 {" {! q2 {//          AuthorisedUsers.java          Provided by: DRS
- z+ y* t/ [1 k/ Y& y//               
  u; A" u4 x0 e2 j9 f% E8 ^+ T//         Program shell for Assignment 2
* U! }+ r) n& q! D! q! J2 b! K//6 ~9 r9 J! e3 E- V
//         Represents facts about an AuthorisedUser% |5 b0 i! ^/ y0 R" W& i' M; W& p
//********************************************************************* I/ }0 j1 r) ~2 y% K

/ P0 n  f( W( L( W: ppublic class AuthorisedUsers
! ?6 R1 F, Y6 `& p# v    {- _2 D' q$ P2 Z5 M
8 P1 R/ u9 j  [2 L, P  r- s# ~
        //-----------------------------------------------------------------5 p+ T" o) s: v8 U2 k: J& z
        // Constructor
% n2 t0 O  f& x% E( I  x        //-----------------------------------------------------------------
% V' V6 l  r: L) Y% V1 {& Q) X5 X+ w6 |  Q
        public AuthorisedUsers()
# N  P1 I3 g6 G3 j                {
$ c: ]0 ?, i8 p' @& q5 d0 v, V                }  u- s1 E5 p* \8 k; p# ^# E

1 S3 Z7 i) k5 A2 h7 J        //-----------------------------------------------------------------' O3 R. R. _4 d) N
        // Method for testing that class has been reached- U' \5 ?$ H$ `
        //-----------------------------------------------------------------          |+ |5 R  f/ U' _7 J2 M- j
        public boolean AuthorisedUsersReached()8 ]# \$ F5 V4 S; j5 m. C- |
                {8 a  E: F2 \1 T. q- F
                        return true;                        9 L: h/ p5 M6 L1 I3 B- e& F
                }, i+ Q/ O, v/ E- @: c4 Z
                8 c5 G$ J+ d- U9 L
    } // end of class AuthorisedUsers
+ c) s/ A! g3 H3 S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  K4 b- r2 r# V! Z) \! T/ O* M. r
Shanghai - 20076 L' _, {6 B" w
Assignment 2
  R- K/ e" H3 Y) ^8 K5 X. 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)7 u3 @3 W* D# l& _4 L( ^5 ]
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.
0 s; ]; y! I; }/ |4 OThe staff must be able to:
, G& O3 l$ y# C( G6 s Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.' M4 e' y/ e$ {( 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.( j8 I- ~) j" K5 d; l
 The interface should provide a menu so that the staff can:0 o  e2 n) L; T
a) Enter the names of the two Java program files to be compared" p+ h1 u: F4 w7 r0 ~
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
, C. w, B1 X% `7 h8 I8 \' t** 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).) |% t+ P) B2 S8 f& H
BSA104 Business Programming – 2007: Assignment 2  T, z# w! Z9 y
Page 2 of 5+ h. J) x! G: h" f' m/ n0 D
b) Print out to the screen all the lines of code that are the same
6 J1 U: K/ R9 R: m( Q Include the name of the file and the line number of the code being printed for each of the two files) @. c4 m9 i. g6 B; o- v7 ~+ }
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ S. ?6 I% Z  `- N3 E
 the name, username and department of the user$ ?) C, i9 |( u. m$ i
 the statistics of the comparison1 i* p! j# K0 ^% a6 r1 e
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ ]: V7 |8 O0 K0 u' H; B the recommendation for further checking; R3 F+ B0 [" j! Y$ s
- 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# C  W% @, }4 Z. q7 G6 C  k the names of the two files compared
' [* k: u( `$ \4 W& D7 e  M! cd) Leave the program (exit)
+ d- }* ]; X! }" EThe ProgramCompare class: (Total maximum 20 marks available)
4 h8 m4 u3 C: e4 Y# N2. 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)) S3 T) S( s; {" A& Y1 }0 Q2 b
a) provide an error message if the files are not found or there is a problem opening them2 c( P' N4 i3 m/ C/ C3 d+ h
b) compare each line of code/ v1 A( |1 _- _* i& v6 T" a
c) print out the lines that are the same, D- g# J, w) e/ ?) X) T. R: ]2 S
d) count the number of lines compared / lines the same
! `- j9 ^% I  A6 Z; gThe AuthorisedUsers class: (Total maximum 20 marks available)
% a3 z& g8 z2 w+ C3. 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- H- d( ]. l/ z' G
4. Provide methods to:
* c" n: F" L% H0 ~4 b: ya) 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
' n( b: n. ?: x- m7 C5 Nb) return the name of the authorised user6 o/ Q: a6 t; X8 b7 K- g
c) return the name of the department of the authorised user
3 r/ [5 O3 c; t7 ]6 f6 fIndividual Data (Maximum 20 marks available)$ a1 j, z" c! 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.
1 A' c+ b6 A- KDocumentation (Maximum 10 marks available)% P8 q4 S6 W+ p9 ^" ^) {7 R/ 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." j( [, E: v8 G" ?7 u
BSA104 Business Programming – 2007: Assignment 2
- j+ F% N: p1 o; ?+ lPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ I, D+ U2 B: t  X3 G' U8 C2 h  T不过你要翻JAVA的类库说明。你有下载没有?
5 M6 [( \3 ~* @/ m: o查询关于对比的函数。貌似关键字是contrast,还有compare
6 s2 ~- t+ w* Z5 t( T) l
$ x# }* ^4 Y: N. J; ?6 r: d0 z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' K0 k( i( `, y/ _: z$ u& K+ M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 |' X; i' H& f1 Y. o
可以下载到的 是 jdk-1_X_0-doc# {! U" t& P9 Q* d* ?5 x/ \
% Q) Q8 Z% t$ C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-26 21:41

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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