找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1451|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 ]5 W/ B9 t$ o1 Y' Y- L, o% Y 3 a1 ?) t+ A, }
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
" X3 Q# a8 X" v//  ProgramCompare.java         Provided by: DRS2 P5 q7 o9 K: D2 a7 ~
//5 a& W* T3 b2 m
//  Program shell for Assignment 2" R# @% D$ h7 I9 C
//1 ?/ j8 s; Y5 P+ {
//  Compares two text files line by line5 X& i# o4 @" \$ ^' G  G- m
//*********************************************************************. h' m1 f; P& k; W4 e
1 o/ D6 v4 H* x0 H. \# K
import java.io.*;
! R& `" V+ r# \% W6 _
% o& @- ?0 T  r1 H5 i* apublic class ProgramCompare2 Z5 Y  g( e* a) d
{
, u2 L# W. q& A  M/ w. u3 a        //-----------------------------------------------------------------
: d' d9 c7 Y+ C2 P* b4 {: I3 X- O# l        // Constructor7 @1 L  c1 Q: M. q# Y8 w
        //-----------------------------------------------------------------
0 k$ p9 d6 ^% z5 m8 O$ O        public ProgramCompare()
& ^9 A( T6 }8 R( Q1 Y        {* o7 ~6 y# Q1 Y/ T: O5 r
        }
9 e: q. W( e- L9 Z1 J9 t4 X% N9 g' {2 p" y. V" g" W
        //-----------------------------------------------------------------8 y0 v+ J: s4 _  z% K+ `9 Q* d0 S0 u
        // Method for testing that class has been reached9 `+ V3 |( E2 O4 }5 D5 I6 D
        //-----------------------------------------------------------------       
5 m" O4 {) P8 w: f, X; L7 M* k; l! h6 p; r. n: n" R$ _
        public boolean ProgramCompareReached()         5 B" |$ j4 |( ~( s' n5 @( P9 t4 V
        {, v# v% k* R+ N, z' p
      try
5 |5 H5 Y- {. W4 @& d: l6 ?   {         : V) R* ~- |/ d2 d
                        7 [; v1 R. a8 o% a# f# ^
                //********************************************************************
7 S0 ^2 d2 E0 m2 f5 o7 i  L                // Try-Catch Statement is used to handle exceptions - such as file not found
0 D2 z7 {0 W7 N8 e! S+ ^. Z                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ J+ T# R% m8 A! l% |                // For more information see page 534 of the textbook
7 \5 `0 D* \# v0 \* A4 U, U                //********************************************************************
, @; ?4 M' @; q$ ]1 E' n                     % n7 {% x8 |4 y- L/ l. w4 l
        }
* p8 u; ?! k: Y& v             catch (Exception ex) // Exception caught here and message displayed to the screen 2 B9 |6 x7 M  C  I7 x, ?
          {: c* \& f  A" F- T- X
                    ex.printStackTrace (System.err);
" F: Y+ B" ?/ K           System.out.println ("Error message goes here"); // Replace this error message with your own         
) H4 _: U1 i- E8 @        }
  M$ _9 U8 Y" V5 A9 f5 O                return true;
, |/ y+ R8 w  c! }        }/ t8 F! z& i. S" v

4 e2 `0 x1 C" T9 D+ `3 ^} // end of class ProgramCompare
8 W: r) y& X/ M" J4 H; G
* c  M7 I7 p9 o6 x" n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 b1 ~) _# g: B$ ?" J' M1 }* k//  ProgramCompareMenu.java    Provided by: DRS
/ |8 b; U. g8 ^6 b2 z" w9 r1 ?( _$ Q//
7 J8 x& E. U! ~//  Calls AuthorisedUsers.java and ProgramCompare.java; F& ]$ K" k: ^6 _8 B9 g7 y
//9 U; g7 j: T$ |0 g3 w. v
//  Driver shell for Assignment 2./ f* g( u2 F% |
//********************************************************************* d6 e1 W+ w/ o; J# @2 g

; b3 y+ f# T* {8 J+ Rclass ProgramCompareMenu
  @0 g- C2 F6 e$ c9 v, Y$ e8 [% j{
6 T+ }) _1 ^# g6 `% b    public static void main (String[] args)
' B7 c+ f& ^+ J+ q/ r            {* N0 [( c! E! X5 _1 \7 r
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- Q/ Y* ]9 _; ]9 W4 F
                ProgramCompare reached1 = new ProgramCompare();
3 U7 ^) ]8 {2 i5 B3 k                AuthorisedUsers reached2 = new AuthorisedUsers();        , r4 T  B% q' h1 S. ?2 y7 G
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
8 l% p8 R# \3 \' m                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 E8 O0 F; n. n9 @3 U: W/ k
        }
6 K! ?$ Y7 Y" V- `+ ^}// end of class ProgramCompareMenu+ [$ Z' v& N  S5 l6 J: a4 L8 r( J

