找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1556|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急, Y: x- q. k* Z* ^; ~7 u 3 b, D0 c& c2 o% P+ n8 @3 s
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
2 a* m, z- G% R( c//  ProgramCompare.java         Provided by: DRS7 m8 O3 N, |/ I1 C
//
% l4 o9 `8 W9 Q7 [4 V4 l//  Program shell for Assignment 27 u" d8 q6 H7 K( F, J
//
( Q- ^" r' ]9 k2 @( W$ K2 }//  Compares two text files line by line# C, t- G6 i! }
//*********************************************************************
0 s" I) f+ }! Y( _  F" H: ?( `/ [4 X: M; W3 M
import java.io.*;, K" P" b! {" C4 X! f

  |. ^" M+ Q( \! c% ~* q' Fpublic class ProgramCompare- R( F, R: V* ?9 b; \: [
{6 g& Q% P4 s/ A
        //-----------------------------------------------------------------% c2 [9 Z/ P5 L/ O
        // Constructor
- A+ _. W! k7 X1 t. K. _% @/ h        //-----------------------------------------------------------------% u* _9 X! D- c0 {; q! A* f2 w
        public ProgramCompare()
; B3 n# ~  U) ?% X( m        {
+ I$ o( Y& W" D) s) E        }$ p  S8 {- }7 Y& D* H2 E

* G( t0 f$ Y3 ?) }        //-----------------------------------------------------------------1 a4 z$ m7 j0 v" ]1 C
        // Method for testing that class has been reached* Y* N& p& I) w5 `9 x! ~7 |+ j
        //-----------------------------------------------------------------       
7 \+ N( S& E  e  ^( {$ }6 F
: D! R+ q; I# t3 @$ Y% a* u& V1 b        public boolean ProgramCompareReached()         - v1 z9 |1 J7 a
        {
- ^4 _5 ?, y' _; N7 |  D8 Y& [      try
5 f' K  ?7 H  F; F2 [   {         5 o0 X# v/ Z) X* V
                       
/ V2 ~3 L. q+ A3 B" V                //********************************************************************
$ U" n' a8 Q% Q! n                // Try-Catch Statement is used to handle exceptions - such as file not found * A3 y) ~+ N& `: {0 N! |! C9 }
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ a" F6 m) f+ ]& O                // For more information see page 534 of the textbook
: f( @1 P1 n* N& P2 h# C% X                //********************************************************************. t) w5 V- w2 B3 \9 \( }
                     2 d0 Q( d$ o* O3 m( P) ~) h
        }
0 ^# Z" i. f) t0 l             catch (Exception ex) // Exception caught here and message displayed to the screen 9 z* |+ \  R! r+ r- u
          {
. C3 t* g/ r! k, K                    ex.printStackTrace (System.err);9 d" }$ r0 h! o* g+ ]: a
           System.out.println ("Error message goes here"); // Replace this error message with your own          . O$ q9 `* ^, S/ z7 r2 {7 v0 _
        }
' S% C+ q/ I! C! P; ~                return true;
0 N9 I  S+ @1 u6 C, [2 i( x        }( P' Q; Q# ~1 W: \0 v0 s
& V# N6 @3 k" z! d4 w
} // end of class ProgramCompare
$ n) h6 s# F5 Z6 G  m' z. G2 O8 Q* |* Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* ?# V2 X: T7 e" O//  ProgramCompareMenu.java    Provided by: DRS
: T1 o9 A& l& C! j) O4 \4 N9 Y; H//
# z& a2 v& K# [# d8 @6 d1 l; n//  Calls AuthorisedUsers.java and ProgramCompare.java0 d4 X# i2 O8 @, }
//0 K9 P9 ?% \3 H+ O- R% i4 N: W
//  Driver shell for Assignment 2.0 }- h1 l( O' D2 @0 v
//********************************************************************2 M' h! X; N+ S
- H* Z0 y* A% h3 B4 K) O0 C
class ProgramCompareMenu
' l0 T. M- M0 Z4 U: G: m1 @+ O{3 i: f4 t; l5 o- q
    public static void main (String[] args)
; t, g3 z+ e8 f1 d            {
% T& f. J7 G8 R9 l# h1 ~                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- r" _3 r8 A% _" V3 ]9 K* w3 C                ProgramCompare reached1 = new ProgramCompare(); ' F4 ?0 e7 B+ v
                AuthorisedUsers reached2 = new AuthorisedUsers();        ; g6 d; F* f' i6 I1 N7 k5 ]- ^
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" ~7 f1 q& F. {                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 b) s( W' ?4 a        }) \& B: l2 g8 j: J/ d1 Y) |: J) D
}// end of class ProgramCompareMenu! D, k0 g; G" W6 \0 T! X; r* J

- ?& R* [$ S5 V! j$ r" b//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ ~" f6 N; b) e3 c  Q4 i- B3 N' h
//          AuthorisedUsers.java          Provided by: DRS  j9 P/ l: j" H, D* {5 K8 w
//               
# z$ K# r8 a- z; Q0 W+ u5 v5 L//         Program shell for Assignment 22 g4 b$ A+ T# J% S- i# w+ e
//
+ U2 k9 X" D. d! h8 z+ x# T% z4 S//         Represents facts about an AuthorisedUser
" O8 h6 V7 c5 |2 a//********************************************************************
+ X0 J3 \, k* s$ |8 t# I. W% e; Y9 m; B
public class AuthorisedUsers/ n, c6 T8 V. c8 p
    {. r& p& l: _- u7 ]6 l

& f( f/ F- _( q3 j; E# y        //-----------------------------------------------------------------
- N$ _  X! }$ _1 ~8 o6 D5 o        // Constructor. r4 g, e3 Z7 k4 ?% y3 T0 h3 V. D
        //-----------------------------------------------------------------& F0 c  O: D" j! R' J8 M
0 B" T- L; C% ?1 _. A
        public AuthorisedUsers()) ?# B8 h2 W! M8 f8 p: g
                {8 o/ C+ g; O7 b" X; K! y
                }; ^* I2 l% W) ]5 z* y

! \, J. W3 w3 w3 m/ a' f- X  R/ J        //-----------------------------------------------------------------
" t6 ~& \0 Q  c! z% t; q* s5 x4 K# [        // Method for testing that class has been reached* Q) g# h) K4 l" M+ W6 |
        //-----------------------------------------------------------------       
9 ]- v6 Y- A- L2 y# w( Z        public boolean AuthorisedUsersReached()
+ q4 v' ?: F8 @                {! m9 }2 f9 _: t% R9 u7 S
                        return true;                       
! U5 \0 T4 x: h0 h2 J                }
) S8 W: M0 Z. [7 t# w                . F1 w; w% X: U6 @; j
    } // end of class AuthorisedUsers
