找回密码
 注册

QQ登录

只需一步,快速开始

查看: 976|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * T- x5 S. ]9 T% w% g h0 K 9 B5 Q0 T. p# W9 ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
7 H9 y/ C& r9 M1 q6 Y; L//  ProgramCompare.java         Provided by: DRS
( ?% E9 U1 a6 D' n6 v* B9 N//
% F' J4 E) ?% w# l! B1 U! O& a/ ^//  Program shell for Assignment 2
; S3 l2 @0 \; A2 {- ]) ?  E$ i8 d7 ^//: n! s( _5 Z: W; w
//  Compares two text files line by line- P0 A+ _) H) j, c
//*********************************************************************
1 |. N9 Q' U! U9 t- d) i! J9 r6 O
" m. Y+ L6 w2 \/ [- J+ z# ]1 M4 Gimport java.io.*;$ T) E- o* S6 _/ W

/ G. t# Q" x6 X3 g" m+ q1 gpublic class ProgramCompare+ j! j1 B' J; z) x# y" H/ d
{
& Z; X  x2 ^7 g8 H9 D$ W        //-----------------------------------------------------------------
: w0 z& y6 B! b  C5 \% Q( E        // Constructor
8 x6 H- T" o4 C' D3 |        //-----------------------------------------------------------------) |& i# \/ q' t  T1 \
        public ProgramCompare()
6 q+ Q# v4 N+ z1 q4 j: O; B$ u( p        {
2 ]9 d+ c$ ^/ R% @        }
# R2 `. q4 [# s. C" L" J& Q/ n- Q* U
        //-----------------------------------------------------------------
* k) ?; b+ H9 y/ f# u+ h( o- v; a( h        // Method for testing that class has been reached3 g+ |1 L3 _6 l( n. i4 m8 c
        //-----------------------------------------------------------------        5 p, X* V+ ?+ I9 [1 g
* a& R3 x3 q/ k
        public boolean ProgramCompareReached()        
- }# J+ f" G6 W* O, G        {
0 D" \2 {; s* {' z$ {1 Q      try
5 Z- ~* r1 B$ U5 p   {         ; Y- V4 f, C! n5 A9 s# Y
                        * ~8 L3 Y% X1 S' b5 W* ?% A
                //********************************************************************
( F! m/ v6 [# E3 ~6 [                // Try-Catch Statement is used to handle exceptions - such as file not found
. E2 n' s8 w! }# R4 q                // Reading the files will need to be placed inside a Try-Catch - just like this one!- k8 H- H* U& m" p
                // For more information see page 534 of the textbook
: S2 C* @: s/ l1 ^/ ~3 S3 ?% o                //********************************************************************, P7 ?1 [" X" B# e' L
                     " ^# F) g) }+ d6 d  h
        }
, k! ?: r/ p% O$ \! ]             catch (Exception ex) // Exception caught here and message displayed to the screen 6 ^; r7 L& O/ W. r5 N/ q* w! P: H
          {' e. {( C3 x- t9 l7 l" h
                    ex.printStackTrace (System.err);4 {+ b- s: g9 p, f
           System.out.println ("Error message goes here"); // Replace this error message with your own          + w+ O6 d: O/ D+ e; R" T
        }  [* }1 X- W5 A/ S& ]# J, ]
                return true;( H" e" I$ Q5 n. V& n! g
        }
) O' G0 ^0 U6 h% y1 _' u  X
3 A3 N( `7 s& o4 l( n9 S; X8 |3 J4 |} // end of class ProgramCompare7 h3 ]2 u7 Q9 `9 @
8 k  @; I3 W: f3 f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( X: b9 ~' {5 _) X% H5 q$ M% K9 e& l
//  ProgramCompareMenu.java    Provided by: DRS8 j% L8 X; V6 h0 L0 h$ b  r
//1 W/ i" F4 Q6 c; T. u' P4 {
//  Calls AuthorisedUsers.java and ProgramCompare.java1 u2 ]  ?& z3 Y4 d7 [6 C6 t
//7 |4 w5 j& Q; R8 _; ^% A) O4 A
//  Driver shell for Assignment 2.; u7 e# ]3 C6 X; r6 k
//********************************************************************6 S4 Z, E$ n& Q# m2 ]2 n4 R

! R) R- h# V) L% rclass ProgramCompareMenu- E# o5 l& a1 v3 o" A2 B
{
- ^( ^4 _' C9 F- O' L! l: j    public static void main (String[] args)
: ~- x! h3 Z8 C4 C" W            {$ Q" ?3 h" l2 [! H" X( y4 p) t
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 f( F  m# |8 n6 z- d4 Z9 l                ProgramCompare reached1 = new ProgramCompare(); . S! B9 f" U' A# B
                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ x9 z# r3 G$ b; G' c' E: d                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 W5 I3 L8 P5 b                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. X0 L8 F2 Y: ?! A/ a        }
: a5 i5 O1 {7 z# l% q/ b}// end of class ProgramCompareMenu: V1 y) F2 N! L3 X" a
/ D& m! }! b" E, j, o1 r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 a7 F0 T" k5 Z
//          AuthorisedUsers.java          Provided by: DRS: ~' l2 d9 P& a& ^% T
//                ) H6 s4 {& O& Z
//         Program shell for Assignment 2- d$ G5 K5 L" u
//
  ]9 D2 B  Y7 p+ O1 M, X4 d//         Represents facts about an AuthorisedUser
% @& o, q4 N) i9 Y8 p: u- U; G//********************************************************************
$ E/ i! Q( Z8 b; E, d* P7 W. G9 H
) ]4 @. e6 L& U* p9 R: L2 Apublic class AuthorisedUsers
' V3 r! Q- A! ?/ X5 s    {  `/ Z% u- u0 G8 \  a- ?( z- t, E

8 e0 c% Q4 ?# E# Y        //-----------------------------------------------------------------
6 n* f5 g4 x, Z; L7 I  `+ _        // Constructor
; b! Z! A& E) `, Q0 R% q- D        //-----------------------------------------------------------------
# R& g% i  M% E+ n+ E4 I$ S) F3 B8 s8 o% L* w$ U6 E5 N3 L8 E, O
        public AuthorisedUsers()
- G* t  q' P2 g2 `) ]% }4 I# Y                {
$ F( l) F5 x0 W3 `( |                }9 `5 E. G- ^# i! K5 w

: M. [4 \1 v  `8 B        //-----------------------------------------------------------------
* ~" a$ r9 x4 C* e4 m6 S2 C' O        // Method for testing that class has been reached. e4 w5 x& a" e9 ?) Z
        //-----------------------------------------------------------------       
' k8 n  h+ T; n: t% P! X1 h        public boolean AuthorisedUsersReached()
, s/ M2 ~% g0 Z* t- ^                {
1 `: q" f( [) `5 d) a& x) k2 D                        return true;                        + ?6 {/ ~  l& O2 Y
                }9 v, h! c  z- _$ g! v
                2 Z' S8 d8 z0 c( Z
    } // end of class AuthorisedUsers
