找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1185|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 v4 \1 I/ n& T$ Q' |% x6 e7 f% g# `6 @" G3 s* y" }/ J
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
! f$ Q3 k4 W2 m4 F//  ProgramCompare.java         Provided by: DRS
+ B8 M9 a6 R4 {" y//7 q, ]# n3 G4 Q
//  Program shell for Assignment 2% I0 h& e" P( U7 a- Y
//
. f5 Z7 M/ a: A//  Compares two text files line by line
; z: h1 u' K3 e9 X2 x5 {//*********************************************************************
( _+ Q4 ~# t4 E$ e6 `8 j2 A1 t1 J: u* ]( b# A
import java.io.*;
/ H& Z% D* U% C" \4 I. @
1 u4 R8 @  k" Y; ?! n, G/ U) \' epublic class ProgramCompare
) G7 N/ W2 s/ M# X+ l/ {{& b" Y. [3 O: p2 n" S8 G
        //-----------------------------------------------------------------, M$ k- H# }4 X
        // Constructor3 F; }- d2 u0 S( R' C9 R# Y
        //-----------------------------------------------------------------
0 ~- y+ E6 h9 {2 d( b        public ProgramCompare()( c9 r/ ?- ?1 m, W
        {
$ R$ s( o  q/ P        }
, ^& T: _6 W; i+ q  T5 u/ j0 F2 Q3 j$ I% B4 t8 j7 [- s; m
        //-----------------------------------------------------------------
3 D9 X5 Z( a! H8 |5 n        // Method for testing that class has been reached
8 m9 u2 R9 \+ a+ p( C% H  B        //-----------------------------------------------------------------        8 ?8 H; k, P+ C+ }
- d% o( d# r4 l2 m( J  K. l- i
        public boolean ProgramCompareReached()        
7 l! {  T* Z; k        {/ m, L9 @5 O4 M' J. l
      try
) V, t% G3 Y; v) z7 G: ^9 P   {        
& I. x7 w% C! u+ O3 J( d- H                       
1 G# y) S. Q( s3 q5 W; F                //********************************************************************
5 M9 B# x# ~0 o2 Z4 H                // Try-Catch Statement is used to handle exceptions - such as file not found
2 e/ H3 `2 ~  x: M& [                // Reading the files will need to be placed inside a Try-Catch - just like this one!! B3 q1 d' v- [6 A( ~6 R
                // For more information see page 534 of the textbook
; i% r0 r- z' v2 L                //********************************************************************
2 x- d9 p5 Q9 \' @' U% z9 h- D4 l1 |4 S                     ( {% Q9 j# A5 Z; d2 q. r* R
        }
" }+ ~# h- a+ m# r$ k             catch (Exception ex) // Exception caught here and message displayed to the screen ; L. m6 v8 F; W" r' w- {1 L8 }
          {6 R/ A( G/ [) V* n9 n2 _
                    ex.printStackTrace (System.err);/ m( Q6 Z& w$ N$ W! h
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- O$ W' F: X. |$ J" C        }' r+ c5 _: ]% J, |
                return true;! I# D# S  K2 R$ A/ J4 Q
        }
$ V7 D. X: e2 s6 A: I; q1 M- ~  }/ W
9 W* j6 n# w0 w9 C) v- f} // end of class ProgramCompare" v8 g) o. t6 Z  r% [/ K
$ A/ R& J; k) M: X* q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ j1 Y- L4 Z1 g! X6 [2 C! u
//  ProgramCompareMenu.java    Provided by: DRS
& P, n) B0 |; \$ W/ S6 i/// ]4 m# D4 `, m& J
//  Calls AuthorisedUsers.java and ProgramCompare.java; J& V5 h% D9 k# J: j; _
//
; W# J/ r! {& [" K+ e7 P. L/ ]//  Driver shell for Assignment 2.
) |" Z/ v3 X, J8 Y! }5 \/ ^9 t5 E//********************************************************************
* o: q; ~9 |  ?6 L" [* T$ G) a5 L
/ q6 R  R- S; Z4 e& Q3 H3 T5 ~class ProgramCompareMenu
% [- X+ n4 H0 c1 v7 E7 {5 V{" U2 Y+ e8 m) M
    public static void main (String[] args)
& h) }$ U3 a4 G) ?: b6 N% n/ f            {8 M3 w) j- y! a+ a, @) Z5 X# |
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable) A) y8 Y5 X* G1 d5 }- y- n% X$ ^
                ProgramCompare reached1 = new ProgramCompare();
+ T6 @/ G( H* `7 v+ E) G                AuthorisedUsers reached2 = new AuthorisedUsers();        $ f& g  s# Z. ?
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 S. m' X" D8 [) m8 D- L! O2 m" B
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. A. t) U2 W( n! t0 g6 M        }+ p; B4 \. G7 ]9 l% e0 ~9 T" T
}// end of class ProgramCompareMenu
$ P9 k9 x  d7 s6 A" D
! U2 u% E$ _" `+ G4 Y" m4 R, y& k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 C, b  ?' p" s//          AuthorisedUsers.java          Provided by: DRS
$ F+ ?2 h; o: ^$ n- h//                  R, {7 m3 v, R( [; p
//         Program shell for Assignment 2
) K7 J" m' k6 ]' p! U//# L: N5 Y- q) W3 m& X% G: h& p
//         Represents facts about an AuthorisedUser6 S5 T8 f6 `* u4 f& ?9 A4 S: c
//********************************************************************
# b$ \; F6 v% N# g. Z5 ^& q% T9 v5 P( r; d6 S$ v
public class AuthorisedUsers. W: L6 I% t& Q8 ~0 {
    {! v! Q  C7 B. ]! k! {

( v) {" q: X+ v) B* y6 e0 z        //-----------------------------------------------------------------! G1 N' F( B$ j4 a; o: w* `1 k
        // Constructor
7 d$ P/ P5 N! z& ~/ c        //-----------------------------------------------------------------
0 T2 }2 i3 w5 y! O# G
; `! ^8 Q2 p6 h; E5 M        public AuthorisedUsers()
  t7 g0 C* @& |                {. ]! X4 ~: A( k" @# z
                }" X) u, V% f4 ~9 h; Z. [# n

* ~3 m; Y; a3 r& K6 Y0 |5 P" F        //-----------------------------------------------------------------) ], S6 j7 b- ?/ O" T5 u+ c
        // Method for testing that class has been reached* p: W; E2 X9 J% ^) O* ?8 E
        //-----------------------------------------------------------------        ( F7 K% _. q, W- f
        public boolean AuthorisedUsersReached()' k, U' j9 u  _  O8 V; Z  M% R
                {5 U1 |/ o- k+ h% j, E9 L3 U
                        return true;                       
$ X+ f$ Q/ m  ?. p( ~1 Q                }
" A3 G  P3 M. I- u  D7 T9 C+ q               
  P1 R- i. R. n    } // end of class AuthorisedUsers
$ c, k) z# b6 B( M+ a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: K% Q$ t% ^7 M) E4 VShanghai - 2007
: D+ ~1 q+ R' I8 OAssignment 2
' y* }/ Q% _* B$ q4 ~7 @, ~2 fDeadline 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)
' L9 A6 Q$ [, v$ V1 t# ?: ?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.
) T! y. v" @& A$ `% HThe staff must be able to:
1 C* S, E6 ^" D4 O2 p' P& d Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 y$ \6 L% l* B5 p- v4 W4 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.8 S" A+ J! P" P8 p& D' T
 The interface should provide a menu so that the staff can:
6 o3 ]$ J- a( b0 M1 oa) Enter the names of the two Java program files to be compared. o, y5 D) w5 c: }
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
; p! w' w4 _! v2 d2 c; O** 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).- G5 j9 e% f2 v' t* l  y
BSA104 Business Programming – 2007: Assignment 25 W/ G. ^1 j5 K% }
Page 2 of 5- i; O. N7 C  _% ^$ h
b) Print out to the screen all the lines of code that are the same
8 v1 V# t2 Y6 w4 i Include the name of the file and the line number of the code being printed for each of the two files% L* O+ e9 ^- V- N' d
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 ?0 x) j) }5 R0 R the name, username and department of the user
+ z  `4 g! f3 \4 a- _  s the statistics of the comparison; G  t9 b6 }5 N) q& M2 E  S
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different  f/ Q6 y4 Z/ y5 S8 B; d
 the recommendation for further checking7 E% k0 T5 ?, X1 K6 s( s- x
- 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
! X# x( I" ]! l$ P1 X, [1 u the names of the two files compared+ U: V/ S- ]0 V) \; }
d) Leave the program (exit)
5 s  I6 s# W& f6 AThe ProgramCompare class: (Total maximum 20 marks available): M" Z' Y* z$ \! M4 p3 {" F5 v. t
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)- Q( H& C: C5 o& K. o. D
a) provide an error message if the files are not found or there is a problem opening them
3 S8 Z" [" U7 S* yb) compare each line of code
2 h+ X! i- ^# Ec) print out the lines that are the same
0 b" R2 u& ?& r; g  v: a) u8 Sd) count the number of lines compared / lines the same
7 v- E, V$ \$ H3 z0 pThe AuthorisedUsers class: (Total maximum 20 marks available)4 U& t! W; c3 b& N. p$ }! U2 o
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)& y" [9 w) w( I5 F; D
4. Provide methods to:
) e) s& g4 Q2 |. pa) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match9 }3 S6 v7 X; ^9 D2 ~
b) return the name of the authorised user
0 U" i$ B2 P1 s- k% Z1 bc) return the name of the department of the authorised user1 S" ]9 {% _3 u- S# B9 }# i! v
Individual Data (Maximum 20 marks available)
$ z- L; B- a( y5. 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.
# s6 z, D$ G/ {3 m4 p; PDocumentation (Maximum 10 marks available)
1 }' }% N/ m/ C6 z) Z% L9 _' w* 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.
# f9 T- P8 d! a( Y) @6 eBSA104 Business Programming – 2007: Assignment 2! j  B  K; L1 C
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% R$ H/ H) _2 H# C# p3 I不过你要翻JAVA的类库说明。你有下载没有?" D. s% F! [: X/ d/ y% L" ]
查询关于对比的函数。貌似关键字是contrast,还有compare& t% p* P  _1 s' H4 A; ~- l

0 S' J& N" J2 H9 ?% p[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 R' ~. k* x* S" I' K痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。7 _  U$ e8 c% K+ u# }
可以下载到的 是 jdk-1_X_0-doc
4 c2 r1 C! W/ i  R( m1 t0 d8 n1 s; ^, k+ S9 K  p( o- `! ~
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-11 12:53

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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