找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1374|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% ]8 v+ j( [$ k" f 4 P0 m" G4 p7 I: |) ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- ^- \. f9 z# f9 y; a8 |//  ProgramCompare.java         Provided by: DRS" \- ], K0 I5 p6 E) g9 Q/ n0 o# p9 J
//# ?2 k4 V, [# N) R3 K1 A1 {6 t+ M
//  Program shell for Assignment 2
# C% \$ }" H! B+ Q4 j//7 `3 u2 v8 p' Q9 n0 ^5 u) q! I; c% V
//  Compares two text files line by line
  R! ?/ @- j( i+ Y, @! S2 `" M$ P) d//*********************************************************************9 v( v" |/ j! W2 j+ h
: ]- r! u! M! l3 y  z7 Y
import java.io.*;
1 a: y- p/ ?; m: y& Y9 t( T& F7 X. X7 n) ?: w) T, U
public class ProgramCompare
  X; |% _; g, D1 Q{7 }- M3 N% k2 z. C+ b, x
        //-----------------------------------------------------------------
4 p2 W( \0 K+ ], F# n! ~& Y        // Constructor
0 C$ r/ {" o; k/ _) \        //-----------------------------------------------------------------2 V1 \, c" \- x% s/ v1 u
        public ProgramCompare()1 s6 f& ^. U% r) d% j4 g* `
        {
7 M. l7 ?  h7 ~  S        }$ l- C5 t, i) q2 e+ }
( X8 ?7 z3 B& g4 {
        //-----------------------------------------------------------------
* e8 O7 \9 {& z  F8 e2 E        // Method for testing that class has been reached
; A7 \) E4 J: o; C# n; f        //-----------------------------------------------------------------        , d+ |9 W6 i+ s1 I% p3 Q' t

* `0 l9 H' k0 J2 x- K* z3 \: J6 e        public boolean ProgramCompareReached()        
6 y2 d; |3 w' s6 e# b        {/ t0 T3 y4 I. }3 @' T
      try $ j6 I1 q4 a( @! q! H; F0 r
   {         - s' G1 e; Q0 Y9 ^" J
                       
& n0 P8 ^$ G; j0 H& l                //********************************************************************
: y7 k: F* x0 ~3 j( f                // Try-Catch Statement is used to handle exceptions - such as file not found 9 C5 V# R2 |% b) E
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- ?$ T8 E( H# a9 ]7 R' L                // For more information see page 534 of the textbook
# J' H; [  o, B9 u# I                //********************************************************************/ j, B1 P3 f$ {* B! ]" j
                     3 \( X; w" [/ ^$ e1 u
        }
: |3 b5 W( l) @8 k             catch (Exception ex) // Exception caught here and message displayed to the screen
  l% g% t# }, R4 z          {. @9 X$ n0 j" X- B+ K
                    ex.printStackTrace (System.err);
; n% R5 m; N4 r8 y3 i4 f$ m           System.out.println ("Error message goes here"); // Replace this error message with your own          # M% P: Z7 `9 c8 Y* f, [
        }
' Z  d" O" o; f2 d1 J$ C                return true;  I2 A. f) K6 N/ V4 C4 Z
        }
# S4 r& R! B2 W9 b5 d' n
# q7 Y3 \% d1 S3 F* s% L! e" O} // end of class ProgramCompare
, z( I+ v6 A  q" K  Y# T4 {2 J; ]% Q% r  Z3 |! V* ?% x! |% D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) `  ~/ a6 k% a+ E& S//  ProgramCompareMenu.java    Provided by: DRS: x/ l# t5 M1 i% I; m1 Y
//
9 i2 V  t/ M  y& p- y" w//  Calls AuthorisedUsers.java and ProgramCompare.java
& ~% Z7 _. I: s! V9 r. Q7 n$ ]* S//* T4 Y/ C' F8 K
//  Driver shell for Assignment 2.
8 Q; d8 ?+ G) p) g6 D//********************************************************************
4 ~0 x' K" [/ M7 r
3 W$ ]! f0 ?3 `) n/ p( Eclass ProgramCompareMenu: p8 }  c3 j6 j) d: J# g
{
& |# K/ M; p+ n5 ]0 M, P8 w    public static void main (String[] args)
8 y* S$ k' _, b0 I0 E8 d0 f* U            {
$ P* v5 }3 j/ V4 K, g4 s: z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 Q2 a2 H6 t; V7 _3 o) J$ G# `& C
                ProgramCompare reached1 = new ProgramCompare();
