找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1358|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急) {* G' g1 c" `7 h! c9 J, n / N9 f, [" ^$ V5 P
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ z4 a, Y7 X% j0 H0 r# j4 I//  ProgramCompare.java         Provided by: DRS
& v# T* b5 m" Z3 Z5 w* @//
  ~3 _3 c! |# {% M/ W//  Program shell for Assignment 26 M8 |4 _9 i6 F2 H  J$ x" L8 `
//
  H. b* g2 o& O# c* Q//  Compares two text files line by line" |1 n: H8 [* v8 m* ?& K
//*********************************************************************$ f2 s+ ]/ }4 e7 L

3 `) r- l0 G6 D, x& s( m8 vimport java.io.*;
, L% L! Q8 l; r  ~& v7 j  p# b! K* ~& f
public class ProgramCompare
% v" H% Y/ I; z2 x9 p{
$ M2 z" O; L* X% R        //-----------------------------------------------------------------: F* x: U; O1 m3 ^% i
        // Constructor2 ~: {% h0 P/ _9 [$ N
        //-----------------------------------------------------------------
- U, b$ X3 o+ ^$ K6 J+ F( m/ X2 V        public ProgramCompare()' a$ l: s6 H6 e( h8 x3 [- H
        {
/ ]. ^+ w6 K/ h* z# ?$ W" Y        }- ^3 f, U2 `: H3 e: D1 _2 n8 H

! S+ k3 D! b% F; A        //-----------------------------------------------------------------
, a; D/ f2 n& K& ?( l% E        // Method for testing that class has been reached
4 m7 L: V% }! q* E        //-----------------------------------------------------------------        9 u8 W$ H9 e  i( z6 v" x/ i5 b. H; q
9 E8 v. s' s! s5 X: t& k4 f3 ?, {) G
        public boolean ProgramCompareReached()        
/ j* D# S' b2 D        {
9 U# D! W8 e4 T5 S5 t, L9 |      try 1 K' K1 t. f/ ]& o* A, p* E6 ~
   {         , P& A6 N6 J$ [; P% _% B
                       
1 u5 o* j- X! Q% Y. A; y& G                //********************************************************************9 }! Q. M* w% n& r
                // Try-Catch Statement is used to handle exceptions - such as file not found ! w$ l  ^# C9 O7 K% }* F# [  q
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
" ]( p5 V1 Z. _" q6 _                // For more information see page 534 of the textbook
6 m* @, H  r& j6 D                //********************************************************************
2 e* c7 W8 F  p! L6 p6 S                    
& \" t; h, \+ t7 p" d6 w        }
/ p$ D" z* A. N* @7 `             catch (Exception ex) // Exception caught here and message displayed to the screen , H- r. D0 h2 r. C. @% R( Y6 l. _6 c
          {/ E8 j4 D, f' ~5 H
                    ex.printStackTrace (System.err);
8 G1 L7 L& |! L           System.out.println ("Error message goes here"); // Replace this error message with your own          6 Q! E* D' a. |
        }
* j* E2 b# @" p5 ?' ]                return true;
) R# o" o6 G# r        }, ]8 _$ d5 l! @  Q/ Q/ g$ h7 w

: C" F& g! Q: _} // end of class ProgramCompare
2 ~2 ?7 J* w* @: q+ s# y; G
& }$ ~7 T# p- l  `7 U: P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# W: M. M5 r  ]( Y6 B; q//  ProgramCompareMenu.java    Provided by: DRS' o& j7 Z, y. Y  m2 E
//
/ z9 P( S' _, ^3 |  E8 i//  Calls AuthorisedUsers.java and ProgramCompare.java! h5 x1 [" m( k1 R3 z# n  D, |
//+ v: s" X. w' C& U! c+ _
//  Driver shell for Assignment 2.( E" r2 k. q& g
//********************************************************************
4 X3 ?" N! k4 t1 u6 W4 W, ~! V7 w* L% f- o( Y. [% _
class ProgramCompareMenu! j+ }6 ]5 c1 ?
{
5 g$ R4 s; R0 ^) R4 z7 C7 a8 q0 J    public static void main (String[] args)! x( G4 _# F1 k! R: y. c- j
            {
: w9 [4 o! ^+ l                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable( D- E* J4 N# n& ^) b& K
                ProgramCompare reached1 = new ProgramCompare(); ) \4 u" k+ j, T0 g4 B
                AuthorisedUsers reached2 = new AuthorisedUsers();        ) P* ]# C3 j! u2 ]  U5 N, S
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());( W' T3 S' f6 j. e1 E+ N
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # c. P% ]9 J& S  `' \$ e" u. F0 ?
        }
' X1 @5 H' ~5 y0 Q}// end of class ProgramCompareMenu( Z0 }* l3 _- u% B; P# m6 l

! N, K$ O0 q5 U1 \# Z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************( R) H9 h7 C4 K% j$ D
//          AuthorisedUsers.java          Provided by: DRS6 l" C* k& Y. T& k, R; J2 y
//               
9 W: g7 x5 \% @* _- q//         Program shell for Assignment 2, ?& I% W8 e0 J1 ?* h
//& f) \4 n7 l2 d8 e% v
//         Represents facts about an AuthorisedUser0 u. y- u9 g5 C# H9 j8 q9 |
//********************************************************************7 h) ~, L9 _0 u+ F$ J7 N5 p. w

