找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1145|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 a% @' {# ]& v 6 c; u/ g! C9 K5 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 | 显示全部楼层
//*********************************************************************
: U. S  ~; G+ x! i$ R//  ProgramCompare.java         Provided by: DRS
6 {% s9 f9 \. N8 H3 O6 |//
7 K& v6 Z4 _- i0 J6 Q7 i//  Program shell for Assignment 2
& a9 m, l' \# G! y//; L# B! S* a) l0 d" d* u# ]
//  Compares two text files line by line
. ~. [1 [3 M+ {9 X* L( j//*********************************************************************
/ |# M. Z# Y6 Y# }. G7 N" r& X( A5 h9 u" v) u
import java.io.*;+ L7 U6 Z. T" A0 x- J: K3 M

9 V' F( c( V  a- k. Y* O5 _public class ProgramCompare
% h3 t% |0 a$ `6 ~, C  |{" n4 r' i2 g' w! Z, t' W( ]$ y
        //-----------------------------------------------------------------% @6 S; q5 p/ _# g6 m- u
        // Constructor
1 n0 B- w3 P# U, x9 w        //-----------------------------------------------------------------; T5 a% }# p; _3 @( Q: {
        public ProgramCompare()* c! P9 [7 @) C' X: K- L
        {
; d% k* N, y) {: ]4 E) ~        }
7 r9 Y4 P) T  x% q3 I: j2 [1 {- \# T+ L" E4 a7 M) g
        //-----------------------------------------------------------------" [1 \, B- U3 x, k2 N% k$ `/ v
        // Method for testing that class has been reached3 p- y4 N& ?- D: C- Z) @2 T1 e( V
        //-----------------------------------------------------------------       
) `- T2 @1 k! ?/ k& Y& c4 ]6 u: m$ O! r
        public boolean ProgramCompareReached()        
8 O* k, ^/ ~& R+ t2 Q! i2 |, a        {
' C1 l0 k' a8 y3 t7 |8 b1 m$ L      try 5 K3 ~* t! e! y) H
   {        
! P, j3 w; f" N                       
5 G' P! l) S1 N; c6 V                //********************************************************************$ {* N" Q% T" @" U$ z% k" ^- f5 m
                // Try-Catch Statement is used to handle exceptions - such as file not found
4 K3 k3 v3 Z# k/ Q9 F9 `: N                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 q5 b3 P6 f, o+ J/ i
                // For more information see page 534 of the textbook* C. m1 H: s7 _0 w! u2 o
                //********************************************************************
; v$ D5 u- ^1 R8 {2 {, w                    
! i; P  N6 ~/ m0 {        }1 u9 h9 D  W# u- c" V# Y8 H0 f8 {
             catch (Exception ex) // Exception caught here and message displayed to the screen
3 [, I' X/ b& V% \          {2 f, q# ^( f4 ~8 @
                    ex.printStackTrace (System.err);
0 ^+ O: Y( {; J2 I/ B: _           System.out.println ("Error message goes here"); // Replace this error message with your own         
# h( ^; Z  t* Z/ x( N9 m8 U        }2 M' Z0 S- g( L7 O
                return true;# k) v$ w; l  M1 {0 d) k. i
        }9 h7 Y6 T& r6 A/ o

( b# W) V3 C/ S2 d. L8 s} // end of class ProgramCompare: x$ D5 w( P7 v) g

" Q4 @6 `* ?/ m* D  n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 g2 _$ x& T0 r' @+ ?//  ProgramCompareMenu.java    Provided by: DRS1 ^" Z3 L) J+ s* N2 U" }2 V3 f# e% c" Q+ P) Y
//4 z. v2 O/ x+ V
//  Calls AuthorisedUsers.java and ProgramCompare.java
# _3 A4 ^, V  C: L4 d& l6 U" c//
0 N7 t" n% j5 j//  Driver shell for Assignment 2.* W6 x3 u) [! y8 D
//********************************************************************
3 y+ d) z8 l9 H% y. [* g
2 u. d8 w4 n5 O8 D. [, Zclass ProgramCompareMenu8 a, Y3 V- ?; a4 @4 K
{
+ B( ]2 g0 \  m9 `! o+ b    public static void main (String[] args)
: s0 e2 \! N2 h  e4 n+ M& v) Y            {% N( Q% \2 }: b' Z6 I
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable/ q: v. [  v* I* Z7 M; _' c; P0 u9 J# v% ]
                ProgramCompare reached1 = new ProgramCompare(); 7 S- h; t9 v; V( ^% R) F0 D8 I
                AuthorisedUsers reached2 = new AuthorisedUsers();       
( a: p3 j% A, P0 ^6 T( n, ^                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());/ u, A0 _) X/ w8 k& N0 I! [, W- C
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# S7 q( U, g" b' ^# g- a        }) y1 n0 j6 e- C
}// end of class ProgramCompareMenu
! X1 |% P( z( n0 w- y3 H8 X! t) V; H2 R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************; L2 ~0 U9 g  c5 p& m( n
//          AuthorisedUsers.java          Provided by: DRS
/ w' f- |3 y/ {1 b//               
. M* I- u% y6 ^3 h2 q; F! M//         Program shell for Assignment 2
  a9 n0 s& Y# {6 h. r- X! c! ]  |; s//4 I# i6 S% C! W8 i+ H( Z$ \7 J2 U: R
//         Represents facts about an AuthorisedUser  B: b3 p; f$ Q$ H# g! K3 x
//********************************************************************
, s' Z' ?5 v4 Z% J8 i6 v+ `0 H+ {# E6 Q# J3 T& Z$ T+ E7 |! k0 `+ h
public class AuthorisedUsers% c) s" w2 S" c) a3 {
    {
% y, m8 g% y0 z+ f, d6 V+ D2 e' y, X; E
        //-----------------------------------------------------------------
* @7 @# w( @' B1 k2 u1 {        // Constructor) l: @3 w  U" ~
        //-----------------------------------------------------------------+ ?) b9 `) O* X7 V( ~

( Z- Y$ `/ w8 \8 v2 v        public AuthorisedUsers()
/ f, M, p9 l  Y) q7 a* }" E  L( J3 a. l                {' L  T$ |  K; r$ x
                }
/ B4 _0 K% y9 l$ z% [: e& y8 s9 Q/ S" _6 d) |% h
        //-----------------------------------------------------------------
5 @5 e* ^! p0 ?# P: m        // Method for testing that class has been reached
$ |% }" o3 L5 u1 P        //-----------------------------------------------------------------       
2 o% y4 z, R' M4 u        public boolean AuthorisedUsersReached()
  Z( q" r0 x) {3 o$ U8 i+ w  I                {" f( Z3 Z' Y/ [) |* K
                        return true;                       
5 b, @9 V5 `3 }  V$ s                }& {* o. H8 \1 q, Q2 H" n
               
" \" B4 M# G, z7 f+ S4 v    } // end of class AuthorisedUsers- e  ?5 g+ ]8 F" y( R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ `5 b( P) M& e! Y0 _- I/ OShanghai - 20075 }7 o: J) `2 `; t& u5 Z
Assignment 2
/ C1 }2 x% o1 X# p6 h2 H1 IDeadline 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)
! l+ O5 D* S) R. y1. 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.& z3 }4 T% _6 W& D# Z( |5 l6 C
The staff must be able to:
& P# y* K  d( u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# E# f9 Y5 R- w! X1. 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.
0 X5 F7 v' Z6 Z/ V; m! g0 x0 w. X The interface should provide a menu so that the staff can:
3 Q- l) X4 u% Y! wa) Enter the names of the two Java program files to be compared
( Z' E9 u* Y( F! \" E. n. o For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
3 G! _( D: C& x) D8 P( h8 p** 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).! q- }) s3 e: m! M: k3 V% E
BSA104 Business Programming – 2007: Assignment 2
9 y& D- X3 s5 i) cPage 2 of 5$ M( C+ _% C+ ], A
b) Print out to the screen all the lines of code that are the same
/ v3 W& q9 i. }  A  |, V: c Include the name of the file and the line number of the code being printed for each of the two files
& R" |' q- H( i5 d( cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; _- V9 _" I. y/ [# |5 \8 m/ t$ }  B6 o the name, username and department of the user
# v% O$ W0 h3 D the statistics of the comparison
( {" W( y0 v6 |2 h- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
  h/ \5 [( H1 i( h9 a! S0 h/ M% P the recommendation for further checking  ^( |0 {) E5 {' z
- 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 closely4 I1 W5 p- s3 N# l4 R' U5 g
 the names of the two files compared: L! Z5 O' ?. }# g% y
d) Leave the program (exit)  [) m/ X3 c& ]( k
The ProgramCompare class: (Total maximum 20 marks available)( |: [( l! }* Y1 n6 }
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)4 ~2 J$ }/ j# q% `9 M3 i" T
a) provide an error message if the files are not found or there is a problem opening them
6 y- s# Y2 G5 m. }9 _& Lb) compare each line of code
0 N/ p! I' G4 O& W1 s% }* qc) print out the lines that are the same7 `$ d8 G! A. c- }' h
d) count the number of lines compared / lines the same  V# h. @) Q' ?. a8 l2 i
The AuthorisedUsers class: (Total maximum 20 marks available)4 U" V9 A# s* @* t
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)
  o9 }2 z* k. N! A% P4 W4. Provide methods to:
% C2 y3 f# i, x: Z/ d' k" Ta) 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
- }+ B& P6 O! a9 ^3 f4 z/ y+ Rb) return the name of the authorised user
4 R" R3 z: ]) j$ x4 D1 Ec) return the name of the department of the authorised user
0 C( T! U3 B3 Y$ o' E; g) Z5 _Individual Data (Maximum 20 marks available)
% M* n, k9 l; i6 I# X5. 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.
7 l1 x! h2 G! s6 ^, [Documentation (Maximum 10 marks available)7 x( c! b) p1 m9 b& S0 d
6. 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.
& V" E0 R* Z% x4 Y0 e/ rBSA104 Business Programming – 2007: Assignment 2
5 x; F/ Q3 g9 X% Z5 k, oPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. j, W0 O" }, C
不过你要翻JAVA的类库说明。你有下载没有?( u+ i) H6 J( @
查询关于对比的函数。貌似关键字是contrast,还有compare5 R7 J( f) q/ o7 M

, [) A. L. e8 k# A[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ A, K0 H/ w6 U/ b痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。, n, H, c; Q: F! J7 p
可以下载到的 是 jdk-1_X_0-doc
7 S: i! e2 j. _9 Z5 }5 G! P' s6 g& Y8 q- G" h) J
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-28 18:44

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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