找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1099|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 7 { T5 r+ s/ C- X: f( {" l' y G- @6 |4 Y. c9 N
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 s# A( F1 d' G& z4 ?* f9 J+ F
//  ProgramCompare.java         Provided by: DRS/ b  C+ |6 E3 v$ {6 {. B
//
, x* n2 x  W; _, d8 A//  Program shell for Assignment 2
5 G" J1 r" i) v  y; f$ S, b4 H//5 i9 u1 T0 c# `2 @* u: Y- t$ W
//  Compares two text files line by line' o; ^  r$ B- x( |
//*********************************************************************0 D& r0 f' i) i2 p( |

& o0 J" o+ d1 N1 Y7 L3 n( timport java.io.*;
7 r. o; f1 B4 g" J
  V8 C# v0 C! \/ B1 e2 Q* c. z" m: spublic class ProgramCompare$ \$ }9 L- f- [: k! d
{
$ t# H& v* Q3 ?( Z, q* b        //-----------------------------------------------------------------/ m( g/ ~" L( i! g( h
        // Constructor' Y1 C) G6 q: u7 L
        //-----------------------------------------------------------------: P: P6 B' i( @$ Y
        public ProgramCompare()8 l9 U, q% J0 d/ d8 R* I9 t+ F
        {; N7 U& m  w$ t' A8 ~4 s3 w* o
        }
! v* Y$ e9 i% V+ Q( x8 a% R9 M
. j* d. c& J1 x8 k2 w1 ?        //-----------------------------------------------------------------* R( C6 a4 N( X/ V+ p* w6 _% K
        // Method for testing that class has been reached
! q. o3 z8 d. m$ U        //-----------------------------------------------------------------        1 K2 X9 q  \% ?& s
/ K3 K+ Z$ l8 G) r: Z
        public boolean ProgramCompareReached()        
) J" f! u& l- P6 w" A        {# \! R! A- [- }, i# R2 l$ Y/ G& J
      try
3 ]/ c# t$ R. h   {        
0 y( H% j1 ^3 R0 A* w8 h                       
( r1 J. }( Z* u. K: [9 ^                //********************************************************************7 ^( R$ q, w# b, u
                // Try-Catch Statement is used to handle exceptions - such as file not found
3 X$ g8 d7 o& u- g5 b                // Reading the files will need to be placed inside a Try-Catch - just like this one!# k- N3 t. l  D) w6 n1 ^
                // For more information see page 534 of the textbook
* `  L2 {4 K" p4 q9 M6 J9 p                //********************************************************************
; S+ Q, k, h3 H) S$ J                    
+ r  D+ G/ N) @1 h- ]# M" _$ Y        }
8 a8 E3 |' n8 Z, t9 ]             catch (Exception ex) // Exception caught here and message displayed to the screen ) }' b' c0 X2 e- k( K, [. _5 r
          {
# g6 k* A# F" d                    ex.printStackTrace (System.err);( @9 l$ ~; K& B$ b7 ^
           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 g1 r3 M( w. |% R        }. \5 d% l* @& V; o: u4 x( ~# Z$ ^6 D
                return true;/ v" g9 @1 n) @6 v& E
        }
. `4 A5 j9 O1 x+ I- |( m& K& i: @0 W! i+ L# {
} // end of class ProgramCompare2 D' z" ], h% J+ y( i

" \6 M* n  ^$ F# M# x: @6 u  T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************% q5 m/ q. L: b# |+ k4 P' r8 b
//  ProgramCompareMenu.java    Provided by: DRS7 o" F1 R2 P& h) D& ^* S6 O
//0 z& i, E4 {6 o. w7 h- `
//  Calls AuthorisedUsers.java and ProgramCompare.java/ E$ y9 z( g" K' x# ]
//
9 T$ G# o7 o" p) z/ \- b/ {# [& z//  Driver shell for Assignment 2.# k! G/ X6 T8 x8 g9 h6 q5 c- w
//********************************************************************; T7 B( o+ e) c6 K4 ^: z( _; x

; k1 m$ Y9 }1 E) B, N1 y7 uclass ProgramCompareMenu, |( ]. d7 r5 h1 ~  J' K
{. }6 q/ J+ x/ L- P
    public static void main (String[] args)
# g" `, }) }8 {: M( `            {
' A' H  ^* m  j2 J                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! d$ I1 E6 `9 ?) f& u. \
                ProgramCompare reached1 = new ProgramCompare(); 6 c5 d/ N& [( P
                AuthorisedUsers reached2 = new AuthorisedUsers();       
. E/ E* |8 n/ f" f3 \: N                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
1 o8 \( t; Y, V3 I# {: v                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + b% h7 a7 r0 |( f: J( S2 V3 ?
        }
9 z" ?  n( I* d0 L) I+ j0 Q  S2 F}// end of class ProgramCompareMenu4 [. r! d3 o, Q! `. e. D! B

; q; Y. g0 Z# S/ C5 v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 g" j1 ^0 ?/ J! o//          AuthorisedUsers.java          Provided by: DRS
2 X/ a& j5 P! f7 A5 b, B//                1 h% ~- ]' C3 |: ?* r4 t
//         Program shell for Assignment 2- u. N) l% K- |- ~5 ~1 i
//6 c2 Q, C; x3 b2 X# O
//         Represents facts about an AuthorisedUser
  K6 V- |) y5 l0 P1 I7 d# h. F- T+ p//********************************************************************  z  i$ V! _( a* b" s- i7 a- v

* C# b7 u% t4 c, O- F$ Gpublic class AuthorisedUsers
! Z( S; E3 F" [$ O7 Q, L+ u    {
9 C, O7 c: R+ p# d' D
4 q: q2 W7 m+ ~6 P* b        //-----------------------------------------------------------------
. s3 M# E" W1 W) F. U        // Constructor5 p+ x( G' e( m+ j7 M
        //-----------------------------------------------------------------# _6 F7 Y4 J7 s( H* c% d0 I) @
& Y: K$ ]. n6 ~+ p. }  b
        public AuthorisedUsers()
% w4 t0 R! m) R- ?! p1 ]6 @7 _3 e, O+ a                {  n- `3 s, |+ f
                }3 }, N, G+ s; p6 P! p

+ Y- C9 D, `+ |4 C, C        //-----------------------------------------------------------------) G9 ?3 ^* U3 d& D
        // Method for testing that class has been reached6 @3 l5 F" L! c# z, H
        //-----------------------------------------------------------------       
& o# q+ e1 w* e- f2 Q        public boolean AuthorisedUsersReached()
- ~1 {9 I5 c- r1 F# b6 A                {8 ^7 R/ W# z7 ^* B' O) f
                        return true;                        ) f8 i# S/ p" m% I  R6 A
                }% U% }. i. M1 H9 b( X6 r
               
: C3 a6 w* s) p) T" f    } // end of class AuthorisedUsers
: E5 G) I. ]% D  l5 p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) z. X) P1 M, r! O- _
Shanghai - 2007: `$ ]0 G( x* R! s) C
Assignment 2
4 p& h: m1 X: U0 B. s9 @. Z& {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)
7 J$ j  x% J/ `8 A& S) l( v1. 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.
1 A( P4 F  E6 f  I. JThe staff must be able to:
3 x! g* B  I. U2 w- t5 L( a, E4 \ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: Y1 p- J% ]2 U: s1. 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.) I# D. x# \( s/ R6 D! ]- G8 q1 Z" `
 The interface should provide a menu so that the staff can:8 V% D, J5 s2 x& O0 e. R
a) Enter the names of the two Java program files to be compared
) u. x; a, a1 }4 |* g9 e For this assignment, it will be assumed that the two Java program files are in the same folder as your program., r8 g% p( u5 G- A
** 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).
" b" \  h! N1 {BSA104 Business Programming – 2007: Assignment 2; {+ G" ~" T4 b
Page 2 of 5: W/ e* g0 S4 ]) B6 R- g2 `
b) Print out to the screen all the lines of code that are the same
& T+ `% t0 ]8 K6 A9 }" [: Y8 E Include the name of the file and the line number of the code being printed for each of the two files$ r5 [* s  x' |+ Y1 @' u
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 w9 n* `; z- n/ `& v; k; D the name, username and department of the user
1 s3 s3 M/ G" k1 ?7 j0 n9 b the statistics of the comparison& _8 ?9 J& M* s! A' t
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% v: v+ x3 W' y
 the recommendation for further checking4 U! _- d/ h+ |# u& M( L
