找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1204|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 X) @: a2 k- H8 P$ s - i% P! {+ k5 W1 l, f9 t7 c0 l4 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 | 显示全部楼层
//*********************************************************************
3 |% `, P2 `' z6 `" P4 M//  ProgramCompare.java         Provided by: DRS5 t3 Y- g/ ]4 p9 W
//
) S/ @" m9 M8 _( a$ [( `! [//  Program shell for Assignment 27 D. W( d/ a2 n
//
$ A! h  J# J/ V# @% I//  Compares two text files line by line: q+ x4 F, I/ @$ |% D  B+ Z
//*********************************************************************
/ q5 F& a- k3 R4 l: h" y( |. z# |! N% y- I6 C+ [8 d
import java.io.*;
5 q/ V- ~. k) |5 x' j+ r6 C7 A1 E  B$ e
  S/ E) F$ i8 V* p+ I7 ]public class ProgramCompare
1 p: h( W6 _# d: P) x) l{
+ I4 u% Q2 r6 a        //-----------------------------------------------------------------3 m0 s, Z* P# |3 ^  h# f
        // Constructor
$ |0 [' n( `. Q/ ^        //-----------------------------------------------------------------
# \6 T. e& x* |. ~/ R' m& S        public ProgramCompare(); Z; N  d) H7 [( x2 G6 Q' O& t
        {
5 n0 D  L5 F# h9 r6 Y: S        }9 s: V6 `' `7 K5 z+ p
" A$ \8 o6 L. S8 s! i1 {/ c/ L* }
        //-----------------------------------------------------------------
( t$ r9 X2 m% ^* o4 ?; Q        // Method for testing that class has been reached
# o$ a# E/ f1 x        //-----------------------------------------------------------------        5 L6 T5 n9 @/ ]! R5 g

. s" G/ F. e7 {+ e+ f        public boolean ProgramCompareReached()        
9 j& E0 B7 \* _- {, q# ?        {
* X* l. n2 t; K9 o: a      try
8 G0 X; Z) O; L7 p- u3 n   {        
. z+ |2 a% K4 S* W1 L                        " @( R5 b. I: B" f  g
                //********************************************************************' \3 V) |% J8 a; s" ^: G  I' _+ i
                // Try-Catch Statement is used to handle exceptions - such as file not found
" S0 G7 j% I* q. {. v                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 {1 B. ^9 K8 s( i/ q
                // For more information see page 534 of the textbook
) A' Y0 @1 u& a+ r; Y+ E1 {                //********************************************************************
' |0 G4 B; g: o; D7 n                    
4 H1 A6 _1 ^8 Q) `# X/ m        }
& H5 j+ O9 y( {/ B  t+ _) U             catch (Exception ex) // Exception caught here and message displayed to the screen
0 }9 o  ]; g& K, M          {
6 P& W2 ^$ L" ]                    ex.printStackTrace (System.err);
  ?: R+ e. H( J           System.out.println ("Error message goes here"); // Replace this error message with your own         
, N7 k* H8 H6 }3 h        }
5 `* N/ H. l1 ^* B! O6 W                return true;9 [9 {( _1 M/ t& a9 N
        }
0 z: B- Y  n  ^9 g8 I$ H* i1 _4 l0 S8 _7 \5 @
} // end of class ProgramCompare3 V8 [& B, h# ]; M; Z1 u

# t1 S7 i3 O; q% Q+ Q& I- l$ y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
3 [% p; p! O, L, z3 |//  ProgramCompareMenu.java    Provided by: DRS- T, b4 J/ o$ R# e8 p
//
9 w: G6 @' a( N//  Calls AuthorisedUsers.java and ProgramCompare.java
: F0 b( `) L& v5 \  h//
" G4 ~! S4 V$ s& B0 d7 }//  Driver shell for Assignment 2.
6 E4 W& L$ g( f& x, h+ {4 _; ?6 u//********************************************************************2 \% N1 \; i9 a! e8 p) y8 i/ B  q% M1 V
% I+ h, r; D, o* a% M* s2 z
class ProgramCompareMenu! f  M5 |: O; r% D( |; d1 x
{
) `& F  o8 N8 e' g    public static void main (String[] args)6 u; z( n9 x, b7 y
            {, h9 E3 Y4 \6 x4 X
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
' B2 w+ R( }$ B" ?2 u3 V; c2 N! c                ProgramCompare reached1 = new ProgramCompare();
$ O+ r# X+ x% |( z5 k                AuthorisedUsers reached2 = new AuthorisedUsers();        9 @2 ^9 z/ Q3 ]7 Y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());8 v4 o9 b. N  K5 a( B0 t& O; n
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 K, ^% g- \; p" U' m        }
1 ^" R0 P- b5 t& i' J0 n% G" q% V$ [) Y}// end of class ProgramCompareMenu" t7 x1 Q! w0 J, K6 b% E0 [9 F5 x

0 ~- P2 ~" W* ]. r" |4 J% O8 t7 U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" A9 W. \. o) ?9 ~
//          AuthorisedUsers.java          Provided by: DRS" J# t- j; u5 o0 |
//                + [2 p0 N, |5 O0 j' ^
//         Program shell for Assignment 2
# J7 x* B, A- w1 {% U, a4 m, Y6 @//2 L2 ]+ a" s- E9 v* @" A
//         Represents facts about an AuthorisedUser  p1 @5 |: X: E- ^* L3 g& I
//********************************************************************4 v9 \3 l3 o( W+ Y# N) B

) z. C6 [' P6 }* ~/ w# \public class AuthorisedUsers
4 K7 ~5 G+ K" s) S: _+ S( t8 f5 S    {( e6 ^% K8 i' j! T3 A

7 w1 a# `3 W3 ~$ x# Z1 U1 K        //-----------------------------------------------------------------' \9 {9 F0 R( m$ \, g' @$ g
        // Constructor
9 g; Z1 l( G( b: w% }0 Z        //-----------------------------------------------------------------
6 s6 Q  {1 s+ n! i( o
# v! u% G2 ]5 n% b        public AuthorisedUsers()( L0 C- l4 b: J4 q& l
                {: J: U% F% g6 T& B8 y  u2 o
                }2 _8 p4 Q) \7 Z" N6 R- ]5 k" I& u
& N* e7 j- y8 k/ N- l1 i" \+ R
        //-----------------------------------------------------------------  W" t/ d! F7 i/ I8 V4 W
        // Method for testing that class has been reached9 w- j+ E7 K  X8 R
        //-----------------------------------------------------------------       
! }& a' X9 Q# t- r4 \        public boolean AuthorisedUsersReached()% S# }8 R" j) e  |
                {4 x8 p: F3 h( {( |& t3 a
                        return true;                       
# y* W: Y) z' j$ V, i8 t8 J                }
8 @) D/ k, f4 P+ r5 j2 l                7 t/ X, f, U. W: }7 p
    } // end of class AuthorisedUsers
0 c/ H' M4 d) K* J( @( T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming& F- a* [  [6 f8 {' @+ G' z' V
Shanghai - 20075 r" S8 ~& A( u& n! c9 W/ m
Assignment 2
1 Y. p( d1 b, ?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)6 V) A8 W6 [4 a# I( j
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.
. d# ~1 N* V1 v) d' V6 Y6 X  Z+ cThe staff must be able to:5 x$ l; `) h; v$ v- h" s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" @; B' L& B3 |* t1. 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.
5 k/ `& p, \! n/ h" b The interface should provide a menu so that the staff can:
6 \+ U9 C8 C* \$ m$ @' Xa) Enter the names of the two Java program files to be compared
0 P. ?* K1 f+ {/ y- ?2 j: @$ O For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- r, O8 W1 ^; h; u
** 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).
! H; K- @1 \4 T: k4 RBSA104 Business Programming – 2007: Assignment 2
# ^0 r4 I) ^2 \2 Z+ m+ {. PPage 2 of 5! d6 y$ m! F9 T( b; {/ ^* L
b) Print out to the screen all the lines of code that are the same
" y  t9 J. u  R# g) p2 k4 q, n Include the name of the file and the line number of the code being printed for each of the two files9 B: Z4 m* I9 x# o: M4 f
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% K+ i1 H& x- {6 t
 the name, username and department of the user
( m; q. U5 U( X* I+ A: D the statistics of the comparison
4 g6 W- P- T6 n3 J2 g! H  K- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ K( m: V% {2 ]( N8 V# U# t the recommendation for further checking
4 u8 x: `) _' ?5 Q: N3 K- 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
% a0 R& I- k4 n$ L1 t* t the names of the two files compared" ?9 r& L5 }% ^, t5 X( k8 q
d) Leave the program (exit)( s- L- m9 E; R
The ProgramCompare class: (Total maximum 20 marks available)' V% N2 |9 D: a" ^
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)
3 j  Y. y' \$ ~# I& E$ N/ Va) provide an error message if the files are not found or there is a problem opening them
4 ]. T3 H  A! X+ S' ]* Ib) compare each line of code
) @  f6 g$ q. f0 @6 `2 G+ \1 }c) print out the lines that are the same: ?9 t4 G  L+ t6 d0 j2 y" k
d) count the number of lines compared / lines the same
- r  J* K$ E: Q. tThe AuthorisedUsers class: (Total maximum 20 marks available)/ k6 T# I  x! D' h' S2 D+ }  U
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)! h. V0 H7 }8 Z& e5 c6 \/ ~- Y
4. Provide methods to:5 D  f' F5 h+ ?1 g" O
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 o, u: Q5 r' J: b
b) return the name of the authorised user
( I7 u- m" g8 q1 L7 i3 c- \c) return the name of the department of the authorised user/ p8 n% z! i' h" X3 S* Z
Individual Data (Maximum 20 marks available)
" R7 p% ]$ q* z9 l0 X' i& g5. 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.
6 |  e+ H! }5 B2 b! h6 T2 B/ ZDocumentation (Maximum 10 marks available)
2 ?8 B. @6 u4 n" Q: z6. 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.3 x- z, K0 `3 q1 U7 u% }
BSA104 Business Programming – 2007: Assignment 2
8 {5 \* R3 d* mPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 n* `& j) B* [. \5 W! [0 A不过你要翻JAVA的类库说明。你有下载没有?3 O, Y1 y) B4 X) b5 q( d% q! V( |
查询关于对比的函数。貌似关键字是contrast,还有compare
0 J  D& e- b$ S5 A4 ^6 a/ ^/ I  m2 H% d( n$ q' T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% G  v# z0 S( O8 M
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* `, g! Y- c1 b: L可以下载到的 是 jdk-1_X_0-doc
% X0 d: o8 |6 c
. S) |* V9 ~& n0 F& K& Z$ K2 ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-17 21:08

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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