找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1292|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 7 A# b# {1 w/ Z. p, ]- n/ S 1 ~6 R8 L5 V! E! T- x
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. O& m+ `6 Q* k  [1 r: Q3 W//  ProgramCompare.java         Provided by: DRS. d  ~. P5 a* J8 @
//
8 y' {9 E+ E/ Z% i) a8 A//  Program shell for Assignment 2& t/ S- Q1 d/ ?* G( d: |5 @
//) Y! j# n9 |, R
//  Compares two text files line by line
! ~; D; l2 P' S3 ^! C//*********************************************************************
0 `9 X, ^" M' m# r- h) U* ?# z
4 A. y4 o+ [2 d  S8 himport java.io.*;" e, o1 E/ X9 d1 v+ O7 b- E
, _6 N) i6 a; B; _4 v
public class ProgramCompare
( \% z, L) X" j{
) L1 s+ D6 g7 K7 K        //-----------------------------------------------------------------; R) |! |$ F0 I* R; a
        // Constructor3 `5 }0 u7 e/ n- y% i4 M* ^; ?& N
        //-----------------------------------------------------------------
4 S$ P3 ^" R# }+ U        public ProgramCompare()$ X% }- w! }6 P# ^. C+ V. T
        {
5 {! L+ k* C- L3 u+ T4 Z" `        }% p( v( j: R+ ^
6 B' X/ d1 K$ o
        //-----------------------------------------------------------------2 x" J& N8 {. ~* {# }! ]; f6 D4 j5 A
        // Method for testing that class has been reached
& ?; G; Q$ E) {' C1 D( m8 ?9 n        //-----------------------------------------------------------------       
0 |! |' I5 P: Q0 p4 |
- ^% p* @* q  m        public boolean ProgramCompareReached()         : S+ ]: D. z% O  N: y
        {
: {# y- K7 m8 y' I      try 6 w" J% U9 v1 i# V8 n8 ?" T- m5 l
   {        
8 [; o+ m% i# }7 W                       
; A2 ]! G2 Y% B4 B  v& p                //********************************************************************
/ s' J4 s) W0 M- U: Q6 |3 B1 W                // Try-Catch Statement is used to handle exceptions - such as file not found
& d9 z9 b8 e' Q3 P9 ]5 _9 s                // Reading the files will need to be placed inside a Try-Catch - just like this one!. `) Q) z6 u/ }% C2 [: K
                // For more information see page 534 of the textbook5 B+ ^& l; F+ C/ S
                //********************************************************************
+ y: z7 o8 n* V1 K  a                     , U# ?2 H. W3 W; ]4 u
        }% J  S0 o- a! V. u4 k
             catch (Exception ex) // Exception caught here and message displayed to the screen
$ G  b' Z8 j8 _8 `7 U  D          {& N% h+ N. {' B; \
                    ex.printStackTrace (System.err);1 j# @# {& ^+ E' [0 E
           System.out.println ("Error message goes here"); // Replace this error message with your own         
% S2 ~9 [; O/ d. U5 P        }: @& m/ e( g/ ~. \; G" [: |" w
                return true;
& O- V: q* n5 R; h        }! z' l) e3 T4 {+ Q8 ?

4 t4 y8 \' w1 p! u& b6 M, n& c} // end of class ProgramCompare3 ^& d: K* t- X

+ I- S! q+ H/ x+ I, B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
  M- j5 J. `9 r0 u( e8 I( |0 P//  ProgramCompareMenu.java    Provided by: DRS  D5 b+ d! Z  m4 [
//
  B0 u" R8 l" T  i, D! W//  Calls AuthorisedUsers.java and ProgramCompare.java+ g( d, R# b8 K
//  ~/ B9 ^7 |2 b( v6 A* n. ], ^
//  Driver shell for Assignment 2.
" t$ |8 |; i& f& t( V- P//********************************************************************' @+ W7 s: c9 L! t
. I6 S! H3 B0 m: j- q( `
class ProgramCompareMenu9 O- a5 i/ w6 Y% ?7 |7 Q
{
8 j. z" \. `5 C8 d3 ~6 i' \    public static void main (String[] args)" l' ~! G5 n, c5 S# e
            {
: [! o1 R5 W; n5 \2 d% W2 A                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 f9 J4 T+ Z7 d8 J
                ProgramCompare reached1 = new ProgramCompare(); " ]2 q# L' d9 V9 z7 a
                AuthorisedUsers reached2 = new AuthorisedUsers();        . I5 o; G7 a9 w
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());* P, B1 E1 y0 i2 m  l* N
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 y% F+ @  o+ i8 K( W$ T! X        }
' _+ r- T9 R) |, d! n}// end of class ProgramCompareMenu
; Z, x* n2 R; g3 M$ c: u* }: n1 e; h+ _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 B3 n6 ~3 V/ T& Y! w, l  \//          AuthorisedUsers.java          Provided by: DRS
! o$ z. F- g# t! L//                8 C2 m' u5 U! |5 R* E: v( O
//         Program shell for Assignment 2
& {9 G. Z3 j' F1 Z. ]' |//% ~1 h. P* `6 ^% Y3 I6 D- y7 a
//         Represents facts about an AuthorisedUser! d' P2 Y0 v8 I( l8 I% K- L  H
//********************************************************************
8 _* m$ Q/ j+ ~6 |# O5 {
6 ?3 f1 X/ Z. `2 W: i3 kpublic class AuthorisedUsers
: ^- k8 d- q4 K    {2 G9 ~  u! w. Q7 t0 w

, |# H$ U) E( x0 E        //-----------------------------------------------------------------
; Y; F: Y4 r& Q( @        // Constructor& K' g) W; W( p6 b
        //-----------------------------------------------------------------
$ {! j# X6 V: ^! D7 I
7 [4 }- ?8 w& m: ?        public AuthorisedUsers(); A& C! r% K. r! C, b
                {9 N; [7 N( ]& T; J$ h! Q$ ]- O3 z
                }: U7 ], X: j7 f2 \( {. L% S

% q$ H' T! h& x! ?$ J  g, F& e7 U        //-----------------------------------------------------------------
1 Z& F4 q9 C$ j0 \5 p9 ]5 r8 B        // Method for testing that class has been reached
( m$ k2 C1 i, L# U9 Y        //-----------------------------------------------------------------        5 A* b2 H# F$ X' w' S0 J* j# i, o
        public boolean AuthorisedUsersReached()3 Z0 s0 h& b; D" z5 r
                {! p! a+ [: E2 E7 j/ M
                        return true;                       
; R$ j! w% |+ N% M0 g4 K0 W' P                }3 m" u! W8 C5 q; h6 S- y
                  h$ f4 i" V" I+ \( _1 j
    } // end of class AuthorisedUsers
" t- X: _* [  \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
* ^' O- L. K# x- a& Y+ FShanghai - 2007
; D# L* c9 i& {/ X8 \0 PAssignment 22 X0 L0 F( T5 i1 i* _- N: y3 X- 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)7 q% ^5 i/ X/ H
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.
4 I" C4 Y0 x+ \5 B, _9 AThe staff must be able to:; k3 j4 x% ~4 R/ S/ z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
( {2 G- Z/ O! z: _+ V; X* [. r1 x4 ?8 B3 [1. 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.: n9 A( O# p  M+ R
 The interface should provide a menu so that the staff can:5 R: Z" d: Z4 {5 t! z
a) Enter the names of the two Java program files to be compared
3 u# m/ M, G0 Y6 K7 N$ S  z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ {, j0 \" `  F1 m6 |% E
** 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).
& ]) _9 J( G: QBSA104 Business Programming – 2007: Assignment 2
( t2 U" ?% }& I0 C( u9 CPage 2 of 5
; B( t% f9 r8 O, |- ?0 }! Nb) Print out to the screen all the lines of code that are the same9 ^& `* V$ x4 D$ w6 s! r" I( B
 Include the name of the file and the line number of the code being printed for each of the two files3 p" ]  C, b' c
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared* |5 I0 ]0 ^4 x
 the name, username and department of the user
. S/ w, U; |" ?, F, b4 R4 C, h% j2 L the statistics of the comparison
! h- ~$ @/ y$ C1 a- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' f3 J' {. g+ T  F0 r+ T: Y: _ the recommendation for further checking1 S- {" v$ P7 g+ W7 g
- 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% ?& w8 w1 F( }
 the names of the two files compared# s' P6 r3 q0 A$ H/ Q1 P1 J2 L2 ]
d) Leave the program (exit)0 ^: x9 z4 V  d& p9 Q$ e
The ProgramCompare class: (Total maximum 20 marks available)
. s' M/ Q1 D: p; x# t! W2. 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)
' S6 M& i! K! k# p" M! n7 d  g& ja) provide an error message if the files are not found or there is a problem opening them
- O( i% s$ \3 {# F  db) compare each line of code1 v7 e) F4 X$ u6 c% H1 Y: X  ^4 M
c) print out the lines that are the same( F" @# z3 O$ E. ?: k2 v
d) count the number of lines compared / lines the same
, Q2 l) V4 |2 l" wThe AuthorisedUsers class: (Total maximum 20 marks available)
2 u4 W7 A( z2 N- |4 k/ C4 y3. 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)6 p, v5 V# d7 b8 j3 y( z) x( ^' K; E
4. Provide methods to:. m& d2 M# a3 A" A0 Y# d9 L8 C
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 match5 ?- Y5 V4 i) h% `# |
b) return the name of the authorised user9 m9 Q$ u; T8 s1 u( f( X1 ?5 E
c) return the name of the department of the authorised user7 U+ b0 C2 ^* [0 K% o+ J
Individual Data (Maximum 20 marks available)
' h& O0 M9 x& u" a4 X. B5. 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.
# K( x8 e. I( \6 E9 v% mDocumentation (Maximum 10 marks available)
% y9 r( E! u" }$ a  X, H/ 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.' W, g4 H& V6 m) l! E; _$ S9 T
BSA104 Business Programming – 2007: Assignment 22 U! N2 f% f9 D- q$ Y+ o4 a8 t( `
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" z0 ?2 \( r( T* K( O
不过你要翻JAVA的类库说明。你有下载没有?! u" q/ N) c7 c7 [
查询关于对比的函数。貌似关键字是contrast,还有compare- t6 O: A5 H$ v
) m, `5 r2 a) m: X9 X* Y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -$ E$ ?% m1 S9 a
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
1 H% \: a' d- Y' l0 u3 D5 a% d& z! ]可以下载到的 是 jdk-1_X_0-doc
0 @3 r% r& J9 H  W- m6 n$ a' b5 A- y/ x* B- H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-18 00:12

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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