找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1664|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% \" }% L( H% c+ a + r1 g7 @9 o0 o3 U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
5 T$ A, j, w, R//  ProgramCompare.java         Provided by: DRS
) D. b  s! {! x//
0 L" V5 U7 u  t2 W* ]) Z1 Y, A//  Program shell for Assignment 2. {* A( P  b7 p1 E3 w0 c9 P5 Y
//
2 y8 f) `4 j. Y& w//  Compares two text files line by line. q6 H+ v. q/ R$ `$ S1 M$ }
//*********************************************************************) Q) s7 M$ C/ s* F* Z) X0 [
3 _6 W$ R0 s% Y
import java.io.*;; E. ?8 b+ v( o

) ~/ s5 q! N' f0 v% n$ M+ Z4 a4 D$ \$ ~public class ProgramCompare
, `# Z; F# H+ u6 i/ p, U- O$ r{
; q. I: Y& u2 Z7 o% Z! v        //-----------------------------------------------------------------( @5 X, A6 M2 z. d9 J8 Y& X- H
        // Constructor
4 A' ~" B+ k/ @9 E3 `$ N  _        //-----------------------------------------------------------------
/ M0 o& U) ]6 L2 ~0 C/ d        public ProgramCompare()" a7 I0 g3 y+ o1 J9 o
        {6 R. X! Z" h9 n' s/ T
        }7 M( }5 ^1 ?5 {

- [6 W9 s& @  A' j1 q% G( b: B        //-----------------------------------------------------------------9 h) q: `9 s. B1 a( P- L
        // Method for testing that class has been reached
% E2 Q0 V' W0 W" E$ |$ F( Q/ H        //-----------------------------------------------------------------       
. z* J0 U6 U: Q) k0 X9 e
# X3 c' P: u3 h, w        public boolean ProgramCompareReached()        
5 K) V6 T" X6 k' P        {
' w7 j4 \8 N: s7 W0 y      try
$ r) u1 ]$ d/ ^+ a* W   {         : F9 w$ i  G2 @' l7 J1 Y
                       
0 m$ X2 e% \& m- w1 O9 c' |                //********************************************************************
% Z" Y2 F) p" Q+ v, T                // Try-Catch Statement is used to handle exceptions - such as file not found
, O1 B, @& o, Y  D2 `, y0 J( N                // Reading the files will need to be placed inside a Try-Catch - just like this one!7 k) P$ u, V6 h% q
                // For more information see page 534 of the textbook; b4 j1 I, L' U6 t
                //********************************************************************: |0 ~* F" e8 c5 R$ n9 f: T
                     ( X: |. |8 v. u1 a5 ]) {
        }
& w0 N8 |1 h# T4 ?) a- K" v             catch (Exception ex) // Exception caught here and message displayed to the screen ( C/ I& V0 v2 B4 y; q( Q
          {  F9 e" L; X5 m9 V
                    ex.printStackTrace (System.err);% H& d/ B8 O$ z- _* X! d2 D
           System.out.println ("Error message goes here"); // Replace this error message with your own          ( T# \# C7 S* _0 q, `  l1 L
        }
1 z3 I9 l" }" h4 B. n0 M                return true;6 Q+ J# i) J% g# L
        }# ^2 j' a( h  I. S5 w; F  W
