找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1308|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 7 [2 U. Z2 D) T" v/ w5 \: w 3 o- B, l5 |, ]- l. {7 x" y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 V* O( ~3 _& t9 U
//  ProgramCompare.java         Provided by: DRS
; s" x1 Y( Q5 L; u# e+ T  r//
- p, l4 g7 v+ Q: n//  Program shell for Assignment 2
( o2 J* K% Y: i" E( p/ o: ]" ~0 s//
. R1 ?8 V5 X  z+ i//  Compares two text files line by line- ], ]/ F% B  x& O, d: ^0 z% L% p4 S& f! m
//*********************************************************************& i, F  j) }6 _6 s# |
% R' ^* q+ \' S4 X9 L
import java.io.*;
$ G6 Z! b; d" n+ l5 i2 Z  l
) i3 ]' i! [8 @public class ProgramCompare% X( R: [0 l, H: M4 k4 Y' e
{' l2 L  N# T, J4 u
        //-----------------------------------------------------------------" |3 I7 o' L9 G: \: e
        // Constructor9 s8 o! ], [! G8 P0 P
        //-----------------------------------------------------------------1 b5 q' L# Q& G/ n! E
        public ProgramCompare()) @" Z8 u9 f2 t4 b/ n, ?4 V4 P! I
        {
3 _0 B2 h! Y" A4 h/ L# t        }
- c1 E/ k* u5 B$ E% h0 w  M( x* m  y$ d2 L3 |6 L
        //-----------------------------------------------------------------
( M4 N0 H. _- k9 l5 q1 R2 N0 `        // Method for testing that class has been reached* n4 R4 ]+ D7 y) S/ i% Q
        //-----------------------------------------------------------------       
" D& F3 I7 u2 @2 |
, M% O( u$ y# ]% x% F7 y6 N" f8 E" c        public boolean ProgramCompareReached()        
& g9 T, F1 F# h4 c        {# H6 ~) h" G1 N
      try , G6 t( a" q- [9 c/ m
   {        
# F6 C& T4 v5 ^( l                        , {; W+ ^) X6 d1 Q) n7 a: M3 T1 K
                //********************************************************************
- J+ `# M- Q  S) S. ?, c! _5 s                // Try-Catch Statement is used to handle exceptions - such as file not found
, F) g7 M! D/ g# D# }                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 v4 {# |4 p* V* O                // For more information see page 534 of the textbook
# i; A3 c* @  u( p! u                //********************************************************************1 E$ Q0 }1 _1 G2 \
                     & t! s5 D, ~" j0 k5 W
        }- B$ @) _6 e  l: \2 G
             catch (Exception ex) // Exception caught here and message displayed to the screen 9 q: }3 y, P9 Y! s6 B% B. x5 e
          {
! t: x% N5 q8 C8 P- }                    ex.printStackTrace (System.err);
+ H. s$ L: m: T% J4 z           System.out.println ("Error message goes here"); // Replace this error message with your own          , T8 Y9 d; P& O3 L& R& R) ~% a# E# ?
        }' G2 o5 N5 }% ]5 \& z
                return true;8 `- z: O! U5 t4 Y7 _5 K8 I7 _
        }
# H0 l8 g, d' f5 D' O0 K0 ]
7 `& L7 q5 L0 a5 ^8 D( [} // end of class ProgramCompare3 r! i! R. l5 n, H$ Z% C6 ?
0 M7 k* j; P! y( E% @5 t0 \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
& l$ ^, H" _% m5 d//  ProgramCompareMenu.java    Provided by: DRS
  E- |+ E( ^* H. {" Z0 l& ]//8 K$ O  l( |. o3 \) ?6 }
//  Calls AuthorisedUsers.java and ProgramCompare.java
+ G7 [# p. B, e& r4 j# J//, O& P- q9 I# f+ ^* f
//  Driver shell for Assignment 2.3 G  ?; h+ j. h$ Y7 q* Y6 @
//********************************************************************
5 {6 I* R3 N  q: R0 q4 @: V. D" E; n+ N4 n/ E) x: I
class ProgramCompareMenu( u3 y$ p$ D7 S1 P9 W$ |
{" }! }3 Z0 m* o* u
    public static void main (String[] args)
4 W) ^& a! t5 c! F* B' @: x0 C            {) Y" D$ Y/ s) v# o) s; Q
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& }9 d. Q, s3 c1 S6 r
                ProgramCompare reached1 = new ProgramCompare();
$ L6 n3 K$ {& B2 t( W                AuthorisedUsers reached2 = new AuthorisedUsers();       
; ?5 A% J9 I  m, X0 v2 a8 {                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ J" Y7 t0 m1 s$ |                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        2 U/ M4 F( `& u# q  \4 ?
        }
$ z+ A/ B+ ~: g1 Y6 w# p$ o7 {# p}// end of class ProgramCompareMenu* l* Q; _. w- \" D( i/ H/ Z

* x) _1 J* Z: [8 V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' P2 ]2 r& ]: Z3 ?5 c" h: q- K+ t  F
//          AuthorisedUsers.java          Provided by: DRS
% J% }; w( z1 c& [0 U9 U+ q//                5 S. I7 U6 Q  D5 {
//         Program shell for Assignment 2: r5 X  [: Z' a3 i# o5 Q/ @
//
1 i" C/ [, s/ D1 I. P3 j  b7 ?8 w//         Represents facts about an AuthorisedUser9 l" u- d- k1 S+ x, H3 C1 d
//********************************************************************' T1 _8 S" ^, N/ ~& j

  o# @7 e' _' Z$ gpublic class AuthorisedUsers
3 A, S5 o9 w4 r. W" x/ v" `    {2 Q# D3 z$ G3 ~4 k0 M/ x

4 B8 @5 x/ m; r3 b        //-----------------------------------------------------------------" V. B5 M8 w3 Q) N* W7 i
        // Constructor
/ c' v) i" K9 Z& j        //-----------------------------------------------------------------! ?! G4 v9 i* H6 d; b, @# n

) A: ]; c& Z- w        public AuthorisedUsers()# i1 e9 [$ B, l. {4 o/ ]
                {5 u9 S" E& e+ b5 K$ ]4 a
                }
1 b' J8 z8 T. D. ?, G
: p) e" @. U; V' s        //-----------------------------------------------------------------
* t7 x  J. a" C        // Method for testing that class has been reached2 f/ ~7 L+ O1 ^% T
        //-----------------------------------------------------------------        & r+ ^1 V+ E+ j+ R
        public boolean AuthorisedUsersReached()9 N- \1 S7 e& K  C, l
                {+ \4 ^& G- \; N0 M8 j) ?* H3 S
                        return true;                       
# {7 w9 S( W9 @( g/ m. ~. T                }
9 e& d( W* T& [  E# c% \  I9 p               
, \# ^: f4 a/ G4 u    } // end of class AuthorisedUsers
! O. K4 g) ]& ~! s/ o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
. }+ R0 ?# O; G5 _. lShanghai - 2007; l' k: q- ?! n( [( d. p- q; u
Assignment 2: ]) D& {; [6 A' 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)9 d1 ]# V6 D5 `$ g! C
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.) B- S6 c' V+ [' Q! P
The staff must be able to:4 h5 c( \" z8 e: j- B( B6 ^
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 A6 O4 ]/ o8 P$ a/ |! d9 g8 p1. 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.
+ c0 u( R/ C0 w The interface should provide a menu so that the staff can:
4 H- S/ C' ^! ]* ?* Na) Enter the names of the two Java program files to be compared
7 s$ _  p) ]' P9 F+ Q/ z' \ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 W# ?% B9 K- @) a$ h( G/ l* G** 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).
5 a" [/ C4 h$ o) m; O0 E0 OBSA104 Business Programming – 2007: Assignment 2- W% c* `3 r+ O5 i8 [" S
Page 2 of 5
3 P% D; T9 z8 r; ?; X# j: P( Y/ U! wb) Print out to the screen all the lines of code that are the same  M& x# Y4 P' j5 j2 Z
 Include the name of the file and the line number of the code being printed for each of the two files
2 A; B3 e9 J8 T) G) }' C! h8 C3 m+ ~c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 S1 {; j3 F, Z, k. q- d) Y' o0 U the name, username and department of the user
2 f- z9 C! d9 Q4 g  {- d. H! g the statistics of the comparison5 o# i. L: P. f6 p& H3 b
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
0 t4 v( Q! L& x) N2 e the recommendation for further checking
9 f% n- S, [+ P/ |  v- 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 closely5 G' w* L- T; v% K( P% p* _
 the names of the two files compared
  h8 M8 E: \. r3 n3 V  y8 nd) Leave the program (exit)8 K7 G3 K* @# n3 R4 j9 _2 I0 r( k
The ProgramCompare class: (Total maximum 20 marks available)
# I$ ]  n" [/ f1 R, F2. 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)
  f. o2 N* C' r: d) W* f, za) provide an error message if the files are not found or there is a problem opening them
- Q8 H. K4 M$ J, C+ ~- m; `3 C7 {b) compare each line of code
8 A- a4 n4 Z  y4 b( q$ Lc) print out the lines that are the same
$ i1 ?6 j" U; c  E) hd) count the number of lines compared / lines the same
; u  x+ k5 I) sThe AuthorisedUsers class: (Total maximum 20 marks available)3 @1 d8 I* a8 E! ~3 N' \. ^5 U5 W
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). v0 G# O% E! M  A3 G# B6 i6 u
4. Provide methods to:5 L% M" t' [0 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
/ c! S+ `- S; F8 Fb) return the name of the authorised user
$ \# c; {$ w0 R1 zc) return the name of the department of the authorised user
3 l( O4 C4 \; }" |Individual Data (Maximum 20 marks available)
  s1 a- _3 d  s, J, w5 E# c5. 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.+ N1 i0 T  e4 T, b! z; n# F) W
Documentation (Maximum 10 marks available)
) _$ _; {% t! C  E( M. }; 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.5 s" F" T4 E! L1 u% i% [
BSA104 Business Programming – 2007: Assignment 2
3 T' `8 W/ A* e- ~Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了* A" W" y8 n; D
不过你要翻JAVA的类库说明。你有下载没有?* M) ~$ B9 l- |2 S1 y" w6 _
查询关于对比的函数。貌似关键字是contrast,还有compare
+ G/ j4 e) e! |9 ?& ~" W/ Z. X$ ~! I& _$ |# I# l' t& A2 f8 }
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
6 g9 k! z7 {6 F. y/ }9 g! I# \' r5 S痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" ?8 h8 m, |8 p" p, Z4 Y4 ?可以下载到的 是 jdk-1_X_0-doc
8 ~% {' [) x  R, h5 q- o' A4 h1 e6 y" W9 \! R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-23 16:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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