8 t2 w5 b& Q* s0 r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming' b9 O0 A# q9 }6 P$ W9 `) u% {
Shanghai - 2007
6 R& \0 _" I: k8 j+ nAssignment 27 T8 T; f1 ~- @" D9 p3 \. P
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)
6 R; O+ u& p  o) c6 E5 a2 K1 O$ v1. 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.! B: Q, P6 K# p( ~
The staff must be able to:5 o: X' D9 Z! r$ B0 F- Y9 Q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" E/ p( |7 B/ C+ f, Q/ n+ X) C- w1. 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.
9 g2 K$ Q: y  e; G" N2 `) Q The interface should provide a menu so that the staff can:
7 B$ C0 W. R; ]" pa) Enter the names of the two Java program files to be compared
. Q* Z4 d$ U- j9 J" o8 c3 d5 _ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 i0 ]; ?6 L  v2 S. k, W8 j: v9 ?
** 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).
: ^6 J% u0 y3 n, `BSA104 Business Programming – 2007: Assignment 2
! _4 J( M$ N& D2 ]Page 2 of 5: s( V& j5 Q8 \4 l. D
b) Print out to the screen all the lines of code that are the same
' h) ~5 n; r2 b+ \& e+ D: h! B Include the name of the file and the line number of the code being printed for each of the two files
4 r4 }1 [- ~: \8 w) B/ {% pc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared$ l+ d9 l# ]/ O( z9 a" m: X4 D
 the name, username and department of the user+ M/ y* a) ?& P) o0 {
 the statistics of the comparison
$ l3 V" M! c5 H6 Y- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different; E/ n, u0 P4 O! q5 h# d: D6 N2 `
 the recommendation for further checking6 K  N- ~. p& j5 m0 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
2 U2 @0 c# n. `2 ^# ~ the names of the two files compared9 m* ^# t, X& l" o
d) Leave the program (exit)
1 N/ \) \9 j5 R2 s8 s# aThe ProgramCompare class: (Total maximum 20 marks available)) `6 p1 s# C9 z5 u5 f
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)
/ {6 k2 B9 N: m& N# w" wa) provide an error message if the files are not found or there is a problem opening them$ _4 M- ^9 `4 l8 w
b) compare each line of code
7 [  }0 A) K- z1 W. [" ec) print out the lines that are the same- I3 o* A" c' ?1 q, F
d) count the number of lines compared / lines the same
; T9 k8 e* ^8 wThe AuthorisedUsers class: (Total maximum 20 marks available)
# u; ]" Y& u4 `0 y2 ~' o3. 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)5 z3 T! \+ b5 k) ~
4. Provide methods to:- S# J: v$ m& A
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 match0 K! i) y3 O) j/ v3 @; x8 @, h4 f8 O- d
b) return the name of the authorised user! \4 I  {: ^9 H1 g' u
c) return the name of the department of the authorised user1 D" A4 R# y/ m. u* b: v$ n
Individual Data (Maximum 20 marks available)
- {8 ]( R' s0 _; 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.
8 e5 D9 l2 B# U* ^4 wDocumentation (Maximum 10 marks available)1 J! S6 l7 p, K
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.
% \. h5 m' y! ]" q  RBSA104 Business Programming – 2007: Assignment 2
  I. Q7 s; p1 w8 kPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 K* [5 n* e4 G6 Y5 P2 h
不过你要翻JAVA的类库说明。你有下载没有?6 _; r8 C% Z% U" I
查询关于对比的函数。貌似关键字是contrast,还有compare
& ]9 \- z8 a1 v% [8 x$ |
  I$ g0 x0 O3 L3 Y' _0 m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 b$ U) G9 w9 A9 [
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' G; x" Q- L, B) y$ G
可以下载到的 是 jdk-1_X_0-doc' u* ^# X2 o' P. N( ~, c

' w/ I+ A' B! n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-21 08:05

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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