找回密码
 注册

QQ登录

只需一步,快速开始

查看: 945|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 y6 V$ M$ @ ^2 e6 D * h- C$ P2 }9 @7 s
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
) I7 p- i, O# `7 X//  ProgramCompare.java         Provided by: DRS
5 J# P) I, x, j2 n/ O5 {9 a* ?/// _7 p! E( w7 f1 h4 j. _+ Q
//  Program shell for Assignment 2
+ p0 Z; V) u1 `7 |4 W- o//
# P0 l+ a7 p! H) b: L5 A  {//  Compares two text files line by line+ A& |& L6 B4 m% P4 M
//*********************************************************************- ~1 f1 a+ E% a. H  k3 K  F
" u1 H% M- r' ^3 r* F1 u! H/ u
import java.io.*;. m' v# N# B, h+ R0 m
) Q' S. H* z6 l# C; S( K7 [- l5 P
public class ProgramCompare
# U' \7 N  C( T5 {) j{
& O* L+ n9 |  t+ h5 \        //-----------------------------------------------------------------
! ?* E* b; |; L4 w        // Constructor9 Q8 c8 @" ?7 D/ X
        //-----------------------------------------------------------------* k# n3 @2 A/ V' J
        public ProgramCompare()
% w1 _# G; m$ q& y8 M        {
+ R$ w1 s4 y- H- J7 [4 h% I' ?5 G        }
8 G; V& m$ L% E# B% s
% G2 ~1 c! n4 ^% T# @& [: u) E9 U        //-----------------------------------------------------------------7 M" a+ v, p" f: ~. i5 E
        // Method for testing that class has been reached
. o$ K9 |6 M- Y4 R        //-----------------------------------------------------------------       
! ^* z9 j$ J7 T6 m" F" w6 u+ F/ g! a3 X5 W9 O
        public boolean ProgramCompareReached()        
) f- p) @4 D) {        {
7 o3 w, {9 r( [, J, [      try
0 ?- f! ^9 }& Z, F( F, H6 C& X   {        
2 ^1 W4 |0 ?. D/ J3 G1 J* M                       
/ V* V$ j1 {- n                //********************************************************************
6 p1 l1 }( F( t+ b, v8 X# t                // Try-Catch Statement is used to handle exceptions - such as file not found
0 I# Z. e: b, w- j5 }, V: }! A0 H                // Reading the files will need to be placed inside a Try-Catch - just like this one!# U6 Y( v9 t( I1 X
                // For more information see page 534 of the textbook' T+ |9 G" a' u) p/ @' C: X
                //********************************************************************
- e+ o9 U2 e# R: S4 g/ U) U                     1 E2 N4 I2 A' @
        }8 j+ }6 }5 F. {6 Y9 J' n! ?% H+ @& k
             catch (Exception ex) // Exception caught here and message displayed to the screen : N) ~( S' l  i
          {* A& U0 ?; E4 W" G2 c2 a
                    ex.printStackTrace (System.err);
. s* u1 @7 n  M& M7 A/ a           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 A! B/ a9 b) Y* R+ s( h        }6 f- m; `7 o; V. X8 M& E8 b4 ~
                return true;
