找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1467|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * Z _3 n( D2 M! Z* W" V) s& i6 z* \( L( j4 Q2 b& r
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
0 p7 m; u  \( D3 u( `9 U3 K+ l//  ProgramCompare.java         Provided by: DRS( A/ [- D+ n' r/ Y/ d7 m7 B
//
. Q9 M/ S& C' L& D6 r//  Program shell for Assignment 2' E' V2 K" G7 O( z1 \
//
8 j1 H, w; x& P) J9 @" k$ `//  Compares two text files line by line/ \+ T) H% Q- |$ C
//*********************************************************************+ W1 x( S  w6 a. q1 ^0 {: Q
6 T# p* d2 n; U" f
import java.io.*;  ?! {4 a8 x2 d
4 y. p# j$ Y* {8 {: g4 M( S. A; k( M
public class ProgramCompare# l% k! \0 [) ]5 T
{7 R9 ?" a4 s- W  J( c+ l- M
        //-----------------------------------------------------------------
! ^+ a& z5 M# @4 g  _# h+ j        // Constructor* v+ r+ w4 t  V7 ?2 _
        //-----------------------------------------------------------------
9 o% e3 z0 T9 V4 y4 O1 m        public ProgramCompare()2 w% [. t) s7 o7 U% `- X
        {" N0 Z7 [& W* ?# ^5 n# Q' ?
        }! p9 k- c9 a3 g+ Q9 T/ i# n: ^
8 P" N9 l* M! O; R" N4 B
        //-----------------------------------------------------------------
/ I, y1 i7 W7 d+ }: D# Y9 r7 S        // Method for testing that class has been reached
8 D+ |1 M) {9 N2 T8 b3 P4 n) ^$ Q        //-----------------------------------------------------------------        ' C( K$ o6 }- v3 p0 G, X4 o* u
0 a5 `/ g8 S" }8 C
        public boolean ProgramCompareReached()           B* U1 b2 P  ~" L& B  X
        {( u6 K' h& g$ q6 Q5 u
      try
  o9 I6 ]- l$ t) E8 |   {        
, n5 P4 z0 C% s' \6 m9 B0 P( Z( L  U                        * H# j! C9 |+ y
                //********************************************************************
% G! E: J' f' k9 `3 b4 `0 ?                // Try-Catch Statement is used to handle exceptions - such as file not found
# [* i6 z; K; X" |                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 Z& o' s$ y* M9 l, [2 r                // For more information see page 534 of the textbook1 T! J/ L9 p* i* z2 k% d& \
                //********************************************************************
- C& S& _; x. Z. t9 W1 d                    
2 K9 d6 j# }& ^6 g7 E        }! R) L: ?! L8 J
             catch (Exception ex) // Exception caught here and message displayed to the screen ( |/ j( X2 q: {4 J1 B# M
          {
) {  f' H9 H5 x3 _/ s                    ex.printStackTrace (System.err);4 m$ B! c4 N9 Q9 V* o' t3 ]4 K
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- }' Z% S6 l  M0 v9 j        }
+ N- A5 T* C' X$ F5 k  o                return true;2 j4 ]2 M' c# }! i1 W) }; d
        }
$ n2 D; L9 f7 O( K1 q7 V6 {
/ ~& F2 b0 l) U6 d4 Z1 ~4 W} // end of class ProgramCompare4 g% O* }( D  Z0 x
; W8 D# _7 |, v  m: J9 O$ |
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 e: D0 k" _0 \3 R//  ProgramCompareMenu.java    Provided by: DRS
7 D4 O8 G* o9 F" C+ |- t//
3 C6 h' Y) W9 ~$ ^+ T//  Calls AuthorisedUsers.java and ProgramCompare.java
! a- r- F/ v" K# K" j) c4 v//
* j0 s8 r, ]$ q* d7 W//  Driver shell for Assignment 2.8 L$ I& w' A8 N4 ?  B
//********************************************************************
% H7 M$ Z1 e: m
6 Q( O, H: L' yclass ProgramCompareMenu
; P5 r+ N" [8 \{
  j' x/ P8 z0 q$ g    public static void main (String[] args)
; u( M7 L2 S/ e$ Z, b9 W            {
; a. Q; X$ r8 a: z$ ?. G& m                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 ]* I" y1 ~& q                ProgramCompare reached1 = new ProgramCompare();
, l( p9 W7 u" v) m5 @7 k# j                AuthorisedUsers reached2 = new AuthorisedUsers();       
& D0 O7 q& r( }8 x% `- |3 ^                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- H) _, u  t6 x4 q* x" v
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ! \0 _. ^3 ]& j  o
        }! C5 d  I4 M* j+ D, p# ]4 N
}// end of class ProgramCompareMenu
" Q/ N) o, _4 ^: M. H
* e" Y) t2 U9 Y/ ?7 o4 r& z8 E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" `) C5 V/ C& S) z
//          AuthorisedUsers.java          Provided by: DRS3 G  l1 a9 t0 ?# d
//               
8 Z3 s: @3 q# M/ V& D# M( s//         Program shell for Assignment 2) D% O8 \5 U1 ~% q
//+ {9 E6 ~5 L* |% D  P
//         Represents facts about an AuthorisedUser( B9 N0 |" J$ c
//********************************************************************1 x/ d- U& V2 U/ Q, j" _( q! }
( F. k3 r. l/ X. ]+ v9 {
public class AuthorisedUsers
* d, j1 q& `+ T* _    {
( _% `5 I7 k) |' G1 x# t! U+ r0 N1 S3 a0 V7 @
        //-----------------------------------------------------------------2 c& [1 A2 i) y
        // Constructor
* M# z% l+ u( h) b5 u" B. ]6 k3 E        //-----------------------------------------------------------------
" S9 o$ ^# `1 C& x  D
. \* V; ~+ z% ?. T        public AuthorisedUsers()
9 B! U5 _/ [5 r8 b! j; `; b                {1 `+ Y  G7 d. t! Q. m( j( J$ c) {! i
                }5 b: R" G! ]- F# C

, B4 {( ^- w/ @% A        //-----------------------------------------------------------------! B& y0 h$ B& {2 z7 i! ]' i* A" Z
        // Method for testing that class has been reached
7 m. o7 ~  S: O        //-----------------------------------------------------------------       
$ h) x. z  C0 z' K        public boolean AuthorisedUsersReached()  ?: ^: y9 I, x; L4 `! x
                {
. Y' o4 f' ~$ @0 `! l% M                        return true;                       
$ Q. f: E4 [1 E* r. m2 a5 a                }
# N7 V6 n  z6 O1 w0 E$ N               
3 I5 d; v" u( s* Q4 a/ ^    } // end of class AuthorisedUsers
0 N% y8 Z9 C  B6 D4 E# p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: n4 r- i+ k& [4 x4 k2 k  d; c$ ]Shanghai - 2007
& e1 J1 T8 H+ h( O0 F3 C# N1 NAssignment 2
$ q. i$ A( s5 ]* \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)
; d8 _2 u. V  j# |1 [$ m. g# x1. 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.* R: F" B$ m5 |2 k/ S' Q
The staff must be able to:! r4 |' W, h' [
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 G1 h6 h* [! J) V9 m. O9 w1. 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.$ S+ x% X0 M6 R/ U
 The interface should provide a menu so that the staff can:
4 `  v$ L0 {7 N. E+ \) Q1 x- oa) Enter the names of the two Java program files to be compared! N: h4 v4 M: k3 X1 a4 t8 h& l
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. a. S* C2 w$ D7 f% y) F1 U2 s3 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).4 B- z  O2 N! _8 z
BSA104 Business Programming – 2007: Assignment 2
9 O; t5 x9 P: E. d  TPage 2 of 5
8 U1 }' S4 x8 f; Wb) Print out to the screen all the lines of code that are the same
# r; n1 E% Q6 W( d Include the name of the file and the line number of the code being printed for each of the two files  L/ u8 H4 ^. G9 Y% Q! Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  M; L" Y* g# E$ [+ \9 n
 the name, username and department of the user
5 S  P1 _4 X/ o" `8 b$ G- M5 s2 L the statistics of the comparison
* Y- `$ [8 z2 _. z5 w6 w7 l- I- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# C+ b& U. w  G! u
 the recommendation for further checking
! x* a. N$ A! 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
% B3 v+ B" {/ A1 b  u, s( @ the names of the two files compared
2 C* r! c  f  D! k: Yd) Leave the program (exit)
8 A6 O$ ?: `$ R  bThe ProgramCompare class: (Total maximum 20 marks available)
7 `+ f# k' b! F+ B4 H4 \2 P! v2. 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)
+ S; o( ^9 Y6 B% |( xa) provide an error message if the files are not found or there is a problem opening them
: B6 o. z$ Z/ L. b# j* Tb) compare each line of code
: b* Y8 U) e' ~4 s8 f) Ac) print out the lines that are the same7 C* E0 Z2 o2 H1 ^& A4 I
d) count the number of lines compared / lines the same
( b- W. V! i4 R) N# y  K* WThe AuthorisedUsers class: (Total maximum 20 marks available); f2 |& Z% ?3 ]# _
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)
# Z4 E; r! L6 [1 Z( @4. Provide methods to:0 E( }7 L& A$ s% R
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 match7 V5 v/ d, ?. {9 D; B# Z
b) return the name of the authorised user
' B9 s6 K. \% D7 h7 [c) return the name of the department of the authorised user  n+ `  d+ Y$ P
Individual Data (Maximum 20 marks available)+ N' i: b4 B% L
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.3 }) V1 L( `! e( ]- k  U$ c
Documentation (Maximum 10 marks available)
" S' p0 Q0 T- ^: C' `$ r9 p2 M6. 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.
* P/ b: S1 m* U( H- {0 q2 Z% QBSA104 Business Programming – 2007: Assignment 2/ }+ N5 ]# h, I$ w
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# i" d) p' p, V  ]# o5 |7 J
不过你要翻JAVA的类库说明。你有下载没有?
" X, P3 G' G4 m. a; t查询关于对比的函数。貌似关键字是contrast,还有compare
5 J. A. U0 F9 j# h
+ e6 D2 w; ~# L8 f) }3 Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -) J3 Z1 M; N' w" }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% n/ }, g% d6 Q# [" n( G( v1 k( q" x, i可以下载到的 是 jdk-1_X_0-doc. F% S; Y- D$ _6 @
- R: q8 _; M# l) O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-20 05:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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