$ w& Q' G4 L- w7 \) d//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************2 Y( H- c9 w9 k: T! E) S8 g
//          AuthorisedUsers.java          Provided by: DRS. P& K) t8 |/ E) G( N
//                5 a  d- ^% S/ }3 W2 i0 c
//         Program shell for Assignment 2- u$ D. H3 c+ B+ X0 A& d3 o
//
* o/ s- {6 N, ~, g//         Represents facts about an AuthorisedUser% z  e8 p9 D4 S( y' U
//********************************************************************
+ R0 m# T- k- ^8 u* O
9 e1 O+ D" u+ Npublic class AuthorisedUsers7 q. Q  W6 S* f' P. F$ C
    {4 i: j3 Q5 _* i2 L/ z, f
- S  I. k# U$ ^' a6 G
        //-----------------------------------------------------------------
, ~( N  s8 T0 f0 l* d        // Constructor
, @2 H8 a" Y6 W# w7 e( H' _; p* ]        //-----------------------------------------------------------------
) [- U5 E! |( V+ h: R1 q' z7 G9 p
$ m# W- F& E8 G! _2 y/ \# K) `        public AuthorisedUsers()
* J" z2 ]' q* W                {6 c0 @% \8 F) Y' s6 [$ w4 {
                }
6 {$ X$ i1 ~3 |7 P8 Z* c# p% D) Z+ t
$ }" D. {% k; X2 B1 J- ^        //-----------------------------------------------------------------
6 {# l2 E$ r% `+ L8 o8 S7 H        // Method for testing that class has been reached
& ?, W2 x3 D) Q        //-----------------------------------------------------------------       
* L- H/ ~/ X- a& P  b$ B        public boolean AuthorisedUsersReached()
2 E# F" n7 ~. A% x# F9 c; ]; g                {2 ^6 G! v1 Z. ]6 H5 |
                        return true;                       
0 L8 i( w  O" |7 K$ i8 v                }
& L9 s, t% E) D2 Y               
% W' n+ z' r1 }" a4 P! M    } // end of class AuthorisedUsers
- X: m/ J* x: S2 k: _( ?; [; M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: h9 e4 T- ^. G* k* S  hShanghai - 2007' N$ M5 ~+ p1 n. B' o
Assignment 2+ i& q* e) x# J3 D: S3 L1 O9 V- Y
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)0 `4 E9 G' b, B8 e
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.% Z5 W& m' F( j0 N( B' y5 d
The staff must be able to:1 T  c$ E9 A- ~- j/ o1 N# c" A: h6 I
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& f3 Q  E8 X9 R7 L9 C# b1. 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.
% k1 ^+ e& ~5 D5 S& F The interface should provide a menu so that the staff can:% h2 C$ c8 V2 u  d( z
a) Enter the names of the two Java program files to be compared
9 O, r" D% `' Q8 c For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 g0 |2 _9 ^9 D% C; U! P** 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).0 t# n9 }$ F/ y- R( L" {9 F
BSA104 Business Programming – 2007: Assignment 2
- n) {2 ?- ?# K1 v' c2 @Page 2 of 5
. `1 J6 `# Y% G4 p  ^5 u6 Xb) Print out to the screen all the lines of code that are the same
2 W5 J9 K) C& i3 N0 F/ X; E/ { Include the name of the file and the line number of the code being printed for each of the two files1 I& w6 @6 v4 l7 t2 k  |* ^
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
% p9 L& x8 _2 T0 D( C- g the name, username and department of the user
! t& n" h1 n" n/ {  g/ i% ~ the statistics of the comparison3 v: g0 I2 P9 c. g) m
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" e9 ^; u9 H8 h+ W& E the recommendation for further checking
# D2 M% [) z3 O- @% n3 B- 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
/ s9 k" ~* U7 a) E# a the names of the two files compared
; Y5 R9 m. O' }+ c& ^. V; ]. |) ~d) Leave the program (exit)
* c& r9 Q6 w' C, I& @The ProgramCompare class: (Total maximum 20 marks available)
8 D* |+ ~* g6 E& w) X/ X% P3 O2. 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), Y' V9 T9 j8 G3 Y4 c$ G
a) provide an error message if the files are not found or there is a problem opening them
7 @% j( |3 \7 t1 V) h6 k& Sb) compare each line of code& _# y& P6 _! o# F6 c) g8 c- G( S! f
c) print out the lines that are the same
1 s) M& Z3 m8 n, z# Md) count the number of lines compared / lines the same
; b" O9 q) x. |, D) J4 aThe AuthorisedUsers class: (Total maximum 20 marks available)
% A/ U- B; m1 B: s9 L0 F3. 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)$ v) l& z! g" D$ l  i# ~# n, r
4. Provide methods to:- B/ p; W- ]2 V+ C' t
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 match4 m0 F, g( M; u1 l0 {1 s( F
b) return the name of the authorised user
7 m, D) Q. y/ w, f0 ?c) return the name of the department of the authorised user0 B1 K" A4 z3 v
Individual Data (Maximum 20 marks available). `2 g; I4 N" T( B  ?. b+ v! V+ }
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.# Q/ {4 m5 j* a; [# B& x3 p# n8 P1 T
Documentation (Maximum 10 marks available)% o6 y1 V8 t& v& 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.
" d  {1 T+ f) a! wBSA104 Business Programming – 2007: Assignment 2! f; [% C* I. ^5 @9 T' V5 l
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
  Z% [! Y8 }& V" K" p不过你要翻JAVA的类库说明。你有下载没有?
( ~; C; T  [3 B查询关于对比的函数。貌似关键字是contrast,还有compare( [9 F0 a! {1 p

8 b2 e3 z* o& M! L# ^$ N[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -2 h: S5 ^  D$ U8 e' @" Z- `6 J2 c8 }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: ?# }7 a" }' h4 h5 Y+ G可以下载到的 是 jdk-1_X_0-doc
8 [8 j, {8 M5 J0 P: n1 X( [* K  O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-11 14:57

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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