找回密码
 注册

QQ登录

只需一步,快速开始

查看: 934|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! ?6 T" e# X0 G % s( v. T5 \, M. B ~* O$ Q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************" X( |8 b: R. h* A+ V; l
//  ProgramCompare.java         Provided by: DRS9 C0 K& K8 u4 z& u+ n3 e3 `- v' B
//. W  t; ?: S0 m' M% I$ |5 M
//  Program shell for Assignment 21 d' H, T& Q- z' Q8 e
//
9 i% P! w2 M! t; ?//  Compares two text files line by line
+ Z& M6 e9 R0 M' H//*********************************************************************
% O+ A  c- J6 U* g- u, I  H1 B( r; u4 z$ K- \, R1 [
import java.io.*;; V, w. J3 Z2 n( p
) M1 }9 l. z4 H& a: ^
public class ProgramCompare# R8 c7 Y. b* V- W5 j" Y5 g; @5 e
{
, @) ^5 V$ B! n2 O9 t% w        //-----------------------------------------------------------------
2 V) ~' _* q) B* t( @0 X& O/ B, N/ l        // Constructor6 l' J0 o- k* g) H
        //-----------------------------------------------------------------( S- I, q) K( M* y$ E. |) r" D; I
        public ProgramCompare(); W) a9 S, w- d
        {
+ h% r8 G* m6 x' H$ g0 n' r        }
; A$ U: ]& J7 J3 e+ t; k; W+ Y3 z, \4 v( G& S# x( @
        //-----------------------------------------------------------------' G, K. n4 q5 X4 v4 Z
        // Method for testing that class has been reached
. e6 T. t7 @6 R% B- y        //-----------------------------------------------------------------        ' a3 u# n2 y. S; J" X; J# @
8 A( D! B( C) S/ e
        public boolean ProgramCompareReached()        
8 |8 w2 f5 Q* z        {
+ y4 A' g; T# m5 ?/ C      try
3 ]+ T8 }' g& K   {         . c& V" G& G* c+ k" T
                        ! \# o9 z" P6 F9 }" T2 M
                //********************************************************************7 L0 z5 s7 a: h
                // Try-Catch Statement is used to handle exceptions - such as file not found : B) r4 \; o, ?# ~% E
                // Reading the files will need to be placed inside a Try-Catch - just like this one!) ]' ?5 N/ p# h
                // For more information see page 534 of the textbook4 W2 h# {+ q+ E' J+ ]
                //********************************************************************* o7 k; W6 I! G1 ?8 g
                    
/ m5 \* P7 b% D* b( p% X        }
, s+ j/ \5 |' U1 W             catch (Exception ex) // Exception caught here and message displayed to the screen
+ \- k3 @7 {: g( l* g" v+ c          {1 D6 D* E# Y+ W, |! h. K' c4 R4 D7 }
                    ex.printStackTrace (System.err);
0 H/ m; b: f! g9 o) {6 m           System.out.println ("Error message goes here"); // Replace this error message with your own          4 q4 W& g+ g9 A5 K: Q. W
        }- ~0 o; @( q, ~, X  B. K' i6 {
                return true;; A, T$ x; N" d
        }" s" U/ m4 W! J

# F. Y% [9 \* L9 ?- q1 s} // end of class ProgramCompare
' S/ q' D  h! L- l
- J' b* V4 J- v6 t8 v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 w5 ?8 E# u( `) N7 t6 M//  ProgramCompareMenu.java    Provided by: DRS8 v6 v6 I& w; {9 l
//
% w2 N2 R6 N  Z1 w" Z7 ~4 {* q3 |//  Calls AuthorisedUsers.java and ProgramCompare.java
  `# i6 w4 M5 @4 W0 S1 \//
" e3 j3 w+ C  [//  Driver shell for Assignment 2.
1 O. @- c& P! B$ w2 D" y//********************************************************************
7 A( ^+ P1 E- R+ d' N. N
* q! w+ c7 G* Sclass ProgramCompareMenu: x3 }  r, [5 w. [4 r3 w
{
5 P& G- T4 H' V1 K; h) f    public static void main (String[] args)# g. Y% n0 B3 d
            {
" H+ a/ R2 G0 M                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& m6 i2 p) b- H: R0 `5 a8 E
                ProgramCompare reached1 = new ProgramCompare();
9 p$ b9 l( I+ G# a8 Y                AuthorisedUsers reached2 = new AuthorisedUsers();        # y$ ^, O8 L3 j5 W
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  U) @5 ?7 k9 ^0 {, e; P5 y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ g# Q! n( L$ d7 X9 h& }0 w
        }& r8 E. G4 }9 x: r9 U9 ]
}// end of class ProgramCompareMenu- K4 L' f0 U! F  \6 R! {% D! }
& i+ Q7 x, j* S9 ^: H' n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 s: s" e" Y+ i# i
//          AuthorisedUsers.java          Provided by: DRS8 |6 {  `* T1 h: b
//                9 |' j! W8 _* k0 z2 q' `! {
//         Program shell for Assignment 2
5 a' j* j# e0 h4 o( {0 s) A//
6 f8 `4 [# d! P# M+ p//         Represents facts about an AuthorisedUser
2 D9 N6 ^7 f' @6 B) I' R$ }  j//********************************************************************! t4 Y3 s$ y. f9 K

/ I, [7 X4 c3 K$ J- g+ r; Epublic class AuthorisedUsers
6 L) F, P* x/ ^# C    {
. a* d- B) v* k4 `) I/ H7 I- w8 g0 m/ L4 D
        //-----------------------------------------------------------------