3 Y4 N5 A: E, G        }( `$ E; d7 i6 y
+ B- Q& [9 K1 [# M" L
} // end of class ProgramCompare
/ |$ q+ a# x! W3 U+ c& g3 J% W- G' {& F: |) a
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ i% R# |( x& t1 r7 e( _4 x- U//  ProgramCompareMenu.java    Provided by: DRS
8 A5 l4 W# D- n+ a' S2 ]  ^7 C& n//( M1 B  p: Y- F" j; b
//  Calls AuthorisedUsers.java and ProgramCompare.java* V1 j" Q- U4 W8 v& a& J
//( W- R; n8 T" k# b. J
//  Driver shell for Assignment 2.
# h+ T( _4 t8 k/ c//********************************************************************
& i# S, K- W8 t% p4 p
6 E4 R2 h6 o  q2 I$ c( o% K0 {class ProgramCompareMenu' O; y8 O; `' E" S8 s# v
{/ q+ b/ D4 x* }
    public static void main (String[] args)3 Q2 Q8 ^2 V0 T& I( C
            {
0 w, c- }$ F) l/ Y0 t; I, F                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 O0 m" W  \% d3 G9 o; B4 s' W) ^                ProgramCompare reached1 = new ProgramCompare();
4 @6 N6 X- |& K. E/ f                AuthorisedUsers reached2 = new AuthorisedUsers();        / X1 \- m. `5 }+ n1 Q( j: P
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());, p0 _+ A* L7 Z: q2 _& y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
9 ^' E! r% o7 w, e5 x" U        }
5 m/ ~6 K4 l9 {! X- G! i; ]}// end of class ProgramCompareMenu: I* ?6 h6 [* m6 r
' j3 @- N! n/ T/ y. K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 i5 E" X" F' S6 ]: O
//          AuthorisedUsers.java          Provided by: DRS- w- M4 J9 t& k+ {0 b
//               
# k% \* w1 J, ~6 r7 w, U# Y//         Program shell for Assignment 2' j# A; V6 w2 x$ X7 E) t4 z
//- \+ k9 k$ |4 ?/ W
//         Represents facts about an AuthorisedUser  E- w! n/ r2 P6 D
//********************************************************************" R( M! m5 M4 p$ ~% X
: F# }4 N8 f9 \6 a$ ?- T% x
public class AuthorisedUsers% q$ v- Z$ @  M) x
    {
' m1 s; d9 y! a% ]7 W  ^
2 s% N( }' k' e0 ?3 n7 U0 w. S; [        //-----------------------------------------------------------------
/ ^7 h3 _* j8 s4 o+ o# A0 @        // Constructor
& y: H+ @0 U% Q( Y4 B/ y        //-----------------------------------------------------------------
2 g( S+ B; V" I$ V2 k0 f8 w9 G& i2 [" D( j4 G( Z9 m% o  Z! R
        public AuthorisedUsers()% r) m* y! h8 P/ V
                {
/ ]4 Y$ S+ Z" v5 j! `# u                }
: J& B1 I% x' Y! E2 ^" H# w- t
" X' f" S7 P1 H7 `) O! F/ g        //-----------------------------------------------------------------: t8 e+ e8 i1 U5 a9 r0 }- A0 Y
        // Method for testing that class has been reached
* M5 s- S8 w# b5 J; T+ h, r$ O        //-----------------------------------------------------------------       
- z( [- Z) i- s- U. T        public boolean AuthorisedUsersReached()" B7 {( O  z5 Q# l. Q! Y
                {
* A; X- d& w! U0 }2 F                        return true;                        . ]6 k" p4 j* r! y
                }
1 w" L9 k% m% l8 ?# F/ M9 y; H* b               
5 r. D2 Y$ k0 @9 P/ v2 m. O! [9 y; i    } // end of class AuthorisedUsers
3 k1 Q  j2 L& w( j/ y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 x0 |1 \) {2 k' N2 ]- Y2 P( s: L& D
Shanghai - 2007# H5 `$ I7 ~7 H: \& f, `: V
Assignment 2; F3 ]( R$ ?5 o- k# \
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)
/ J, V6 m! M8 @( a5 ~5 }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.$ p$ L: L3 F* {* U3 O* i: V
The staff must be able to:: o. ]: J6 l3 `# _9 o4 `9 [5 m
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 v) ^: `7 x, ~+ x% S2 F1. 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 m6 `, C- @! P4 O* X
 The interface should provide a menu so that the staff can:2 U! u1 @5 x9 e1 G  N! o/ o
a) Enter the names of the two Java program files to be compared( _& U/ g0 p% W) K3 n2 V; l' O" Q
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: q2 V" U4 j# Y' L8 |** 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).
( A: X/ Q) J0 |* T! kBSA104 Business Programming – 2007: Assignment 2
3 U! z9 @% W( pPage 2 of 5$ I$ g+ ?3 z2 m+ S$ S& f
b) Print out to the screen all the lines of code that are the same8 R+ j: v2 V' U4 a' t# I3 R/ v
 Include the name of the file and the line number of the code being printed for each of the two files
6 k" E, u/ S  ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* ]) }/ F" Q9 c the name, username and department of the user; b  d1 X& S5 O; r9 }
 the statistics of the comparison* A' T; X& H8 W, [
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 ]& c: z1 x; C6 ~, V. u% V the recommendation for further checking
' n% ^' `: g. c" b, O' [, F* t! u) o- 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
: ]  M5 _  g1 Q) q" T the names of the two files compared
3 H4 \. l& U- Sd) Leave the program (exit)
! U5 [6 D) i6 CThe ProgramCompare class: (Total maximum 20 marks available): b4 N  x9 q7 ?, D* Y7 P: Y
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)
0 }; c5 Z1 @3 Wa) provide an error message if the files are not found or there is a problem opening them" U5 [" ?7 G3 X; H  X* K
b) compare each line of code' a, _; b( |0 a- D
c) print out the lines that are the same  F2 ?7 o( R3 \; ~. R+ O& t
d) count the number of lines compared / lines the same3 Y3 N. p, W# a# U
The AuthorisedUsers class: (Total maximum 20 marks available)% ?4 k( I- f4 q4 o
3. 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)+ ?7 ~+ Z! L$ E
4. Provide methods to:5 C6 y, N. J9 d( K9 H. T% n
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* v, M2 ], y5 l, n+ i& P( y2 k
b) return the name of the authorised user
5 R  h' ?0 ]  Oc) return the name of the department of the authorised user3 X  k" w2 J! u5 c: ?* c7 k
Individual Data (Maximum 20 marks available)
; R6 A! i  u1 V9 ~" W5 l) c0 s5. 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.
5 t5 W# E) T9 ?Documentation (Maximum 10 marks available)
" c$ Z: V2 C- O4 U. ]2 y% A6. 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.
! s, O% N( C% ?& ~0 O! YBSA104 Business Programming – 2007: Assignment 2/ S+ w4 c# `" p3 Y! F, d
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了' l2 P0 u6 `; @3 E# ]: Y6 [5 S
不过你要翻JAVA的类库说明。你有下载没有?; E9 u' u% S1 E3 z
查询关于对比的函数。貌似关键字是contrast,还有compare
+ q0 M' M& f0 J2 u, |$ I* `* ]& {- b/ I9 Z" y+ g+ S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; _3 s; a) j; o  Y5 F( {2 N6 c痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
) W! P+ Z+ X" d, g可以下载到的 是 jdk-1_X_0-doc
4 \4 _( p9 D( c9 r) x0 G/ H* c9 H) g4 U
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-16 01:32

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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