找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1044|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急/ g" ~$ t* x6 |6 g + ?) @/ l$ t+ M+ W
回复

使用道具 举报

 楼主| 发表于 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 y5 K! U9 J: |# Y6 O9 @! k//  ProgramCompare.java         Provided by: DRS0 D3 P$ x2 m5 I5 G
//2 p% z% }+ R" C# f# T7 N
//  Program shell for Assignment 21 R( Q2 n! R# w
//
( {% U0 e3 H( c/ f+ n* X5 h//  Compares two text files line by line0 C' Q& T7 b$ Y9 @5 }
//*********************************************************************
  J/ p2 T3 K0 `
! l; M3 z' B5 qimport java.io.*;/ f+ g& G$ k" G" U( [. w4 N* X
# J- L4 e& h' p( a1 S2 l0 p4 Q
public class ProgramCompare
1 l% Y8 |3 o" E+ H: c, [1 @{, w# `5 V5 d# Y* Z$ ^8 N4 n
        //-----------------------------------------------------------------$ a8 A! A4 S9 j( A; d
        // Constructor, L/ p  C( B; x: X: D2 O  r
        //-----------------------------------------------------------------
$ o5 p- ]+ E1 H  h( O* n        public ProgramCompare()2 Z9 }4 u/ e% E1 ]
        {
8 z3 y& |5 H/ e5 u4 Y        }, J: h2 ~1 L! n; @, o% U/ J. @- I9 y

' z( ^; z0 _) v+ q        //-----------------------------------------------------------------
( F: S. z, r( J& T        // Method for testing that class has been reached0 I, T  J& D3 ^1 u( v
        //-----------------------------------------------------------------       
* V* J2 F2 B) S- c- c0 {" i
4 X* x, \, h/ c. L4 X$ ~5 D        public boolean ProgramCompareReached()        
9 R: d7 N6 T, U& k- M9 B' V- D* q        {
3 K0 x4 [/ _0 y( a      try
# s2 @# H( e2 w& n   {           _: R& M% k* _2 p* b+ O" g5 _
                        & t; A! X, @* H9 y$ \  t  Y
                //********************************************************************, `) Z) q2 V, [7 q% D$ O  U- Y8 \- ?7 n
                // Try-Catch Statement is used to handle exceptions - such as file not found - ?. w" r8 w8 |5 k5 K
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 [. \% G3 D" Q- x2 i/ \% C& K                // For more information see page 534 of the textbook
/ _8 N7 c5 h$ v0 x  S8 f  {4 i                //********************************************************************! w: Q% o' b  K. _
                     ' \. Y" P% \; d) ]! D6 u
        }
, h* L: |( w* a6 q2 m             catch (Exception ex) // Exception caught here and message displayed to the screen ' k* P5 y! |9 D3 d  V( s5 O3 K- [3 [
          {* q7 w$ D/ `3 I  V5 O. ?
                    ex.printStackTrace (System.err);% ?. a9 {. K) _5 T* R: }; Q
           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ x' g# f7 i" j, K: I/ v0 v( q4 B        }/ t+ L6 e4 [; n( P8 l
                return true;
7 t" I5 X* ^* r0 d% Z1 R        }
" K5 E! \% w9 t5 W4 d3 G7 K2 |$ z* O
4 B/ p( k( P# S; m$ }- k& \' r} // end of class ProgramCompare2 N+ x  j' h/ L. c" C' r

2 ^3 X( d- Q2 I8 Y4 }# x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" g- S& s- n1 {3 e: @//  ProgramCompareMenu.java    Provided by: DRS
$ x, [0 O& ~  O$ H4 ?7 Y//
! ]  |$ F2 j  Q4 f//  Calls AuthorisedUsers.java and ProgramCompare.java
" f& l) ~* |6 Z4 s" U6 r6 }' o- M//
* l+ ?9 Q5 r' a//  Driver shell for Assignment 2.# w% V' o8 A- L3 t
//********************************************************************. J5 g" Z5 \# Q* f
( f  O7 A! j, H5 A% b7 E
class ProgramCompareMenu7 d1 k) k9 V/ n8 m( L) x
{+ J* o& R* c) o! P. @
    public static void main (String[] args)- ^( j1 f# h2 q7 }/ p  I( K
            {' h4 v  f* H% h- }' W4 _: r  }
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 |. h8 q0 w) L3 _
                ProgramCompare reached1 = new ProgramCompare(); ) p# g$ y" {0 n& n
                AuthorisedUsers reached2 = new AuthorisedUsers();        " y4 G& l3 P# T) l
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. i  l# \  r, N; M5 l; `8 K
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # s9 w7 [$ t9 U$ E& e" T
        }4 f: \* [0 Q/ j/ Z( W( {1 @
}// end of class ProgramCompareMenu6 W' r/ v5 e' Q( r0 f% F# H
& Q% B) H4 I9 N( f0 |  F( U! l( N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 F" F! e- a4 Z+ ]/ c//          AuthorisedUsers.java          Provided by: DRS7 f, h  Y% |9 M0 S/ |
//               
# N; L( P1 Z% `6 k& ?" {//         Program shell for Assignment 2
: c  M4 |7 k6 n) O/ P: n2 N//: y7 T3 X- ]7 L5 s, K+ m
//         Represents facts about an AuthorisedUser
( Z5 Y3 w/ T" |3 l7 V/ a//********************************************************************. H" |0 D! e- u" a

* k6 J! S% d3 E8 W+ A& A: s3 j; Fpublic class AuthorisedUsers
; d: ?0 r" \) s    {, f. r$ y2 C: {
1 z. u& t" L2 C0 `/ h
        //-----------------------------------------------------------------7 u) |, y; C3 z, w$ E- V
        // Constructor' k+ `+ E/ x( m; Y, h+ ^6 _
        //-----------------------------------------------------------------/ L2 q/ C+ C& a! e
9 b2 X% j+ Z5 J# l
        public AuthorisedUsers()
) |; v, i( p+ E) V: ~                {
( V( J3 u" L  z8 ]2 E6 A                }/ Y3 I+ f4 n8 Z9 a

& I  X9 D. n3 O6 \        //-----------------------------------------------------------------
; C2 ], j7 l' t2 `2 _) d$ |1 J        // Method for testing that class has been reached
  L* I7 U, x6 b7 _        //-----------------------------------------------------------------       
- ~; `9 Y/ R% \) u) m        public boolean AuthorisedUsersReached()! t1 a. W) t. I' d1 }: r2 E$ i& V
                {; V2 X( j* I6 K; X- z
                        return true;                        - |- Y" J$ `( B3 a' L7 L
                }% Q5 k+ Y! A: D3 W1 w2 y
                : ?! y$ G% l4 e+ g
    } // end of class AuthorisedUsers
/ L* i, |. C' C; F; B! h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% g- M: g1 {, m. q; {5 J; @
Shanghai - 2007
# f/ ]- Y5 z- Y7 [( _' sAssignment 22 A: Q* q. d5 a
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)
. `) A/ y% O% l2 z( L, E4 u) T1. 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.% P7 X- _8 E3 E/ U+ C: D
The staff must be able to:
, c; _! Y1 z! Y' J" \! E$ i% p; Q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
. q7 N) e" ?* B  T: c( a) d& o4 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.) k, v8 k! T* G0 A
 The interface should provide a menu so that the staff can:
: W1 q5 ^$ G, {/ g) k+ q: ]a) Enter the names of the two Java program files to be compared3 P7 s1 F- f/ N5 A  U5 Q+ A
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 U7 m& v( u9 l" k* f8 C4 c, @
** 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).
! z' ?" n' }$ L5 v; D* SBSA104 Business Programming – 2007: Assignment 2. n' U* e( ^# T- e. I
Page 2 of 59 }. [1 [5 t! V4 D& e3 L0 d
b) Print out to the screen all the lines of code that are the same4 D: x- F3 t4 L5 j  G) Y
 Include the name of the file and the line number of the code being printed for each of the two files; a% R/ T" j5 T, y; b8 ^, ?" l
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
( E6 L* J# A7 z0 L6 f( ]# ? the name, username and department of the user" q2 M& w4 _2 ~( N! k
 the statistics of the comparison4 A& ^$ Q% t4 |  q3 G
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different9 M0 A, p( _- o/ P6 g  w6 T! |
 the recommendation for further checking
# f1 \$ G4 B% W. A9 d- 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
2 X. P) C- W& T& i/ f. U the names of the two files compared1 t) Y" v+ p0 b3 a/ k
d) Leave the program (exit)
& k( ?3 o% d5 m6 _& e9 ^$ x1 `, `The ProgramCompare class: (Total maximum 20 marks available)
7 O2 H. Z: L/ u: Q2. 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)
4 j2 a8 K, h: O! C1 G) L1 T: {2 _a) provide an error message if the files are not found or there is a problem opening them. q/ `) t2 I& p0 o+ g! p/ M
b) compare each line of code2 {2 y8 x1 N8 F" v
c) print out the lines that are the same' k& Z4 _) C4 |' M
d) count the number of lines compared / lines the same% H( b; Q5 k- f4 L! v5 O9 a8 r
The AuthorisedUsers class: (Total maximum 20 marks available)
6 r) T/ m9 B# x3. 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)
' w4 ?2 G; X4 Y, I. V. _% [4. Provide methods to:
+ o  j. n# M$ p- U% ha) 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- n5 ^* t- w( E# K
b) return the name of the authorised user) r9 X/ ]' Q4 |/ B/ o8 \2 c% L
c) return the name of the department of the authorised user
, \+ ?, ^' t0 YIndividual Data (Maximum 20 marks available)
- Z6 \% m- C$ u& D8 E2 m5. 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.1 M: p; k) P* ]7 T$ Z+ B
Documentation (Maximum 10 marks available)
. H  ^. I" Y% l6. 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.' {& X1 G* d1 F+ ^  b7 c
BSA104 Business Programming – 2007: Assignment 2
( E5 _" {- Q4 A* t" Z! z1 x8 tPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
9 a2 D6 v0 e( B/ l7 B/ ~不过你要翻JAVA的类库说明。你有下载没有?
: f# F: e  f& x; }# j查询关于对比的函数。貌似关键字是contrast,还有compare
. I, U6 K; k  U5 ~3 d, Y3 R3 s& t8 m# X6 Z2 P+ x6 `7 D9 Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- v  H$ ^7 O, V+ y" I0 n痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
) n! w. u( U9 f. L: ^3 L可以下载到的 是 jdk-1_X_0-doc( A% @# g  x2 Q

/ X* J' p3 {% ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-13 20:31

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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