找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1450|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 Z) B0 ~; e! k% r$ k. Y5 ~' j# o5 i7 V' l3 q9 w. B, l, v
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; [* r$ ?& a; L: u//  ProgramCompare.java         Provided by: DRS5 ], w# b2 ~& F/ ^' h/ U9 T
//. O- S: D/ H( k" @/ M! r4 u
//  Program shell for Assignment 2
. |. @7 l% K7 g//
3 |) I# g- U! ~$ [; f7 f9 a//  Compares two text files line by line7 F. z  h5 y2 X# _4 G  q
//*********************************************************************
' e; z0 ?* a" `- U2 T# U7 z3 J1 y7 S3 B9 z5 U
import java.io.*;
: V2 N. p2 ?8 j+ X, t$ f4 {$ E8 ~
9 e* f' w( ?3 m4 ?public class ProgramCompare4 v) ^- W( Z: c
{6 u! P7 y3 i, D6 r
        //-----------------------------------------------------------------
' \: f6 V$ S8 ^" I" S: z4 W' ~        // Constructor
( s" T$ Z" h, x        //-----------------------------------------------------------------
0 y: h9 @" L7 ?1 m3 ]  B( D        public ProgramCompare()
( L$ X& c( ?8 Q" p4 B9 p) f2 q        {( Q7 L* D: ~0 V+ V
        }, _" p- N0 R' [! C
. l& l. Q/ u1 F% e+ |
        //-----------------------------------------------------------------
; x. D. ^$ n0 |$ D; _  i        // Method for testing that class has been reached' J' U3 J8 V- m2 X; O
        //-----------------------------------------------------------------       
3 C1 T: e; h9 Y2 g# H2 a, A
0 k2 T& q7 p5 M: z& e( H$ n% Z        public boolean ProgramCompareReached()         2 C8 u% C4 F7 C
        {  T) A  ?! P4 M& C0 A
      try
4 ^  t  m) T: z8 A' |   {         2 ~& G4 r+ R2 K$ u' V
                        : e7 ~( t: }! ^: F! f
                //********************************************************************
" b$ d9 b" S; d% r2 Y: h                // Try-Catch Statement is used to handle exceptions - such as file not found 6 f5 D- {; ^, M: u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
& I, K8 v7 U4 R- l* l                // For more information see page 534 of the textbook
* |* Q+ j( j# t0 t                //********************************************************************
4 G' G& W+ q# X+ z: R; y& l                    
  |5 w" ]7 |* o8 Y5 A% }8 J        }
* [) w5 x2 U' D             catch (Exception ex) // Exception caught here and message displayed to the screen ) [1 o6 f3 H2 s
          {
/ b8 i- d6 c2 c                    ex.printStackTrace (System.err);
, M3 S! v! w! |( K6 o           System.out.println ("Error message goes here"); // Replace this error message with your own          ' N, Z2 S! D8 S' r9 ?
        }0 R) U$ \3 p  v9 f9 s
                return true;
  O! g( ~* N. |9 Q$ t0 Q        }2 s/ Y2 Z+ Q" d2 [1 F, d
5 [0 g( K1 F$ G8 _/ R
} // end of class ProgramCompare
4 `; e9 K; M" F1 e
; C1 h+ A7 w2 G1 m& {- K+ X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' Z1 J2 Y) s, T+ L7 S( z
//  ProgramCompareMenu.java    Provided by: DRS
- m8 g9 \7 D1 x# t) ~, }//
/ Z0 P: Y1 P2 ?% C+ j//  Calls AuthorisedUsers.java and ProgramCompare.java
2 D6 f) C* }6 F8 x: H//9 b1 }) Y- @" |
//  Driver shell for Assignment 2.1 A' S3 q- W1 Z' J
//********************************************************************
% ]" u5 {& X: V  ~, |* z' B; ^1 h+ Y
( ?# g, b9 j% U7 D5 x! qclass ProgramCompareMenu
) ^; q; ~7 c0 D2 _{
# Y% F+ i* k. c# W7 P  W+ j    public static void main (String[] args), S) Q; o  r; f; P  ?
            {9 @# G. ^1 C+ b8 B: s. R7 ]6 G
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 E2 ~6 z1 c* V                ProgramCompare reached1 = new ProgramCompare(); . F; a+ j9 Z" ^/ P& \! Z! P$ X
                AuthorisedUsers reached2 = new AuthorisedUsers();        3 [* E+ h* m5 ~2 y8 D5 a
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 f- D/ |- S) l/ ]1 c* w& n, {7 K                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + c# Y. P! o, X% [
        }
- O6 m  z* f' k1 h6 D& a}// end of class ProgramCompareMenu2 r% Q8 y" B$ x9 K: [: A
0 P' }7 e/ l* W3 v
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" ?0 u6 S/ U! Z9 }//          AuthorisedUsers.java          Provided by: DRS
0 o- K, s% p; W//                0 N1 H& [( q+ T
//         Program shell for Assignment 2* I: Z. Y, O2 r$ w4 |' V: w/ u
/// ~0 G8 Q! O5 W. N' [- u
//         Represents facts about an AuthorisedUser; \: a+ u3 j5 p* `1 @
//********************************************************************
+ `0 P. ?* q7 t1 ]3 n, j. ]  L8 {2 n+ @0 `' j0 W% k7 H
public class AuthorisedUsers
. n) W" _) W6 [! @4 L+ n( [  V( o    {
- L7 n  F5 [! P$ F, G! `% p% Y! [0 t: w9 k( a
        //-----------------------------------------------------------------
5 d2 P- f6 i# ~( }( Y        // Constructor
1 s) L9 R3 P+ `6 u' ]* \        //-----------------------------------------------------------------, [4 ?3 p9 l" Y9 {4 k

* Y$ T. d& w7 t4 \1 Y4 A        public AuthorisedUsers(): P0 t: E; t" o6 m& n$ p% q' S7 Y
                {4 v1 j% R& q) h+ s! w5 P5 `
                }
, o3 }; g  C, t, A& T" E8 i8 Z- s, h, v% V6 V- ?
        //-----------------------------------------------------------------
1 n  ]" d3 K' ?        // Method for testing that class has been reached4 ^6 {: c( q7 d* `2 ?9 z/ I
        //-----------------------------------------------------------------       
. f# m/ F; ~9 y7 a        public boolean AuthorisedUsersReached()" H% z9 T9 H4 J0 e' O! w
                {
. N0 U/ v% @* x3 s6 S! O% t- p' E( M                        return true;                        ) y9 D& C2 ^. y- x$ M- w
                }$ ^$ A3 m7 ^5 u/ M
                ; `% ]6 v% h, n) I  D
    } // end of class AuthorisedUsers
" P2 c" v$ ~- s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 q1 x# c0 O6 d) t: ^
Shanghai - 2007
) b+ Z; H3 t& ^6 _' }% TAssignment 2' P7 J4 W9 D5 {) t) i: L' Q* o6 }
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)$ Q/ z5 P3 Z/ a6 `
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.
2 P. J/ N% D- ~6 v$ JThe staff must be able to:
0 e, A& ]( p1 n# w; S( y! u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: e2 J! u! k* |9 a1. 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.
8 P0 s  r, Z1 N" | The interface should provide a menu so that the staff can:) _, O4 `( H( v: ]7 T
a) Enter the names of the two Java program files to be compared
0 W9 |$ _" T7 B, Z* ` For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  `  [' W& a, m$ W% \* E$ x* 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).
! E! j; {& d+ ~) d9 pBSA104 Business Programming – 2007: Assignment 2
- B& s# x3 v" r* N( O' }% IPage 2 of 53 z2 y, |0 ~) j1 w# u, q5 z8 E
b) Print out to the screen all the lines of code that are the same
: d2 j; e4 R/ B5 G+ W Include the name of the file and the line number of the code being printed for each of the two files
0 s- C+ |: W* Z# v4 {& Hc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 q$ n+ j% a7 l2 L' M. W+ p
 the name, username and department of the user
8 Z& a8 ^. A& F% Y1 ?1 @8 M the statistics of the comparison
5 [# W: F$ A2 J6 {, M* i- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) l; V2 @* ?/ r3 K2 d9 `# f, v
 the recommendation for further checking
' \9 v8 _- R5 ~- 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
- }: Y! F4 w7 M; j5 y  V the names of the two files compared1 u3 s+ m) W5 ]) W! p
d) Leave the program (exit)
' c! g$ m3 }! W% u% pThe ProgramCompare class: (Total maximum 20 marks available)
, D( _- o. d0 E  {$ Q* S2. 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)& K) E( a# J1 R* K" ~2 d" H6 W
a) provide an error message if the files are not found or there is a problem opening them
/ `& |1 k9 ^5 |- v4 K6 }6 t. Zb) compare each line of code
6 h' N! l# d; V9 l; fc) print out the lines that are the same. [5 \" X4 _% u5 G6 z( }
d) count the number of lines compared / lines the same! G- S9 y4 L* ~0 S
The AuthorisedUsers class: (Total maximum 20 marks available)
2 V$ i, R" A8 f8 v: v3. 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)- c# D8 G! e1 b& a# @
4. Provide methods to:( f0 a* h: s) W; [3 X
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$ N) R6 q5 i" G3 l5 K9 a5 {
b) return the name of the authorised user$ s' m# c* |- J
c) return the name of the department of the authorised user! I& {8 g5 e/ Z- X4 G# c  X: e
Individual Data (Maximum 20 marks available)$ K$ S8 y' J. {8 \
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.! O/ a6 f' c. j" o$ i
Documentation (Maximum 10 marks available)& y4 g- C7 }) W4 B; f4 ?8 S1 H8 a& F
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.+ n! Y& H' n7 w0 m+ u
BSA104 Business Programming – 2007: Assignment 29 `$ f  G7 N- Y1 i* B6 S
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 h/ _/ Q4 j  p! n+ v- Z. r不过你要翻JAVA的类库说明。你有下载没有?4 G# t( e6 e4 B# S; [- g6 R
查询关于对比的函数。貌似关键字是contrast,还有compare- i" O) b" @% W7 F; J1 i$ v
4 q3 y# X! ~) J- X) h. Q5 ?2 v
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -. g" m- O' I- z5 @2 e
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
3 U' f: J7 P: f0 z可以下载到的 是 jdk-1_X_0-doc
. Z$ y2 q% w% t. ]( g* G! R* u) B0 ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-11 01:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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