找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1746|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' ?) U% R5 A- u& K8 n+ N 9 l& d3 A6 C/ H6 ^9 D+ p
回复

使用道具 举报

 楼主| 发表于 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 i" X  x2 D, h. d* P7 I//  ProgramCompare.java         Provided by: DRS9 O( o0 I* a0 [2 s
//
4 y! V7 P" W. H//  Program shell for Assignment 2% H$ H3 v- n; d3 \
//
" v, ]5 @( r$ j4 Q8 x9 P! l9 |//  Compares two text files line by line
' F4 N, C: L" D# q2 b, u$ Q- r//*********************************************************************
" B+ g  M( h" W. n. P0 O3 U
: R. H7 e; X: B% h1 f; Dimport java.io.*;5 [, }3 K$ f  b0 M
: {# i. h" W2 K" v0 I1 g
public class ProgramCompare& S- U0 y& _7 L* D6 z
{
) E1 b8 K: W' }& ]  U        //-----------------------------------------------------------------' Z9 D$ O+ F; Z/ C" k
        // Constructor  k9 }2 M. `- W, i7 J7 d
        //-----------------------------------------------------------------' K4 O0 }+ G, I8 y- k7 w9 w% s
        public ProgramCompare()
4 W+ K# L+ E0 x/ a6 `" _        {
4 D: y3 y8 N7 C' P# @        }1 w) l7 f1 V; K: O& F/ P; C
! s! b: \) V0 }
        //-----------------------------------------------------------------! k. t, s+ V, T2 W
        // Method for testing that class has been reached
) Y3 i2 J6 q0 J        //-----------------------------------------------------------------        , Z# Q" @+ D; B2 f  G

1 H; ~& |' S( t+ m: J        public boolean ProgramCompareReached()        
9 B+ O8 b1 ~2 X3 r& Q" z) l        {
2 F; Z+ R3 u. |6 m6 ^( Z      try # m6 Q# l+ p4 ]$ r
   {        
6 Q$ E# F; G9 S& U. O& a5 X                       
! ?8 a( b; N8 ~: w" {1 u                //********************************************************************
# h; G2 e4 \; f                // Try-Catch Statement is used to handle exceptions - such as file not found 6 K9 a6 \/ z; i, k9 U- Q
                // Reading the files will need to be placed inside a Try-Catch - just like this one!3 B9 V  L3 r1 G9 A0 F0 x2 O
                // For more information see page 534 of the textbook
$ G. }% p! O" c/ m2 M7 E1 z                //********************************************************************6 w/ C0 @: ~& q/ U* T, ~" a3 p& @
                    
$ o! g; z2 E/ ?0 o' w        }1 H0 @% G- M9 b" R4 E# x
             catch (Exception ex) // Exception caught here and message displayed to the screen 8 ^- u( p1 L) Y
          {
* @8 a; X5 f- B1 n. F" r, ?! b5 ]' M) `                    ex.printStackTrace (System.err);% \$ v# ^4 I% p  b8 e2 E" m7 W
           System.out.println ("Error message goes here"); // Replace this error message with your own          0 i" w) c" S+ `7 _
        }
; c0 `# Y% y$ X0 D' b+ T                return true;- u# Y1 m0 O) j# s2 b
        }6 R+ j9 n2 z7 L4 \1 b
4 y: a$ x7 M) d) ?& `+ a( |
} // end of class ProgramCompare" ]7 Y: o1 g& C# ?. U6 ]
: X. P5 b1 q8 J3 M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  ]) N! i: z. w* u# y8 G. L
//  ProgramCompareMenu.java    Provided by: DRS
, m8 }) w4 @+ ^//+ N# Y! }/ P" A/ j
//  Calls AuthorisedUsers.java and ProgramCompare.java, j, y+ ~. g& v* J# Z1 _
//$ v: c- Z& s6 e7 l1 u) [* u
//  Driver shell for Assignment 2.3 g2 j' Q/ X3 R
//********************************************************************1 M2 o( ~. m4 x6 B0 y
, f) ?- F+ |6 o/ F3 h6 V
class ProgramCompareMenu( X5 O0 H. M4 t( @5 [* O5 H+ W: b
{! p( z: N$ Y: _) U
    public static void main (String[] args)) \" b, S+ E" x* S: c
            {* c4 d) l2 q+ c! m* r! s4 d5 x$ t' ^
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 g# a: N6 Q' R* @9 k                ProgramCompare reached1 = new ProgramCompare(); 7 {! ^- G5 G5 K4 @- e
                AuthorisedUsers reached2 = new AuthorisedUsers();       
1 ?* h( y, k" S' ]; U0 o; D: q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 D- F% v9 A2 d/ _
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 _# g  ~& D' o+ Q- @
        }
7 i) r8 f. N! ?7 v. `1 X& Q1 [}// end of class ProgramCompareMenu
2 A; L- z* f) {0 i  }- A- I
8 i' f- ?0 s. K5 K1 R. i# F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
0 ~" Q" t( r' E# {- }( r//          AuthorisedUsers.java          Provided by: DRS2 q' l! u# N1 m6 n% g" O
//               
: X" e; \6 h& p7 N+ ]0 e//         Program shell for Assignment 2% |" B' S  U9 t3 p  F
//
/ D" \7 I% T8 O7 B( P) d//         Represents facts about an AuthorisedUser& H2 w& x! z' k; B5 K6 p5 i
//********************************************************************8 b1 L9 i: j/ [  z" Y
, k2 F5 [) I/ {( L6 \' k
public class AuthorisedUsers
$ O7 B, p" k6 F    {
- R% n9 Z$ j& C9 g- C+ D
, c, Z; A  w+ \7 r0 ]        //-----------------------------------------------------------------
: n* |8 u/ i8 D/ [& E0 ^. [! y        // Constructor2 I9 R" G3 }' H5 H0 ^
        //-----------------------------------------------------------------+ j5 s9 _. D2 r' U2 p7 ~

' o, o; T3 A& M# m        public AuthorisedUsers()4 D% E' M9 t* f$ I, v) x6 Z" \
                {, Q& Z0 C2 e* f
                }' R5 M* L& W, [5 p9 v+ T% m

4 g. M! B' U/ G, z4 n& T3 C; Q( x        //-----------------------------------------------------------------
  Z1 R. G; ?8 @        // Method for testing that class has been reached+ x! |1 z; H/ |1 D
        //-----------------------------------------------------------------       
0 t% K, d' q0 A4 \5 l        public boolean AuthorisedUsersReached(). x9 Q- L: v: O3 x* f$ _( y
                {
' }$ X7 V! D0 x2 A% J6 `* h/ b: P& b                        return true;                       
1 F7 ]7 h# Q! g; _- d1 m+ g                }
/ t6 d! u( q' ?7 A               
; Q4 d2 |. w# n' a4 X' @    } // end of class AuthorisedUsers
) [# U( }4 A5 \0 U2 n) V5 [6 `" a4 w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 e; s1 W8 d% J; lShanghai - 2007
9 c4 [8 }* l/ _. M( N  eAssignment 2
& M. [9 e8 Z! QDeadline 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)
  n$ E; h5 s$ I$ p' x( \/ a! 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.
9 I6 u! v- a. ?The staff must be able to:4 _" L# C6 H+ _0 j! x
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ W5 w; J, h' x: n
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.. |4 m2 n* R: F
 The interface should provide a menu so that the staff can:
( l4 K' ^1 b7 }' C8 j' O6 sa) Enter the names of the two Java program files to be compared
0 D' t: i- m/ ~$ D, E. y- {1 y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 c8 I% I' g$ ]2 N3 x( o) e- X% j/ }** 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).
% E# r: v0 H% jBSA104 Business Programming – 2007: Assignment 2+ Y( Z9 p* [5 r. b; Q1 s- x- N  i
Page 2 of 5  M6 T& r6 w' x' I. _7 |0 e9 s
b) Print out to the screen all the lines of code that are the same
' [3 W, y7 [. Q4 ~# ?2 g" F1 ?% w Include the name of the file and the line number of the code being printed for each of the two files
& n% o! Y' h" F2 d9 ?+ N! K/ f. X7 Sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared- p8 b1 Z7 j- d  S: u8 U3 T3 {
 the name, username and department of the user! t1 `' Q1 O7 z! q- G. j
 the statistics of the comparison; e- C, C" }& q5 n
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% O1 h) ]0 j+ F the recommendation for further checking
- l% X8 [$ T1 J- 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% z: Y' G8 `" ?
 the names of the two files compared