2 t. z7 O- P  l& p: b% x  o                AuthorisedUsers reached2 = new AuthorisedUsers();       
. J6 D2 t! x1 I2 t3 a                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
4 m3 U, F! Q9 m( m                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * l2 Z6 T! k! ^8 {1 a: U
        }% m4 k  r8 Y8 p4 _9 ^( K5 K
}// end of class ProgramCompareMenu0 n6 l/ o& `0 _* N6 v: Z% A
4 o# Y$ ?8 y3 T0 I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
* C, ]( [. D, Q% R  r' D//          AuthorisedUsers.java          Provided by: DRS! J+ ^0 I+ ?0 S
//               
8 a) ?( r) i5 W/ D/ f/ ^//         Program shell for Assignment 27 L; x' H" A1 `, O$ T
//( h, X) T. U2 h
//         Represents facts about an AuthorisedUser
2 k  U; r" M' |/ G- C: o//********************************************************************0 ^" o- [. y% k- e

/ e" u; z2 J8 Wpublic class AuthorisedUsers/ C) u$ z* ~/ |' x* [" s
    {  K* _  ^* s- a

- [: \3 {) J( }, J& U        //-----------------------------------------------------------------5 S, ]% u* k" b+ d8 c" g
        // Constructor! i+ u* s2 w9 D# k
        //-----------------------------------------------------------------
5 R1 Z6 K0 B* }# H  l
" v, K' i% n4 p4 f/ x+ B        public AuthorisedUsers()
' u* g/ D( v6 K+ [                {
( y8 x. C1 u' W  ^% ?  }- M                }% H; u/ _" v% ~& ^+ y
5 O1 x) d  `( N) k
        //-----------------------------------------------------------------0 z' m* K+ E2 V# |# `# K
        // Method for testing that class has been reached
; X: t+ z9 m+ z        //-----------------------------------------------------------------       
& _9 k' ^0 E" D3 \1 h/ N( k$ ]3 m        public boolean AuthorisedUsersReached()
: ?! K+ M* ]$ w& R# X" }9 C$ V                {
9 T- _8 M6 U( M6 X! m                        return true;                       
5 L+ Z( l1 y- W$ [4 H# z                }$ `8 l' A( _2 H- s
                ' O, p( r* D/ }8 N; ~0 N' |- t" |
    } // end of class AuthorisedUsers
" ~* I# y5 o1 ~8 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: W. `  v& Y; i! {1 m+ Y6 d: @) L8 L
Shanghai - 2007
9 }5 O" X& l4 g) `) H0 g0 h: R/ TAssignment 2
! [, q: ?$ k* [$ Q$ ?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)* F& o* n3 ?6 y& H
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.
6 b, G8 d+ E  p$ R! _1 IThe staff must be able to:
" U* [' {8 _, X9 K. f6 f Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ E6 `+ R% Y, m" g  _% e& R
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.. j6 O$ I  X- K
 The interface should provide a menu so that the staff can:, e1 p0 J! A( [. W
a) Enter the names of the two Java program files to be compared8 V/ c  t3 w8 x8 A$ v: u, x
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  k) Q; A6 U9 p. |3 B
** 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).  A- P; C: a0 Z  S( _! y& e
BSA104 Business Programming – 2007: Assignment 25 B, D; A1 n$ K- a8 i
Page 2 of 5
  |( D4 }; V. Q; V9 T( T6 s4 G, Rb) Print out to the screen all the lines of code that are the same; P  h' `# U# V: Y& A
 Include the name of the file and the line number of the code being printed for each of the two files
5 R! g& c  g/ H, dc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared$ ^: m0 s% K" K8 K2 z
 the name, username and department of the user
" P2 S& `3 v3 s4 _4 ^ the statistics of the comparison" W" q: D" I% R! i0 F
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 n6 |& x+ \" [7 `# i' s+ o. S" v( f the recommendation for further checking
6 u9 o! y5 J4 j$ ]/ X( k  {& 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 closely6 j; x7 H9 U' Y3 S1 U
 the names of the two files compared9 Z. r; j. C" {! |; H: X* C& W
d) Leave the program (exit)
: R; U2 t3 c' `3 [The ProgramCompare class: (Total maximum 20 marks available)% T2 z' a- ~( \0 T; V
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)
* E9 X5 A4 Y+ C; ca) provide an error message if the files are not found or there is a problem opening them
3 d! [) k! |# J$ T/ R3 yb) compare each line of code
& K) v6 n. c5 B2 W4 Jc) print out the lines that are the same
7 X! I2 I/ o6 gd) count the number of lines compared / lines the same/ p9 _! `+ L& ^! h+ j
The AuthorisedUsers class: (Total maximum 20 marks available)1 o+ k0 B) R& g; l7 k% J6 x
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)0 |; @* p/ P- s8 L# j% n: ^1 T
4. Provide methods to:( h6 e9 C* h9 E$ S7 K& q  V) z
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
( T! H% c1 Q& P7 d$ ~( Mb) return the name of the authorised user
8 H7 E4 c8 o( ]1 Jc) return the name of the department of the authorised user
: @9 ]% [$ v: BIndividual Data (Maximum 20 marks available)! K! b- i  d8 P7 O! o
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.6 e; P8 A' `+ t0 O% v. f. U4 r5 a
Documentation (Maximum 10 marks available)
% B- f( j" r, t6 q6. 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.
4 h8 Y& }9 e. {  w8 gBSA104 Business Programming – 2007: Assignment 27 [2 U$ H, B5 S% s' {
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了1 c4 Z1 ]$ u  w5 u9 i
不过你要翻JAVA的类库说明。你有下载没有?7 f5 ~6 M% _4 ~1 U8 |! p0 k0 k
查询关于对比的函数。貌似关键字是contrast,还有compare
3 x2 u, [5 _" U  {( K( L
8 b6 X: ^7 Y' `' G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ |- h4 i% O8 M+ T* n7 c3 ?3 B
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 r: B6 e$ O9 l% l) K6 A8 a" ]可以下载到的 是 jdk-1_X_0-doc
3 e6 N. E* [& t9 k9 n5 }8 C+ C2 Y" f7 @
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-11 00:13

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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