找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1689|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急/ e+ I6 \' ?/ X$ [+ h, ^ ( R8 J' {; F! w2 e! G
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ O' E2 d5 u* w% U9 K$ S& R" O//  ProgramCompare.java         Provided by: DRS( P) l, p& T1 \: @
//4 o' @% T# d6 T- s9 `% n
//  Program shell for Assignment 2
/ K5 L0 w( f: v, i; [//$ w/ d0 y# S. Z+ q0 q
//  Compares two text files line by line
9 p: R2 C5 \$ e( K* G0 I" s5 L//*********************************************************************8 P, a& k5 K9 _# s- C2 ?8 y6 Z
/ c! a& K( x5 K
import java.io.*;# r/ ~& X( q& a- o+ y  l% j
' P; S1 E% p' I/ W) q) h- l' u
public class ProgramCompare7 m0 t. C' d! K7 @
{
% l! z7 l9 J9 r' Y        //-----------------------------------------------------------------
. x2 _- F2 T# U& ?7 J        // Constructor
2 T: v* L2 g- E; W9 t        //-----------------------------------------------------------------  k7 [  W% H4 V5 z6 h' [% G
        public ProgramCompare()
) s" P8 q( A/ `3 |7 b        {3 E. H( w8 a" Q* W2 J
        }
, W8 L( f3 q4 @
; N, E$ i2 E& H' k9 ^& \4 E3 n        //-----------------------------------------------------------------  E+ ?# K( J. Y
        // Method for testing that class has been reached
2 J( h8 \+ K8 a1 X7 Q        //-----------------------------------------------------------------       
" H% M) Y& p' y4 _
5 ~5 k' D5 i2 h% g8 r5 \6 H        public boolean ProgramCompareReached()         6 I' a0 j/ c% Q8 ~
        {
- l: N6 ^" l" r. M; i      try 8 w; b+ K2 B5 N5 V- }
   {         . e% {- v; b$ w9 C
                        & i* x- m$ S% k
                //********************************************************************' q  G$ Y. h# b3 ?0 x
                // Try-Catch Statement is used to handle exceptions - such as file not found 1 U! |) u6 W% H2 S
                // Reading the files will need to be placed inside a Try-Catch - just like this one!) r' z% ~/ k  _, Z
                // For more information see page 534 of the textbook
6 H2 q9 W2 z/ {6 l                //********************************************************************7 ^: V( ~6 [8 m- W9 G$ Z
                     0 M& G0 t3 d1 a, a8 B% y
        }9 A  ]' I  g, y9 y+ z: z( h% K
             catch (Exception ex) // Exception caught here and message displayed to the screen
( Q" q! K2 @7 r' Z0 o          {
, l' ?* a$ ~' V  t+ F" f                    ex.printStackTrace (System.err);
9 m: H& l% m+ {# ^% `7 T* R           System.out.println ("Error message goes here"); // Replace this error message with your own         
' y7 B1 \! Z# v6 G( b; i        }
$ [% a( D+ y& g- Y; [( p: o                return true;
  e4 `* L0 B* F& o- _8 k        }
6 v$ w& D% O: z+ ^6 Z; r
7 V: p9 z' C) @9 a% h} // end of class ProgramCompare! ~1 p. g, c0 v0 F8 ?

: L( \$ M8 A' B7 c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# v! B' Y5 e  s
//  ProgramCompareMenu.java    Provided by: DRS
+ a- s! }* |# Y2 n//
% N& X0 m/ h4 `4 {//  Calls AuthorisedUsers.java and ProgramCompare.java
8 z5 n" \, d8 ?! }' i//
/ u# o% l1 P& B4 n1 p//  Driver shell for Assignment 2.. E8 l) K0 {; Z
//********************************************************************; k5 w* _: _( S1 h9 H0 m2 C7 j
1 K5 o+ c; `+ H* ]
class ProgramCompareMenu
7 A6 \/ v. [1 U2 _  [# W/ e{0 R) J9 K* R0 x) B9 }2 D
    public static void main (String[] args)0 T1 |, d( }/ O4 S+ v
            {) s+ |5 L' g: F# s% S
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; v8 T" m5 A" ]% R2 G3 Z0 G; s& p                ProgramCompare reached1 = new ProgramCompare(); * A5 |5 E; ^4 p; N5 O- j  H
                AuthorisedUsers reached2 = new AuthorisedUsers();        4 q: T, _; u0 @& j
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());! v# M  a+ k: c+ h: p" X
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 {; _4 s  b) Y1 I& x: p
        }' h2 L( N4 T5 Q4 K/ W; [$ O
}// end of class ProgramCompareMenu
! }0 j" Q; B  V+ B7 n6 G+ b) v) s) E* E  p
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************% D) f4 U5 h+ C
//          AuthorisedUsers.java          Provided by: DRS
/ ?; K7 z1 [4 s7 g1 ]- z//               
4 H( q( v; ^: U0 |& O, G//         Program shell for Assignment 2
2 |' r" |+ N. z8 p//
5 c4 |8 J, g2 d4 [; u. U. M//         Represents facts about an AuthorisedUser
4 g7 F6 |# t+ c8 l//********************************************************************
* [% k6 S5 z/ G4 X4 R7 d/ T; I, d( |+ o, F+ B8 ^6 p
public class AuthorisedUsers% z- u/ u( a8 G4 ?; o5 D. A; d
    {( r6 S% ?3 [2 Z" @5 h/ i; b

) T# L# u% T0 D$ g        //-----------------------------------------------------------------$ u; J( C: ~) j9 U
        // Constructor
4 E" ^* C3 Q) Z        //-----------------------------------------------------------------/ B2 D5 K# l7 L8 R, @

8 ^+ R# u/ h3 Y3 F! S        public AuthorisedUsers()! A( e' D% {* Z# K9 Z4 ^
                {
9 l7 t, v0 _7 A& N4 g- z: X                }
* [, R1 ]2 o! k9 b% O* {0 z
- `; z: a0 `( o/ Y) p, J0 L5 w        //-----------------------------------------------------------------$ Y9 f) ?8 I' N
        // Method for testing that class has been reached
' y  u/ i; e4 ~6 I, w: G8 |        //-----------------------------------------------------------------        7 J+ T, ~. M0 j' `4 {
        public boolean AuthorisedUsersReached()% }! p& b; ]( U: M$ O
                {
5 n) v# U0 Y/ ]) B! B5 z* N3 }                        return true;                       
. m0 h7 ?3 d$ Q# d, j' d8 B/ W  Y                }
% i$ t9 P) q6 X) N: B; @/ Q               
. s# L8 W( k4 a6 H% |$ x    } // end of class AuthorisedUsers
3 i+ j: l! o7 D# D; E( J! l3 C6 V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 |6 j( y: K' C; N
Shanghai - 2007  v9 U( z  ]" {$ \% _: _9 S
Assignment 20 i, q* Z* K0 ]
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), ^7 b+ S3 y2 u- S
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.
) H, E! I- ^2 E, i* D, w( PThe staff must be able to:5 [- W. j$ [* v) P) Y% e
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! Z8 w, t0 k  a. b. a6 C. T1. 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.( b) G& x! Q. F% l' D
 The interface should provide a menu so that the staff can:
0 ]% I: o! O6 R" ]6 S6 F  ?a) Enter the names of the two Java program files to be compared
# r, e# w0 c2 ]" @9 _& C5 ^ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ r6 J' f7 ]" K  }** 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).* |( e, z- Z1 ^3 v2 E
BSA104 Business Programming – 2007: Assignment 2- R2 D1 h) A/ ]  k# H
Page 2 of 5
) S$ h+ t4 `+ m0 b+ Lb) Print out to the screen all the lines of code that are the same# I$ ~8 f% _1 x/ Q3 F
 Include the name of the file and the line number of the code being printed for each of the two files
# e$ h" U& g5 c% B/ _, sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared+ p# O4 ?& {6 l; @
 the name, username and department of the user
+ c9 {1 i4 O8 x2 w9 D the statistics of the comparison
" Y# s8 S7 {# F! e3 r- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, v: E0 j1 P, ?' K the recommendation for further checking9 V" D& ~( H. f/ f* f# _! L
- 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
; G  F. c. v& m* q the names of the two files compared
# t2 o. a1 T7 P' h7 Id) Leave the program (exit)
# }% F  w7 B5 M8 c( R: N9 rThe ProgramCompare class: (Total maximum 20 marks available)0 @8 b2 {( ^( K4 C( M! S, A4 w( X
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)
/ H0 z/ l/ [) q9 x) |' da) provide an error message if the files are not found or there is a problem opening them
2 }7 K, B- }# w4 \5 i! Z# Tb) compare each line of code
. }; H8 E9 \% S. Y. p$ |c) print out the lines that are the same
/ R+ }- Z9 h4 e$ v! n) @d) count the number of lines compared / lines the same
; }- [4 X5 [. @( |  JThe AuthorisedUsers class: (Total maximum 20 marks available)2 {3 x& j& m) F3 r! O1 k. Q7 ~
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)5 e$ l! _, K4 K! ?
4. Provide methods to:. O: Y) H$ C% E* `0 S5 c. K1 E
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 match
# d: Q. f( `* }1 k# a( _1 Hb) return the name of the authorised user
: Z5 v# O0 J' E& Dc) return the name of the department of the authorised user
/ ~* a3 j3 j2 C) o8 FIndividual Data (Maximum 20 marks available)6 {$ S* V9 `. M8 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.4 N2 z3 {2 d. I9 y, b
Documentation (Maximum 10 marks available)
' y8 p# S1 f* E3 O8 b, ~# f6. 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.
7 l/ F/ |8 k" S: v# a% s* b" mBSA104 Business Programming – 2007: Assignment 2
& I( A2 q4 U. p! q7 j3 C  {Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) _3 G1 n) U7 D- Z8 L3 v& O, T# Z
不过你要翻JAVA的类库说明。你有下载没有?
, Q4 ~- O! G7 Y: E& [5 w查询关于对比的函数。貌似关键字是contrast,还有compare+ h, o( t2 F6 m/ a
& R: O9 c1 {; Q; s7 F& V7 v+ G5 m/ \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ K8 B6 I. Q3 ^0 `可以下载到的 是 jdk-1_X_0-doc( `  o3 f5 S4 I2 k5 y) ?6 x- \  ^

. u  x& x- t& l# b7 x2 G# ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-1 07:21

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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