找回密码
 注册

QQ登录

只需一步,快速开始

查看: 971|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 K8 X, ^* z* n1 D3 W& y3 V9 }4 V1 f* P& \0 M
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************" ~! S3 K- F7 j+ E
//  ProgramCompare.java         Provided by: DRS* H( \' V. h* Y, I
//
- @" H5 N* q' Q( R4 [//  Program shell for Assignment 2
2 j6 _- A  E* G//
. ]/ j1 x8 I0 s# _5 g5 e! |//  Compares two text files line by line- V. [8 u* W. I/ s6 j' u
//*********************************************************************: w9 R- \0 D& n5 ^
7 _/ U2 e' k" Z6 r! N4 |7 G
import java.io.*;
. q$ i7 q  R+ T- c( ^/ t6 O
" n* K6 t  E7 P5 \, Opublic class ProgramCompare( l$ t1 W0 p: @. n$ K
{3 H, Q& V$ J; N. {+ b) s
        //-----------------------------------------------------------------
+ @5 I  ]7 {- U& |4 M, g        // Constructor
. q7 i8 K/ X' F$ r+ I1 U+ }        //-----------------------------------------------------------------7 q: C( Q- O( [, }8 ~
        public ProgramCompare()
8 H4 u' I- |5 k7 }( ]" M: H1 H3 B        {8 r: x3 R! Y8 B( M& h) F
        }
; ]& |: q. {5 f# s8 v/ L' i* h
: W5 m; I, G$ R* g        //-----------------------------------------------------------------
2 @: W; u; a) J8 y        // Method for testing that class has been reached" ~& G) q/ B- z
        //-----------------------------------------------------------------       
3 E. H% a3 V3 U: Q/ A7 h+ X8 d. t+ t; ?& Q+ X3 B* \+ Q
        public boolean ProgramCompareReached()        
