找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1826|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / l# s% l ]$ \# F9 g# n+ l9 S7 N' O0 T" q5 o1 k- e# v
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( B4 D3 p* H, {5 B/ w0 t//  ProgramCompare.java         Provided by: DRS6 T) S3 R8 R" X  d
//; z- c, N. r, K! A( k& F4 u
//  Program shell for Assignment 2; [* {. G/ |. Q: P* ~
//
" k& U% p2 B- @$ q3 K  Y. n//  Compares two text files line by line2 D( R; P2 Q9 U& G6 S6 s
//*********************************************************************6 T, D6 A6 {" b0 |$ I# E
* Y2 a. Q7 v  Z4 F) x( f$ q
import java.io.*;! ]. U. N# J! z: x$ P

5 h) n3 q, O; x9 v" y( E: o4 a& d! Tpublic class ProgramCompare
; F0 [( c; B* ?{
) V' @3 O8 O! P! b! h& A        //-----------------------------------------------------------------  f* t- D6 N  I" w  Z
        // Constructor
" M. g+ k8 ~; e9 B; L4 v6 n2 X        //-----------------------------------------------------------------5 ]1 \* |) Q9 m1 B1 j8 m6 u1 ~
        public ProgramCompare()
2 y) q, ^0 {/ |4 Y, P( J        {
2 X3 X9 h  p& `. J$ t5 ?6 |        }
$ O  J2 x; B3 `0 n/ F2 {3 M; T: N$ R$ E% t9 d. Q* S
        //-----------------------------------------------------------------; |6 M% }  m* c3 T, r6 i
        // Method for testing that class has been reached
4 ~2 r* n. }  w# ?        //-----------------------------------------------------------------       
# p" V, z! q& g2 O( J
# M! [! }) W2 Q5 Z        public boolean ProgramCompareReached()        
% {8 o; ?9 c- P- c# Q+ p        {/ B7 X9 d4 E6 Y
      try
3 b$ F7 w0 Q5 S- ]   {         # K* w8 r( h6 n7 j
                        , v, G) P( C& O8 S
                //********************************************************************6 y, L8 u4 I/ T) I; G# A
                // Try-Catch Statement is used to handle exceptions - such as file not found 5 S4 q# B; U# Z' I
                // Reading the files will need to be placed inside a Try-Catch - just like this one!; w/ L& k1 o; T: j/ }, Y7 a4 ^
                // For more information see page 534 of the textbook
% \! @) @  E) @                //********************************************************************
* k/ y9 l3 C# b* J6 J                    
  k: X" A+ G1 ~. l: N9 s' l: n! \        }& b, v7 K; c" Y/ C- ?' |  |
             catch (Exception ex) // Exception caught here and message displayed to the screen ; C3 a. N, T" o% Y; T- U
          {
$ Y  ]' W; ^4 {( O: p1 b4 [) u                    ex.printStackTrace (System.err);
/ ^/ X3 v( E* l( W- m; x5 }9 X           System.out.println ("Error message goes here"); // Replace this error message with your own         
+ r( @9 S5 r3 N4 `2 X, B1 F        }
2 Y/ _+ s2 {" @4 f: A9 C3 _                return true;
8 r8 a+ a% y. G& r- Q        }  I% `; O6 R  L% f) A# [

/ v  z% W0 P/ ~$ V& C} // end of class ProgramCompare
& R% |6 I2 p9 g  ]3 S6 p+ y& F& j# w/ a' x: K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
5 V7 _& [% w2 g) I//  ProgramCompareMenu.java    Provided by: DRS/ y6 Q8 x8 D0 u
//# T- P3 X! N" M! H4 P' H* {
//  Calls AuthorisedUsers.java and ProgramCompare.java
$ Z( j, E! V$ w8 Z. B. s//
" r% D% Z. i; A. ?7 b! y; l$ E( m* }//  Driver shell for Assignment 2.
( |: ^; O4 \( g- p" T; x" _//********************************************************************
/ N& W. ]) f! I4 @4 l; {5 U! |
2 C6 X) g0 U- C& k6 K2 k$ `class ProgramCompareMenu! Q" s( j( m- r) P0 l& j9 a2 C& n
{
) z) N& z7 S6 R! _; @  Z. Z2 [    public static void main (String[] args)) k5 b% `  G, l; X4 b0 q
            {
& R5 l$ X7 M: ?, \, u" F                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: Y2 [  R: Y3 P+ d8 W* ]8 ?$ D
                ProgramCompare reached1 = new ProgramCompare();
- h; o5 V! r1 T+ A/ L* c                AuthorisedUsers reached2 = new AuthorisedUsers();        6 @2 d) s0 P; z: s
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 j4 G5 c5 K/ L; n                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
+ i* S* H. N, ?. l' K: B- ]        }, ]- d% H: Z" R3 F0 f2 V" V" l
}// end of class ProgramCompareMenu
, W$ m% Y7 ?! c& V8 g
) ?+ m# Q9 D# X6 P! z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 Y# J9 C) i; K# D//          AuthorisedUsers.java          Provided by: DRS
- m' @9 U# C) q//               
) A+ c9 y: T. U//         Program shell for Assignment 2% @& l( `# C/ Q2 |! t
//1 v' [  J) M$ {# E0 i( x
//         Represents facts about an AuthorisedUser+ B1 j- S) O  m, I% |5 y# M
//********************************************************************' f2 |+ o; M+ Z* k9 u& v
3 W+ F$ q3 X* t# C* @& f8 {
public class AuthorisedUsers# ]1 [. K6 p, Z6 G) p' V: F
    {
' u: m: i! O( n7 f$ D
+ C: X  D- E4 z3 B. N' I- x- v' f        //-----------------------------------------------------------------
; S' b2 i( s, \  P% y  g3 R& \! ?        // Constructor7 R" H5 m+ V6 m" q
        //-----------------------------------------------------------------" p* d& [  `: U0 M- @

1 l4 k2 w0 I2 W2 ^        public AuthorisedUsers()
: [) o* P5 G: d6 O: O                {
, m. Z7 S0 e/ ]                }
7 x+ Z" _4 K( {+ \: Y2 m/ r# B- V" Y
        //-----------------------------------------------------------------
