找回密码
 注册

QQ登录

只需一步,快速开始

查看: 942|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 [* P/ T0 \5 b. W+ F# S 8 D0 }9 ]( W& C( o5 d$ i/ f
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% e! \3 Y) F9 J  V; N
//  ProgramCompare.java         Provided by: DRS
8 q, |+ E+ J* M5 l//
; X. }- X+ g% B, R/ F9 i//  Program shell for Assignment 2) b, S$ |  \9 {& s3 ?7 t" Z* p2 _1 n+ H/ D
//0 C- M4 n3 `+ _7 P
//  Compares two text files line by line$ P- l; w, G$ b# g% @4 i
//*********************************************************************% `( m" {% \* ~* Z  L+ k2 @  r0 r+ q

- g; L6 E1 J( l$ c2 g9 oimport java.io.*;" n7 Y* K- Z; O- \9 w

  ?" a5 [9 ]7 P* S) `9 Y& r  L% \) dpublic class ProgramCompare
9 D& G! C( W/ w' T- E/ U{1 ?( l% ?% B, H+ u
        //-----------------------------------------------------------------
  X/ b4 U/ n* h" R4 x' R4 R5 B        // Constructor
, k. C- q7 v  Z& G$ Y! a0 \# m8 A        //-----------------------------------------------------------------" N- {, V/ j. C/ \, P/ V! q% b5 f
        public ProgramCompare()
, K7 F* v; L4 D1 N1 W        {
# A4 f5 t/ W# S        }' o* V5 B- @0 P  j0 z

9 ?1 W6 l) T2 s/ Q" V        //-----------------------------------------------------------------
" L: m) C- f$ F" d8 u        // Method for testing that class has been reached
7 {; V5 n) [' `9 Y9 k        //-----------------------------------------------------------------       
  G5 S; e( w$ P( Q4 ?
8 V" o2 r. u. A# s8 Z        public boolean ProgramCompareReached()         4 Y1 y) @: t8 \# w+ p7 f
        {
2 H4 d% B2 ~. g2 M5 A      try . `6 b- ]7 s' L; y
   {        
2 b% w5 d1 t  E) L3 u5 {% e  V/ P                        4 q/ b/ k/ c  x
                //********************************************************************% K  `( {2 A9 V" s. l' @6 n* z. Z8 _0 D
                // Try-Catch Statement is used to handle exceptions - such as file not found + O: d$ ?9 n( f% O( A8 n
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  V3 J; o+ A9 J6 g                // For more information see page 534 of the textbook
" E, Z4 ^+ E* |8 M% N                //********************************************************************
0 j' E; {! O9 G9 H0 l; o  w, F) R                    
6 ]6 q# M$ c' [/ n# [        }
* j( Q8 P! @3 c0 o             catch (Exception ex) // Exception caught here and message displayed to the screen
# m& V) l4 @0 ?. r) O% _; o          {
% _$ R  M' a5 v5 }! Z, w; q0 O$ u2 e                    ex.printStackTrace (System.err);
& S  q+ |- Q% I; [; t1 H           System.out.println ("Error message goes here"); // Replace this error message with your own          $ w+ `/ [# C9 J/ b* {7 [% q
        }1 \6 @  b  U3 I7 x0 e1 y
                return true;
2 w1 i" V1 c1 j" R& O        }
2 ~; |' f3 ?0 A. ?! \4 l- E' R+ a: i2 _! k6 K! V. S1 w
} // end of class ProgramCompare
1 X- s; |- g. Y% i- f" q1 b: {6 L! K, M- |0 G3 B0 i/ _) }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 {3 p7 `" a0 i4 s
//  ProgramCompareMenu.java    Provided by: DRS
$ ~; i9 T( e  o7 @: B//: `! a; w( m* j: C, _- Q  g2 X
//  Calls AuthorisedUsers.java and ProgramCompare.java
% u2 E2 X, Q) d* x7 X6 M; L5 {//
+ m$ Y3 ?9 N1 s& a( l& L, P! ]* I//  Driver shell for Assignment 2.
1 J8 a/ g  z# Z# n5 f3 v- W( P//********************************************************************8 l% P- \9 j- {. q* G: i
) ]3 y2 ?, C( S( y0 X
class ProgramCompareMenu
' v3 A6 G4 j- n' M7 ?. }9 w{% |. R) G/ x* _, a
    public static void main (String[] args)( z; z1 U" m9 Y* F+ C
            {
6 l$ C, g: c  Q' J& [                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 t6 h/ T6 p& J0 H: q
                ProgramCompare reached1 = new ProgramCompare();
- M3 o& T/ C8 |2 _# Z+ X) [/ [  a                AuthorisedUsers reached2 = new AuthorisedUsers();        8 P% W4 s8 B# {, H7 Y0 ~/ n
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());* f3 y) n* k2 f
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 ~; _9 b: x8 n, m8 f        }
2 e: ]& Z( V4 N+ q$ O4 ]}// end of class ProgramCompareMenu- Y6 v+ |3 S4 K0 Y4 g) q

& T2 R' i1 E$ Y9 |% ?0 @" a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 v8 z: w! ]: N! f& R$ g//          AuthorisedUsers.java          Provided by: DRS
" R4 r: H3 K# C//               
/ L# @+ }6 ^' @) w: U//         Program shell for Assignment 2! p8 [5 K+ b# n1 s1 e, m# v5 a
//* f& q, V: U5 g( s
//         Represents facts about an AuthorisedUser: v! l3 I# p5 _: m5 Q1 Y
//********************************************************************0 m: u; T/ f6 @9 T1 a3 X& {; Q

' c: h( G% }9 r! K5 X1 H0 d6 Z8 Epublic class AuthorisedUsers% d8 F! F# i1 N5 x% z* T3 ^; E
    {8 p3 [: L* @- F) R+ C

9 ^+ H- t; f3 ]/ ?8 I! h7 C        //-----------------------------------------------------------------
. a# d& u; h3 T& ]# ^        // Constructor2 g  s5 N, B& K! `8 d
        //-----------------------------------------------------------------
* Q; L0 u) d; I/ b4 }/ \/ t1 T
1 s- v( ?" k; l' b" o4 O        public AuthorisedUsers()/ J5 F. ]2 W3 A: E5 E5 n
                {6 }( o0 a- L; W' ?& j8 h
                }
% e2 n; _" |% [: z: v# Z7 C; B  Q+ H( p/ C% I. C& v, o4 ~; o
        //-----------------------------------------------------------------
4 `, d" |8 a7 f2 o9 @        // Method for testing that class has been reached8 W, T; p( ^2 K+ ~0 L# i& l- m- B
        //-----------------------------------------------------------------        & Z7 q6 b$ `* B6 Z+ e0 p
        public boolean AuthorisedUsersReached()
% n4 I+ Q3 Y6 ^7 k. p4 [2 ^) B                {
8 y9 J" j4 v' I/ ?% W  g  i                        return true;                        " D8 y, a  ~1 {0 I. m) g
                }
; Q# _% e+ @0 ]6 X" Y               
" C2 N( N9 h2 K/ q4 c- G+ ?    } // end of class AuthorisedUsers0 ]# e* J% ^+ f; n, y  F5 X
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
$ l, j. o8 C. {! w1 r  cShanghai - 2007% l8 C" P: E$ E
Assignment 2
+ t# q" k7 P& |; W4 k2 MDeadline 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)
# ]4 J0 c2 C, P3 H5 T; M1. 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 c. p* i( q  }* wThe staff must be able to:
4 f/ Q, A) k' I/ o( k6 z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' c3 t+ A! Z9 g3 v4 T/ N; a. I1. 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.1 U$ O- H$ H8 p: E* y! P
 The interface should provide a menu so that the staff can:
1 X5 ^9 [( n- G5 h5 Xa) Enter the names of the two Java program files to be compared+ ~% h# y2 c! z- P: B7 B$ G5 O2 F
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program., b9 {: C2 s2 V: W' H7 L
** 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).
3 p) z1 T* \. N4 \: T/ G# l2 C" ]3 YBSA104 Business Programming – 2007: Assignment 28 \* z7 \4 z+ \3 u
Page 2 of 5
% w/ r; ~/ O5 c% S+ }8 ?: Wb) Print out to the screen all the lines of code that are the same9 F$ I" Q) V1 h5 X
 Include the name of the file and the line number of the code being printed for each of the two files3 [  T8 d6 R4 N$ [7 H  M
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 Q! h) f) p# g/ {4 h the name, username and department of the user
) B9 L5 f# D; C( | the statistics of the comparison
5 D2 f0 X0 c; o2 x- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different7 Q' T: y0 ^( k' y% Y0 `/ P: P" ]1 |2 t
 the recommendation for further checking1 X0 y$ N0 l/ f0 q' ~
- 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
% _8 Z) o  m5 f/ j; N  U' F the names of the two files compared  B* ^0 [  ]% @' t) K
d) Leave the program (exit)
! S" s$ F/ |8 j  N! yThe ProgramCompare class: (Total maximum 20 marks available)/ O& K; x6 h% V; E: R9 j" `6 }
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)
: g- r* i% G2 v) a$ Za) provide an error message if the files are not found or there is a problem opening them
& l# A& w  @" ?, Mb) compare each line of code
0 ?% p5 u# B& rc) print out the lines that are the same4 l( d( J5 Z* c8 R8 F
d) count the number of lines compared / lines the same
$ l6 ?7 N* \' {+ c0 b" x* [The AuthorisedUsers class: (Total maximum 20 marks available). X; _. e' _1 D) [$ M
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)
6 j. k- u( h" B- X4 g; E4. Provide methods to:
/ `' u/ s& M! X6 a" P; Ca) 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
" Y0 {7 K4 P1 [0 T2 H. c2 tb) return the name of the authorised user
' I7 t& c9 P& Q8 lc) return the name of the department of the authorised user
  D; d6 @8 z8 X- Y' \, Z! t0 XIndividual Data (Maximum 20 marks available)7 W: B' H6 r% W
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.
' @9 G8 ?) H  X/ @- [Documentation (Maximum 10 marks available)
" z+ Q5 I; H* H% r6. 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.
( G+ u( S: ^- \3 f1 A' VBSA104 Business Programming – 2007: Assignment 20 o  D0 _: q/ q  |
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 d! K3 B; `1 r" u3 B
不过你要翻JAVA的类库说明。你有下载没有?
" P/ f- f" D$ W& w* H8 z查询关于对比的函数。貌似关键字是contrast,还有compare
1 P/ l4 f0 c: q# x; J$ Q9 [
0 ?* q/ G/ V% J5 K[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -6 B# m; s4 l) l1 h
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 M& c" Y( \" y# J2 M- q可以下载到的 是 jdk-1_X_0-doc
- O1 O, C! e3 Q: V/ r2 K: r7 m# A$ T# a- Z" C; ?9 i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 22:58

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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