( Y/ d. e0 u( Z7 S7 e        {
& p% r) e+ _7 Y      try
) B! [+ \; W: L, A0 A1 t8 B; S5 m4 L   {         2 F7 P* o% [& q- H7 C$ v
                       
$ C' N6 e6 v1 n& i- s- F' z                //********************************************************************0 ?' l/ x1 v4 x& }
                // Try-Catch Statement is used to handle exceptions - such as file not found ' g) }0 {+ _6 w2 a7 [4 ?- @
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
2 X3 D$ K7 C) _; U6 p! m                // For more information see page 534 of the textbook0 c+ h( N) O' H0 N( \7 s, g7 P
                //********************************************************************* ~+ [2 P0 r, K; z2 [. {( `/ ?* \
                    
& A5 C5 H5 S5 B7 D* V        }
7 E; o( Q& y! O* R             catch (Exception ex) // Exception caught here and message displayed to the screen
' b5 B+ o* h# ]; G4 T4 K6 d          {& i) Z, M) n2 z) \, m
                    ex.printStackTrace (System.err);* L& Z/ `: F0 ^, `3 g' x# k
           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 o* q/ x6 a; ?& k        }
) s. A7 N% E. j* v  X4 w$ j                return true;
' {3 x( R7 {4 W& k& L; d* e1 i: ]- }        }( t: z. G) w9 U! p& B8 J0 e3 L

. H, e2 L% g4 z7 X4 {& E/ U; q( u} // end of class ProgramCompare, W! q4 A6 \2 z! M, D
8 Q& I4 ~3 S5 \# A4 g% `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
6 j5 V2 m' h5 R0 ~% e//  ProgramCompareMenu.java    Provided by: DRS' C9 n  c2 C5 h* s% A& a4 ~
//) s: o( i8 y. ~2 f4 S$ [+ Y9 m
//  Calls AuthorisedUsers.java and ProgramCompare.java
5 }; p% O! g# n; r# a//
) u+ S# D4 Q- H7 Y6 o6 H/ W" U//  Driver shell for Assignment 2.1 q  Y% o, {8 H, y0 x
//********************************************************************
. }" W6 y# C% [1 M; m
1 A( b$ e  Z% @1 Iclass ProgramCompareMenu0 [9 G+ y  w; q8 h' f1 {
{
& ?; i8 p/ O- ~% |# Q    public static void main (String[] args)
. z' R3 ^0 ]$ |8 U* f& p            {
! M8 y9 [1 `8 ]4 v$ H                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable/ o) Z; Z# V+ X( R* i: |' S
                ProgramCompare reached1 = new ProgramCompare();
+ [& Z9 M! U! {; K                AuthorisedUsers reached2 = new AuthorisedUsers();        & i1 Z" z0 `* l+ _6 ?6 v5 t
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ Y9 c$ N" r" i/ t                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
+ ]1 W0 |9 v1 m* ^# E. b        }$ Z. ?4 D, E. W# K  Y% `& d; q
}// end of class ProgramCompareMenu
, C6 o: O6 I' R& o% }: Y( L  k9 X. z1 d) m' B. f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ L5 [/ G' ~+ Z
//          AuthorisedUsers.java          Provided by: DRS6 H! t+ L9 O' O2 K$ n' C0 L4 _
//                ' I' r( r" m6 v+ Z
//         Program shell for Assignment 2" k/ h" |* X6 @
//
: i- m+ z4 G1 B3 `* e6 g//         Represents facts about an AuthorisedUser; H# R- {* c; W5 S0 q
//********************************************************************+ F) g  N# H* \8 l: |( \
+ Q' M, q; A1 ^# j* N* j  ^4 o
public class AuthorisedUsers
5 F1 p, ]% s7 J1 ^) \. U    {* K. k$ I4 U* {3 y
; s6 e: c2 N: n4 }. t
        //-----------------------------------------------------------------. S8 S$ g7 }6 ]# p: O- o
        // Constructor
' a* T! K- z8 u. d& ~0 t& O* x8 ?        //-----------------------------------------------------------------7 Z0 r5 W" R3 P6 ^% `7 y4 `
- _9 h+ ]2 ^! C. B, v( e0 H
        public AuthorisedUsers()( o: V% Q$ s  a! G
                {3 S1 z2 i% }$ |! J, P
                }/ G& K+ X" ^1 f

; p6 L  E" _+ W, M3 x) ~        //-----------------------------------------------------------------
3 a7 [+ ~* o( M) i        // Method for testing that class has been reached' N# B3 N9 j# B
        //-----------------------------------------------------------------       
. @8 L2 x+ }% ?" r- C' q# c- [        public boolean AuthorisedUsersReached()6 _( l5 W6 U) j
                {
" k, H; p( t' \5 ]                        return true;                        1 i5 H8 k, O5 s* P: ^; E. L5 N5 ^
                }& h8 H& @5 L; s. _5 ~& P" \
                $ L8 [, w; a# a+ b/ M
    } // end of class AuthorisedUsers4 I1 Q" s) n- f0 M% L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! t" n  z' i& f! X3 k. M% I/ {Shanghai - 2007
1 K$ T8 {/ W- a3 jAssignment 2
! m, H2 {% M# W8 n( t  Y% bDeadline 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)5 a9 j, G6 c$ ^7 K+ \* a
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./ _/ G3 I$ k* Y9 f
The staff must be able to:0 a7 i% `! O  }) \( W7 e4 d
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 J% r1 N2 I) x
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.
. Z6 d$ h  G! }, I The interface should provide a menu so that the staff can:. I. V& l# f+ G8 O& p
a) Enter the names of the two Java program files to be compared* [. S3 S7 q; }( K4 v
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- b, O) c2 e8 t( l5 W: A/ x6 S** 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).& b% \& C0 z; z9 K& I% o; D
BSA104 Business Programming – 2007: Assignment 2
7 M+ f* p% A, ~% i! rPage 2 of 5. n2 O! l# H' C7 R( G
b) Print out to the screen all the lines of code that are the same8 R( r: H! H2 u. F
 Include the name of the file and the line number of the code being printed for each of the two files
4 d' Z0 P7 T1 [9 C' c: Gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( x$ ?. [4 v* z$ L% g
 the name, username and department of the user
$ m5 E: H* A) q. x( f% }8 s the statistics of the comparison
% @. d( d) ?5 m- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: |2 ?1 W! w5 ~( D+ o
 the recommendation for further checking
  a8 _4 `( B3 @7 I- 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) W' h' a; T  O& i! {6 D0 V) h2 w
 the names of the two files compared
+ B8 P9 ?: S5 W: g$ {+ ~: L/ kd) Leave the program (exit)! L% W8 _9 a4 a2 q. @1 L) P
The ProgramCompare class: (Total maximum 20 marks available)
+ A9 m! r$ v8 D% o, m2. 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)% e5 Z0 d' A$ @+ y5 g2 I2 g: V' c  b
a) provide an error message if the files are not found or there is a problem opening them$ m; m+ ^: O0 F5 y4 [0 y
b) compare each line of code
: H6 ~2 {/ G, U0 fc) print out the lines that are the same
4 ^0 a0 L" {" J; Yd) count the number of lines compared / lines the same
' O9 a' U. B/ I% IThe AuthorisedUsers class: (Total maximum 20 marks available)& J( [5 o6 w; y% |8 E3 T
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)- J; D9 {, t  T
4. Provide methods to:
; ~: b, h$ M# c, La) 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 ^; a7 w0 q7 c  Z7 G) P
b) return the name of the authorised user" n1 e& }* `: H+ j
c) return the name of the department of the authorised user
# o4 V1 I& a& ^$ O+ EIndividual Data (Maximum 20 marks available)
0 k$ x, X6 e5 Y$ M$ w5 X! a5. 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.
: c* O' s* p& d  ]Documentation (Maximum 10 marks available)
- V" v5 D8 [3 E6. 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.* X5 J- V9 }" c! ^- i
BSA104 Business Programming – 2007: Assignment 2; s9 q, L7 w8 f+ ~) {
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 N0 }3 g! a  K+ h
不过你要翻JAVA的类库说明。你有下载没有?! Z/ f# f/ z4 I
查询关于对比的函数。貌似关键字是contrast,还有compare$ r3 S  q! Z! z4 \

8 z5 B0 v/ h* n, a9 h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -, Y" A0 g4 ?# F, W7 \' w* U
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ i1 N( v7 B8 W/ j3 w可以下载到的 是 jdk-1_X_0-doc
, S' s1 \8 l/ j6 \2 _; z. j3 h: J' N. y1 G$ s: c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-28 06:49

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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