" A% `6 h5 F2 P4 u2 r4 ^public class AuthorisedUsers7 n* @5 V6 g( X9 }  @) v3 [1 w5 c
    {( b% f9 o' t1 M0 k/ A* ^: x

. K, V8 _* T# g# w( ?5 m        //-----------------------------------------------------------------* a6 N3 v; h4 y
        // Constructor
. a4 }: g1 S/ J' M" p+ s7 }        //-----------------------------------------------------------------' Y! L! L. s  x: Z3 k) C

. ]& o! b* {: b: g: r4 p- D        public AuthorisedUsers()
; u6 }: M/ e+ V/ F; |                {3 v; U) Q! {. b6 {- v6 e, B+ V
                }2 U# J: y& U6 M2 c

& ~! U( {0 Y5 f  i/ P, X        //-----------------------------------------------------------------9 ?; A" E7 ~2 P, r
        // Method for testing that class has been reached  J% G# B4 d6 q$ E. W& q+ j
        //-----------------------------------------------------------------       
+ l% p/ C1 ?+ Z$ L8 W- Y, g        public boolean AuthorisedUsersReached(): h( O4 B& T6 A1 ^
                {
, ^( M4 X1 B" q, y0 L+ `2 e. G; B                        return true;                       
: P; A9 l0 G- k, F                }
$ |; d6 k  t* F5 ?& u( U. |3 d                + J4 b" }# V9 J. ^
    } // end of class AuthorisedUsers
# N6 u1 p4 L! Q( o  ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming9 \" U3 o2 B  s3 f% T9 P1 {
Shanghai - 2007
( S- u( _$ h( q" b4 F0 UAssignment 25 J4 c* m  y3 E/ o* d8 F$ t
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)& r8 w& m! e% C% b
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' K3 l8 g: ]! x; c
The staff must be able to:
4 [8 z! w* u" R" m$ K" I8 c# T Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 Y' d- O+ h5 {: {6 o' D1. 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.+ C2 u6 D5 w4 J' K. J, O
 The interface should provide a menu so that the staff can:/ v! j( {/ |5 R0 C/ O) g; g3 s
a) Enter the names of the two Java program files to be compared' Y; s8 X* Q$ P4 Z+ M+ [( u; D
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.; M2 C; g& v+ U& i
** 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).
: I: m; L0 n+ o0 H3 vBSA104 Business Programming – 2007: Assignment 2
6 T7 F0 t! D1 C% R. Y+ QPage 2 of 5" `( G) ^9 I6 E& u
b) Print out to the screen all the lines of code that are the same9 D6 F% W3 j; p" U# \
 Include the name of the file and the line number of the code being printed for each of the two files
2 p7 `8 @  O$ T; [c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" ]/ R( ~  U/ q' f) m& r the name, username and department of the user9 L' Q- Q1 I( @3 C1 }1 @; ?
 the statistics of the comparison
( `7 v( V4 }; S# j( |- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different  w7 e6 y# X, H' D2 H
 the recommendation for further checking  @  ]8 G- }3 u7 _* i
- 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" Z; \( W& o* o2 j
 the names of the two files compared) A+ @/ P; `" V- X# f6 M
d) Leave the program (exit). x$ S9 m' q% v1 G
The ProgramCompare class: (Total maximum 20 marks available)6 S! P+ v6 t: [) `- `8 {, u2 b
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)% a2 ^7 g0 J* F7 W# z
a) provide an error message if the files are not found or there is a problem opening them$ @/ K! E$ [& x5 w0 P7 M$ h$ k
b) compare each line of code. O5 K! t) f  k2 v
c) print out the lines that are the same
; s# f, v. `) s" Cd) count the number of lines compared / lines the same
$ |; U" A# G! P% d. `5 c7 q$ w' PThe AuthorisedUsers class: (Total maximum 20 marks available)
* V3 l/ ?1 \" L, y/ i; ~3 R3. 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)  n1 m* X$ E" t" Y
4. Provide methods to:
+ e4 C5 s5 y, ], t7 N9 Z! Ka) 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
* T- h& F; Y' Y  ?9 t# \b) return the name of the authorised user( N+ P4 a1 J, G; w) J
c) return the name of the department of the authorised user
( R1 [+ ~2 n, y- d% \Individual Data (Maximum 20 marks available)  c, ?6 Q+ S5 x& s* Q
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.
, \$ r* w- H9 C8 s# F/ sDocumentation (Maximum 10 marks available)6 e. ?7 n  v4 U' {' Z3 i
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.4 i6 i6 R9 f3 K( @# y& F1 K! S
BSA104 Business Programming – 2007: Assignment 2
9 ^( C7 B! R6 FPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 B. h2 o; C) _% x7 U# Z0 a
不过你要翻JAVA的类库说明。你有下载没有?+ `5 Z& C1 h; p
查询关于对比的函数。貌似关键字是contrast,还有compare
# r) a! q6 q1 V3 f! t: g; l; L- f
+ Y& Z- B/ A2 Z8 U% ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 H; k+ r1 q0 [* P4 J2 _
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 q% v& p& G1 ^' ]; c
可以下载到的 是 jdk-1_X_0-doc
+ W, ]5 K5 u! n$ `- H
+ _5 e4 r$ T. E: [) g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-6 14:29

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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