/ T: e1 N  r2 A, y9 m! w- _        // Constructor3 r+ \. D( M2 T! T
        //-----------------------------------------------------------------  u9 p/ z5 ]# ]; ?
# l% _+ f/ C# r/ j# t% Q- g7 s( p4 s
        public AuthorisedUsers()/ Y4 Q$ B( Y/ C$ w+ s
                {
2 I% C7 N6 Q0 l) L% K5 B3 G                }
& h2 l/ q  T: i1 z& ]# v1 T  f; w- j( k3 c8 y3 m: M1 D
        //-----------------------------------------------------------------& q: o3 [/ x. P( ?" |! _2 p: N
        // Method for testing that class has been reached7 u# h1 H, V% X* {- X3 C% z( n
        //-----------------------------------------------------------------       
) f$ x7 B  b0 f9 t* L3 q# f        public boolean AuthorisedUsersReached()6 U3 }: v$ c% x/ Y% P4 ~6 A' h; |
                {
& I) X% c- a4 N& F! N3 I3 [                        return true;                       
' I% F$ C; t( `- L                }
6 o3 _/ R, l3 T+ K! N- j( Q0 c2 J                6 |0 B( n: n2 V6 w0 }4 a
    } // end of class AuthorisedUsers
$ o6 e$ ?" Z$ F+ y! N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" p# }" `+ D/ K4 y3 h$ e
Shanghai - 2007+ ?4 w# Q+ `1 d2 G% u$ X, Q0 L" Q
Assignment 2- `6 A$ L4 q' M) V! K" ^4 e; W5 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)$ d: o9 }( X+ n" ?- M9 o# H% N' n
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.
; g9 I; ?8 o. q' _- J& KThe staff must be able to:( F# D/ C4 M$ A
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.5 F* I* s, R+ A# i1 I) s" Q* `/ `/ K
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.% x, }0 Y2 m+ e$ @/ B+ B
 The interface should provide a menu so that the staff can:
9 `6 |) s- R' b3 W" ^$ Fa) Enter the names of the two Java program files to be compared
$ U' Z4 e* o8 m6 G7 f For this assignment, it will be assumed that the two Java program files are in the same folder as your program.1 I* j; G0 I3 [; Z& y
** 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).; j) a8 [9 P( N/ h' C. o3 s
BSA104 Business Programming – 2007: Assignment 2
9 a7 d3 v; {& h; ~Page 2 of 5- D0 Y: N/ R+ Q
b) Print out to the screen all the lines of code that are the same
8 |" O% ~3 t5 `! K+ F9 } Include the name of the file and the line number of the code being printed for each of the two files. M9 K. ^) |4 L+ E% F% @" |
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
1 z& i) y( o3 x' S the name, username and department of the user( _1 E5 d2 h# Z6 k7 M- k  I! n  b9 p
 the statistics of the comparison. n1 T, N1 {& s( }3 E' e7 W  p
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 y! H6 v: ~3 A) M) o
 the recommendation for further checking% q5 p* ?& `# m, H9 ]4 y
- 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
! q% i& s) z( _* k6 o' _# W the names of the two files compared
. d& }  {: Q7 |# k1 F$ n. T( Nd) Leave the program (exit)9 U5 l' E5 [; }/ q) {( y7 R0 v, m
The ProgramCompare class: (Total maximum 20 marks available)/ X/ w' Y0 q: i; [* P6 R
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), W0 J6 w4 V1 R' J+ M* `* r' p
a) provide an error message if the files are not found or there is a problem opening them
5 s  R7 x* Y+ R# Q& l( @- D0 [" |b) compare each line of code0 F" f8 A# \8 j5 `& V9 d. o/ F! S
c) print out the lines that are the same
* m. O  l, d: m# q2 n4 Yd) count the number of lines compared / lines the same
6 u5 p; N. e& ^6 J: JThe AuthorisedUsers class: (Total maximum 20 marks available)
8 ]6 _" b2 F7 p7 ]& C" }2 k3. 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)
8 X$ ~; q" J; u' d4. Provide methods to:
% J0 A1 ^& s- O0 J/ aa) 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) J% j, ?8 w0 f5 w/ r
b) return the name of the authorised user
1 b9 o6 V' E1 ]. L+ q0 }# jc) return the name of the department of the authorised user( R1 ?. Q* l, G/ t4 [4 i$ G$ Z
Individual Data (Maximum 20 marks available)
* J' [0 [' j/ k( h3 s/ X# \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.
% A- f7 O1 u7 W5 Z' GDocumentation (Maximum 10 marks available)6 D' s& Z; G/ z3 t4 q5 U$ C9 K% K% r
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.6 K, D- Y5 }6 M5 b+ |
BSA104 Business Programming – 2007: Assignment 2
0 b8 Q: m6 C8 h2 OPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了9 m1 [: i/ Z. o. ~8 }! d
不过你要翻JAVA的类库说明。你有下载没有?
7 W9 A) P, z/ U& I& |# i: c查询关于对比的函数。貌似关键字是contrast,还有compare
5 {5 D" m& e1 c% L$ M
! `: C/ M- d0 ]. s, x) d6 s[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -8 K2 C) h' T$ Q) ?, F
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 e6 `  o% v: N' K9 ^可以下载到的 是 jdk-1_X_0-doc1 U# D' \6 _2 A# h
& r; X; G" ]8 q: U
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-11 23:58

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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