- 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 closely4 n3 r+ n% r  J, Q" L9 X
 the names of the two files compared
) s9 ]+ P  L7 j& M0 m+ @& id) Leave the program (exit)
; T' J+ T( }+ G! q& P! aThe ProgramCompare class: (Total maximum 20 marks available): o9 C+ C  J' |, u  F
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)7 ?. J9 V. K* j) J- O/ M
a) provide an error message if the files are not found or there is a problem opening them/ _" D0 }8 V' i6 y1 U+ S
b) compare each line of code
( j5 c" |8 o/ ?" B, O2 z. G; Tc) print out the lines that are the same
/ w# K' ?) T8 ~- fd) count the number of lines compared / lines the same9 O" O/ d. \( r4 G& a& O
The AuthorisedUsers class: (Total maximum 20 marks available)1 q7 ]+ D! x1 o  j# i: }5 |
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)( X$ `" s' q( N" ]
4. Provide methods to:/ K5 W" J- V+ S
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
9 M# i5 ?' u; ?6 M  qb) return the name of the authorised user) p( A! G' a; J3 a& E: F
c) return the name of the department of the authorised user
; b# m" ~+ i" \5 S) z' h7 c+ s6 V  dIndividual Data (Maximum 20 marks available)2 W( Z" x" Y( L- E1 M, |4 \4 o  `
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.# F4 O) Y  Z5 Z! P3 J" j
Documentation (Maximum 10 marks available)
* ^* s7 n! ?# Y" e1 b. C6. 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." N3 q2 B9 |- ^9 M2 Y- S! Y% r: Z
BSA104 Business Programming – 2007: Assignment 2; h/ x7 a4 f8 v' z$ O) ?* Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ H  {- i  ?" R
不过你要翻JAVA的类库说明。你有下载没有?
" \/ }$ X2 ~; Q9 M1 Z$ s( P查询关于对比的函数。貌似关键字是contrast,还有compare
3 l. o; k  }, y1 ^" V* e! \
5 b& c" L; S0 I- B/ D[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; {2 I+ u3 e: ^1 {( Q( n* U痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。+ ?2 T8 T! u! F7 ^9 b
可以下载到的 是 jdk-1_X_0-doc
9 k8 F3 w. f  C. t2 c
0 G' j- ~: T; J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-7 10:46

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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