4 B, r4 g, v! G$ v7 g* c        // Method for testing that class has been reached
2 ^: Y( S, `; S+ x- G5 a: A! h9 b        //-----------------------------------------------------------------        7 m; |. I- P% T! H$ g
        public boolean AuthorisedUsersReached()
' h& _! L) E  o5 I7 ]( j                {) O: V2 f% ^! B. [8 G: e- I
                        return true;                        # C/ T0 i/ J; A6 {
                }
) I& B" L1 u7 H                9 j8 {% i0 t: ]7 O9 O5 t2 K3 B
    } // end of class AuthorisedUsers  H( A$ h9 t- b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! G0 f; E, `" M4 E- j' O
Shanghai - 20075 |5 m6 V5 y: L) [( s
Assignment 2
$ E0 v4 o7 n2 zDeadline 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)8 Y' j/ Q+ t; U8 o! f% }/ 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.
- F, ?& {8 ], O1 O' v1 uThe staff must be able to:4 n: A$ i4 s8 T; O; Q8 z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.4 G( M, ?' \$ |5 W
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.# _, I: ]9 ]5 {& G; l* d% {
 The interface should provide a menu so that the staff can:; U% E/ c7 C4 Y
a) Enter the names of the two Java program files to be compared
2 M# N' y4 s. x0 \# z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
% P" i- w  j# G8 `; @. T8 h** 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).
0 X' [6 s  Y6 A8 O* \BSA104 Business Programming – 2007: Assignment 2
  _" s. O4 D# ~  i; p6 p# A% VPage 2 of 5
* w3 Q  i) m# K) l/ i6 U. i% d" Wb) Print out to the screen all the lines of code that are the same
* X9 H) J2 W6 q* X. ~+ @ Include the name of the file and the line number of the code being printed for each of the two files
1 ~6 P& U+ J  v" H8 L8 p6 I% a) Ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. f/ T2 n. B% I; v2 P the name, username and department of the user9 m0 }8 D  z7 f9 I  H7 P8 K1 S
 the statistics of the comparison1 C8 H  h- w% [2 W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different& q' a6 q( m# U9 o, ?
 the recommendation for further checking
2 v5 o8 d9 K" [) Y. q7 B- 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
) Y1 s+ ^3 K/ U* O- o  @ the names of the two files compared
1 U5 a4 a7 l0 R3 {d) Leave the program (exit)4 K' Y6 H" q7 x8 w" Q( j' ?4 @
The ProgramCompare class: (Total maximum 20 marks available)
/ l, d+ V6 ]3 i7 l# t. z9 _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)
0 w  U5 I. z% T% a- j. ca) provide an error message if the files are not found or there is a problem opening them
, g/ r9 n: b, ^0 j, E# K0 T7 r) m6 pb) compare each line of code
4 Z$ g" w4 K2 ^c) print out the lines that are the same
5 Y- V/ ~# n# f8 fd) count the number of lines compared / lines the same$ u0 W0 `( B8 ^6 Q. r( B
The AuthorisedUsers class: (Total maximum 20 marks available)6 S5 v: V5 q  i. N
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)
( t' X: c* `) _; i4. Provide methods to:
. l$ @9 n# q0 o+ x% aa) 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
4 r9 S% T# F- N+ D. ub) return the name of the authorised user6 R5 R$ E, u: o6 b! C" _) R
c) return the name of the department of the authorised user' U6 p5 k& _0 n" T0 E) h+ B
Individual Data (Maximum 20 marks available)7 w! i- B: D7 i& k: h
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.
* y' Y$ f/ A  D8 b, ?, _8 ~/ TDocumentation (Maximum 10 marks available)6 _7 g! A9 c: d$ t% P" X
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.
5 y6 R; u. r9 X7 cBSA104 Business Programming – 2007: Assignment 2
% q* H9 r- ]- S! sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了, a, B# E- ]/ d4 F3 Z! u0 r
不过你要翻JAVA的类库说明。你有下载没有?
  D1 m6 h! d9 g3 Y0 _; X查询关于对比的函数。貌似关键字是contrast,还有compare
, B/ ~5 Y0 V8 p: {+ }9 A5 _" {- Z7 Y3 Q, F4 {& I
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。, B) C6 I. {1 V- S% x4 K+ N; m/ |
可以下载到的 是 jdk-1_X_0-doc0 c( i4 _/ F7 e3 N; ?

3 {3 ~) Z4 j4 T! y* m. D7 M! J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-14 20:08

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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