找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1002|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急) B* Z$ O) o+ ^ 2 f5 B9 H+ [0 f7 U; i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************5 C* J3 u$ X: N6 y0 t: v# [. G
//  ProgramCompare.java         Provided by: DRS
7 {! D% w( G4 D- q4 R1 i//
/ |# k2 A: U0 Z( o- `0 C$ [4 m. y//  Program shell for Assignment 2& }9 s! U1 h9 A3 l' n
//
- t3 l" i+ `! R//  Compares two text files line by line
; V2 C1 }' Q& w- r, _$ G//*********************************************************************
* r) d) h8 v! d3 f4 I0 g
* `* U# ^- m. z, H& N, a+ a1 }import java.io.*;9 |* z/ i: e8 s
, Y8 o  B" _) h( x/ w
public class ProgramCompare0 {" n  Q: Z- A! a
{: j) ?& L! b, O. k+ P6 w6 t
        //-----------------------------------------------------------------
) h4 ?6 N. C6 X: s        // Constructor
" [) S5 U# z" Q5 R- [- f# r% e        //-----------------------------------------------------------------
# o; S2 ?1 N' E) V' f5 r% U+ z% ]        public ProgramCompare()- ^4 h2 {0 Y% b- u
        {1 Y# K+ a1 c. }7 t
        }
: r+ v9 r% U1 g9 p, _- [. Q
. L) {) }6 p8 a1 E/ q, T        //-----------------------------------------------------------------
: Z/ z6 y, v+ H        // Method for testing that class has been reached
5 _1 Z* U4 ^8 A+ e- @; H& `% J        //-----------------------------------------------------------------       
/ ^; `6 k, v  O9 A) G" p2 H, h
1 Y; U% A' G3 t' h/ w& g% R        public boolean ProgramCompareReached()         . D0 _" y% U- p4 c4 r# q) L
        {
9 W' ?+ d, e: y* E6 U& {      try 9 E4 S9 {5 ]: X9 {# U. @  J
   {        
8 w( i! S9 E* k6 I. i                       
5 J+ R9 `/ n' r4 V  Y) i                //********************************************************************; N0 c/ L% _8 w
                // Try-Catch Statement is used to handle exceptions - such as file not found & w6 x  b% ]3 E" ?" R" G) [7 o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 Q9 L- [5 m# C2 [* \
                // For more information see page 534 of the textbook
6 F" f6 G! Z8 A+ P3 m                //********************************************************************
; @! {: x; U2 }  V                     ; }" r8 R' ^6 d) F
        }
& c* t4 z2 O# i) o             catch (Exception ex) // Exception caught here and message displayed to the screen
, u2 n1 q* `& h( Q4 [  x* @" n' G          {
9 A! F# X* c) W5 M- |                    ex.printStackTrace (System.err);4 ^, G) V6 G  J& E5 G  V
           System.out.println ("Error message goes here"); // Replace this error message with your own          5 f' U" ^# s( u- |
        }
% f# r: E  @0 g1 F+ |                return true;  ?0 |' K! @, J! J8 E
        }9 l' V3 \8 f# Z5 N/ w4 y
, b+ Q' N& \% t2 y" W3 w& y& ]; t
} // end of class ProgramCompare1 X  b+ V4 L" Z
( a5 \; G  f$ G* S" o4 A3 N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ ?: m) G: e+ s$ r; B
//  ProgramCompareMenu.java    Provided by: DRS5 W4 P1 x' ^6 ]2 t: E1 T
//
' c; D( s0 o" G5 ?: M5 E2 x" F//  Calls AuthorisedUsers.java and ProgramCompare.java
. {" ~6 x6 l4 G, }0 |5 M# o//
) W( t5 w- A+ O0 n$ Z: P$ m//  Driver shell for Assignment 2.
8 |6 n2 T, x+ q+ \- J7 F+ W//********************************************************************# `- K- A7 K! p9 C; P) ]0 F