. b  x' `) I) h, S' S$ N& |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 k6 G: D  Z) K2 o3 J
Shanghai - 2007
4 K2 d) m$ [9 s8 h* C% d, eAssignment 27 D- F+ n  k  T4 O
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 E# k: W2 T# i& g( L6 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.0 I- |, R' L- a0 d' K1 n4 j8 v% @
The staff must be able to:
- p( w8 r- V/ ?0 t Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.- ]* v3 W* ^* Z( u: j6 {& e  v% N
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.
; b+ k+ P& y* K. d2 \/ Q# j, Q The interface should provide a menu so that the staff can:
0 A  f- P; l3 l) L: m$ Ma) Enter the names of the two Java program files to be compared. y) r! X) u2 z8 |0 N. N
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
% V5 f/ K: L/ h2 d! w7 _** 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).
: g8 N! U2 C; ?& kBSA104 Business Programming – 2007: Assignment 2; v3 J' G1 r2 B: c6 `9 P% q" T0 J3 p
Page 2 of 5
  q( H: a4 `' A) D$ z" e/ k+ Cb) Print out to the screen all the lines of code that are the same# n4 ]" \7 m5 v/ B
 Include the name of the file and the line number of the code being printed for each of the two files
5 M* C. ?" N, w2 c4 n0 Y6 Ec) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 T4 w! a4 M4 f  q' `6 a  K/ i; @
 the name, username and department of the user3 c" a+ z; V2 V" A9 Q8 i8 ^
 the statistics of the comparison
7 l, G1 v3 o9 F+ M0 O# e- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
+ \) `: Q6 ~0 u8 ]  z' j the recommendation for further checking
& F$ r3 h& g1 S7 Z/ B+ |9 ]- 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 closely1 S8 \# D: s# p  H' _
 the names of the two files compared6 j% N; n% V! O& H; r, j" W
d) Leave the program (exit)2 u, A' r" S0 Y, \7 }! }
The ProgramCompare class: (Total maximum 20 marks available)6 x7 a5 L9 Z0 m$ {/ X  r
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)
$ m1 \' [5 T1 F- |+ Ka) provide an error message if the files are not found or there is a problem opening them! V2 y/ ~( F: _% u: `9 I" F0 ?- F9 z
b) compare each line of code1 |, v, Q  Q) q6 o) h
c) print out the lines that are the same9 m8 Q) J2 H0 @
d) count the number of lines compared / lines the same
/ p' C. I$ Q: O' {The AuthorisedUsers class: (Total maximum 20 marks available)4 f0 u/ j$ B: c( L
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)$ P8 P4 K+ ]1 J* Z4 M- \) j
4. Provide methods to:1 E. N6 L& F; q3 c) e# h
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% K! `- x+ ]1 z! G* ]! I
b) return the name of the authorised user
! H; _6 n) U4 Z' fc) return the name of the department of the authorised user) j+ f- e. E: P! {0 x; i
Individual Data (Maximum 20 marks available)
7 p+ M+ b# Y% m7 s8 W3 Y: a5. 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.% a  j) \3 G# }, p' h: a  o6 s
Documentation (Maximum 10 marks available)
% Y" ]3 u3 B# n3 I; T- 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.1 J$ M9 A4 r# d. u7 k- O$ i+ K
BSA104 Business Programming – 2007: Assignment 25 k3 b7 `' C8 V" n* Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
7 D* t/ f3 x+ L# U1 C# D" z不过你要翻JAVA的类库说明。你有下载没有?
( |0 U6 j; z: \4 C) z1 Z) K6 J' P# A查询关于对比的函数。貌似关键字是contrast,还有compare
  w, a' D- s8 {# X
% d( d( j# {# p6 H5 G7 t[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
6 s) H7 X* V9 ~. e: q& Y0 i可以下载到的 是 jdk-1_X_0-doc/ I- b; N2 ~+ |, c1 Q% w9 P

& Y2 x% j) N! k7 W" z+ @[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-29 20:25

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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