& g0 H) u: ]' B( R5 M3 u% Y5 M
} // end of class ProgramCompare
% Z8 ]6 ?' u0 U* F6 F& m0 H! x/ q4 z: p8 i8 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
6 Y1 F( Z) i7 }5 g1 \% E% z* t& s//  ProgramCompareMenu.java    Provided by: DRS, t2 d# C6 x6 [
//" j& p0 L, A& |# \' _* a
//  Calls AuthorisedUsers.java and ProgramCompare.java
8 d" F. z* x" I' j$ q//. H( }- @" t6 c( t& i
//  Driver shell for Assignment 2.
% i0 e. ~) E8 b( g' H& c) {//********************************************************************' ?7 a9 k- Q% t" D

7 q. v7 O, a) W7 o1 }class ProgramCompareMenu
3 E  s% |9 R6 {8 e7 l{
) K" y/ }: H, t! K    public static void main (String[] args)4 R. q  [5 w1 l. u8 ?
            {) N$ z: m8 `0 k6 A  B
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! ~, k' ]/ G( R* B! A3 b                ProgramCompare reached1 = new ProgramCompare();
/ D$ c& b$ C0 ]5 N* A8 J! t7 c                AuthorisedUsers reached2 = new AuthorisedUsers();        7 f) h: I- d: v% v6 D; c
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());$ j8 Q4 f( m, q* E1 ~( _' m
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        2 ~- R; c& c2 a1 X* S+ i
        }
. r- @! w# j# X7 m/ d- D}// end of class ProgramCompareMenu- J0 S( J% d6 w. E% q

. D& a+ N& l0 I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
) X" P" T5 o4 k, A1 c$ l1 m  P//          AuthorisedUsers.java          Provided by: DRS
3 D' {6 ?6 J" H! W) E" Q//               
- N7 }, @3 ~: E8 y//         Program shell for Assignment 22 t, `7 L8 N4 b$ Q1 q' o( \
/// z1 O0 t- |8 }8 P: y" z- i
//         Represents facts about an AuthorisedUser
" \8 g. ], \2 z3 ~; ]6 O. G. D//********************************************************************
1 a2 u9 D7 R" N4 `+ ^; }2 ^/ v7 U  `* i. D* e; d4 K/ m% [" F
public class AuthorisedUsers
7 O) u& N' L* X% p    {" d7 c, J& f; L0 S
: H4 {7 n; O. p
        //-----------------------------------------------------------------
. r1 w; P5 q6 A( W- s2 U/ T5 l! p        // Constructor7 M  g: T$ U  R8 K
        //-----------------------------------------------------------------" ~9 d3 Q: z" o- ]- }* V

( p" M, Q1 s8 I7 i# y        public AuthorisedUsers()  Y6 @7 Y% M3 t! w* n
                {/ g5 P9 b* }( {) _
                }
5 R# p  X5 {, x, ~" D; D" n! I: Q0 ]: `
        //-----------------------------------------------------------------/ q2 E$ X* H# R% ?0 W* J+ Y
        // Method for testing that class has been reached2 f' [2 q: E2 \% ~$ v/ A$ k
        //-----------------------------------------------------------------        # A1 S; d1 V8 h1 f8 O
        public boolean AuthorisedUsersReached()+ a" A! k# Y& G2 e
                {2 g7 F: ?4 m6 Q2 N. `& t
                        return true;                        ( ]2 h. \# g( y! [; ?
                }7 M. W! Q4 |. v: }" T$ \; Y& m/ |
                ! ]  R/ ]1 V& L7 s+ q, g
    } // end of class AuthorisedUsers7 u6 G& D0 ?6 W) W: S  c
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# }3 u8 V( _3 A/ v% i& gShanghai - 2007
' ^0 V0 j" v" E1 Q, ZAssignment 2% F4 U' ^6 _( Z/ ~
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)
  V0 ^) W) i6 {) |& G! ^: g7 b1. 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.: c/ U0 w9 I/ U
The staff must be able to:
+ P8 P3 m7 {) W4 p6 [2 ~3 {* ]9 g Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# y0 [& r3 O) ]9 X1 L: {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.9 b( ^; S- m/ E) N8 P
 The interface should provide a menu so that the staff can:
: [6 h. i( }9 U0 M- _9 B% u% S7 e( ~a) Enter the names of the two Java program files to be compared& N/ q& V) S. k) d. e; l  M
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# c, G( F% f; l3 |5 h# ^0 F+ ]+ z** 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).
8 i% z! t; D9 @9 y9 o. F; L0 \BSA104 Business Programming – 2007: Assignment 27 ~; G5 _0 y# B, ~4 f$ Q+ S3 C, x
Page 2 of 55 R) o1 z$ E3 ~& N& C1 [& U
b) Print out to the screen all the lines of code that are the same9 j( @( I* F( \' p7 ?6 x
 Include the name of the file and the line number of the code being printed for each of the two files
( p  }0 R) ^3 J, U% ^$ x/ Sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ y' ]( X0 g# ~& c the name, username and department of the user5 V: I* v4 Q' l/ m4 y( F- Y7 y/ K
 the statistics of the comparison2 _, b$ g$ L4 M8 M" U- V) R
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 n4 {0 |: |  ~ the recommendation for further checking! J) [* z3 W- H) x! C9 C
- 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& |% \, U$ i9 T
 the names of the two files compared9 K" Q# C! `- b6 S* D8 C; c
d) Leave the program (exit)
& d; P7 L' P% Q$ ^: JThe ProgramCompare class: (Total maximum 20 marks available)3 G. k# `+ @& g( T/ 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)  w; M$ ^9 j4 w
a) provide an error message if the files are not found or there is a problem opening them
" T$ x* }8 N2 @  Xb) compare each line of code  p+ x7 }! ~9 H, c' q! h% S/ Z* U
c) print out the lines that are the same) Y$ ^5 }0 k+ t, V' f1 k+ F
d) count the number of lines compared / lines the same
* b9 P( D7 ]. {The AuthorisedUsers class: (Total maximum 20 marks available)0 q2 h4 @2 W& q3 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)
& L1 _% r4 M# K: i+ r4. Provide methods to:# Y+ E  ^7 S' M- K2 [2 Z6 u
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
* Q7 {3 Y8 y" V+ C1 f! k/ u; {! y( P* \b) return the name of the authorised user
' v! U. I6 o/ Y/ ?c) return the name of the department of the authorised user
# |' U" |3 s2 ^2 Q$ r0 \Individual Data (Maximum 20 marks available)
' m8 `3 d+ B5 Q5 h& h9 }6 g* W5. 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# o9 e# G8 [" I/ gDocumentation (Maximum 10 marks available)
: g+ K2 {) @9 @) \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.9 S5 o& s2 g0 \1 ^1 f
BSA104 Business Programming – 2007: Assignment 2
) I# L, [5 L) f+ G4 _/ V) ?Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 S, L8 _  O4 v+ L% x6 @8 p' b+ \0 U7 ?
不过你要翻JAVA的类库说明。你有下载没有?
, z( b1 w# u* M1 f( ~" V, u9 x查询关于对比的函数。貌似关键字是contrast,还有compare% s6 t% k/ s& L. u1 _+ I
" t, ~. h3 i. I
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -) z8 Z) D+ }6 O& t
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
) F+ Z3 s/ c0 r$ P( E& u" V! G可以下载到的 是 jdk-1_X_0-doc4 T& W0 L  C  ~" ]; o. C

! [+ ~6 J2 ~+ r- s$ g; f3 ~[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-24 05:51

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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