5 r  h- N; }1 m0 sclass ProgramCompareMenu9 P, M, `! L/ S7 n" M4 l
{0 v" u/ ?  F9 R& I  A, U) B" w
    public static void main (String[] args)- e; \  A" u0 E
            {
0 Z" b# l4 H9 j' [                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 Y2 v: W' K# I. C; m/ m                ProgramCompare reached1 = new ProgramCompare(); 7 G9 ~% K( |3 d8 }, {
                AuthorisedUsers reached2 = new AuthorisedUsers();        . B7 Q+ d3 x7 R/ \6 L0 O
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());% x% |0 k7 M' W( H% |3 }* O; U
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , S: x  w: d" e
        }
8 ?+ U3 s& a9 u: V. t}// end of class ProgramCompareMenu
. W: I# }. V0 c0 ?3 Y0 S, Z! D+ D7 D% v& A3 R8 R8 r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ M7 k( [$ V& S" D
//          AuthorisedUsers.java          Provided by: DRS
  g8 F9 ]! e# P* r( j8 a//                4 S0 z! |! e% A$ Z" h6 f, a
//         Program shell for Assignment 2
0 L, l( w) K5 e0 S//
' S  w2 b- t# V5 x//         Represents facts about an AuthorisedUser3 w8 ^; ^) x* ]: d! m# D
//********************************************************************
# R% x$ n7 ?, s, t/ l
' D) O9 C8 j; jpublic class AuthorisedUsers
: Z7 t1 r" |/ Z2 k$ V/ q    {6 Z2 P: k9 g( U5 B

2 x6 I2 w. U. I4 ^, o  h5 `        //-----------------------------------------------------------------
) [9 O2 o, Q# D, _  R; L        // Constructor" Z$ d$ `' y3 V+ i
        //-----------------------------------------------------------------
% z/ f' W: ?  y) G( m2 K% c$ F9 h% x" p1 C) E
        public AuthorisedUsers()9 b: T4 m7 a+ B. r; t
                {8 w! @4 N$ i* K+ P' v+ o+ _; `
                }& e( U, @# r9 Y
6 n2 r, B! l2 T( D4 o6 }
        //-----------------------------------------------------------------
. R% Z4 `5 H( f! B/ r8 E8 G' x        // Method for testing that class has been reached
% A0 R8 V' n6 G* [' Y9 q. t+ u        //-----------------------------------------------------------------       
2 p7 ^0 F2 n# m* C* R" V5 s+ m$ j        public boolean AuthorisedUsersReached()
% A+ G4 [7 ]) m- i: x( D                {
. t: {- V% M2 n( W8 P" m  t* B                        return true;                       
+ [/ o6 U7 |2 b! \                }( v8 E& y- S$ E- ]$ U
               
; f& g- g- \# e; `9 J, B    } // end of class AuthorisedUsers
% v8 d! v% w( N4 k% P3 L) D; t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming* G$ Y" B/ B  q6 ?- C) N
Shanghai - 2007
* G( y) N! r  L6 jAssignment 2
2 g* S  Q( [: L7 Q! c1 @2 FDeadline 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)" o$ o  }' ~6 A& k& [7 {
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.' k; f, p: C0 S6 \. ^% k9 c
The staff must be able to:
: s# |% ?8 g2 d4 i" P Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, N$ O: ?" e1 v7 r9 i! H# P1. 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.6 q- _2 X0 `4 h( t$ H% }  A
 The interface should provide a menu so that the staff can:) h. I! d2 `3 |
a) Enter the names of the two Java program files to be compared
/ T) }4 l1 G/ E. c& T' t For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
; A' u0 o% }; k, F** 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).: [& G8 g1 X+ }$ u% M/ n* E6 f% N' \
BSA104 Business Programming – 2007: Assignment 2
6 o0 t0 c6 K3 I" l# Z; b1 i2 LPage 2 of 5' S9 }) c! X& q& f3 x; v
b) Print out to the screen all the lines of code that are the same: n7 z7 {4 A6 D7 Z% \
 Include the name of the file and the line number of the code being printed for each of the two files( A; a, w( Y( e: T
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 M- P9 n2 Y6 J' O" q' R the name, username and department of the user
& Q" b5 d6 K) G the statistics of the comparison
2 n* Y7 A" f* L6 y: h0 v- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different' x# _/ W+ H- f6 \5 v: W0 ]  I
 the recommendation for further checking3 N* G7 v, a& @' 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
9 h. h8 {, _" O1 Z the names of the two files compared
$ Q0 v6 ?, ]' R4 W1 d( ad) Leave the program (exit)% D( u/ N: m8 O* t+ _" B
The ProgramCompare class: (Total maximum 20 marks available)
7 E8 [. c. K, ~5 S; u* D2. 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)
) _1 u5 j; K( W7 Ha) provide an error message if the files are not found or there is a problem opening them/ I( H; b1 D) P7 v" X( ~
b) compare each line of code( W- f! U2 O: a/ ~. f  J' x
c) print out the lines that are the same3 d+ I; ?" S% C8 q9 w- o
d) count the number of lines compared / lines the same
: d( @: M: ~: U+ n9 DThe AuthorisedUsers class: (Total maximum 20 marks available)
9 w& w9 _2 e: z3. 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)
2 b4 l, |; Q& C( ?2 I, B# `# T4. Provide methods to:
* y3 j# S: w; ^: C& G: |$ m+ Va) 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, m  [3 ]! q; V7 ?. `' u% c$ o
b) return the name of the authorised user
( {1 x0 O) s* G  |+ B  b0 N" uc) return the name of the department of the authorised user" n2 ]0 f3 x3 b* K- W
Individual Data (Maximum 20 marks available)
; A+ N/ T2 r. J& Q  s) f3 R2 P0 x: j5. 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 M2 p- _% @4 N; wDocumentation (Maximum 10 marks available)
: h% J/ v8 b  y' j6. 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.  d( ?# E) V. O2 H
BSA104 Business Programming – 2007: Assignment 2  ^6 g; \6 n$ I' `6 g& ^" F4 {2 V1 M
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: B# [, l" S' G% i& u! ^. T
不过你要翻JAVA的类库说明。你有下载没有?9 ^. S/ x8 w3 {
查询关于对比的函数。貌似关键字是contrast,还有compare5 @' s* A* H+ C$ a# W$ ?% @

6 V+ J. H/ i% D3 Q8 M. M[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -; L- Q$ ]* `+ l! n. u8 B! J) L; T
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。7 S0 S6 U0 J9 X0 {& {/ j
可以下载到的 是 jdk-1_X_0-doc
' R( D: Y9 {$ l2 x6 M6 |/ E4 u9 O7 H& k# G
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-7 08:25

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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