* Q* [/ ^5 o0 h# T( p3 g+ Rd) Leave the program (exit)6 R' F- Z1 L( e3 c1 Q! o. t  ~$ C1 Y
The ProgramCompare class: (Total maximum 20 marks available)
( W8 ~6 o: }4 o  Q  ]5 ?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)
, E& E/ G( }" Y! Ca) provide an error message if the files are not found or there is a problem opening them
3 g- t+ W( E% D9 Kb) compare each line of code
( s5 z! h' P3 Z# k7 ?; f$ Sc) print out the lines that are the same, u# m" w( q0 u( Z) y7 P, j
d) count the number of lines compared / lines the same# \  A, `+ F+ U- l- D# }9 C
The AuthorisedUsers class: (Total maximum 20 marks available)
+ I  X+ v7 I9 D/ u. Y3. 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)$ q, _6 x4 p4 A# P
4. Provide methods to:; D' q! c  r7 K- E
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
7 b( F$ \% |! a' J2 O4 i  I% ?, z  zb) return the name of the authorised user  J2 v9 i; m! H& p  E
c) return the name of the department of the authorised user
* r& w, g4 X8 }9 w- zIndividual Data (Maximum 20 marks available)
8 p4 {* M" G8 g; g: D5. 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.
& s% ]) q, s" _# @. ]1 I) bDocumentation (Maximum 10 marks available)/ Q* `8 i: V' V9 J2 m7 R( N
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.1 w4 d3 F0 Z/ V' S
BSA104 Business Programming – 2007: Assignment 2* m- q) x6 o  U- d" Y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# E# ?: r2 {  H% F& |7 E4 V
不过你要翻JAVA的类库说明。你有下载没有?
3 e, [0 K; R9 P# N5 Q+ K: K查询关于对比的函数。貌似关键字是contrast,还有compare
7 f5 u/ d6 N- d: z- z) ^& a1 s1 q& Q! C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
. r! G. Z3 O4 t4 ]1 Z5 Z痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* S, w$ |8 q1 d5 o1 |可以下载到的 是 jdk-1_X_0-doc
1 P# K( g: C4 G8 [; G3 a( B: m- P' i2 A* Y7 D) O1 K, p- P& ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-22 03:47

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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