找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1707|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" p1 a5 c; U3 c. a, Q0 _ ( Q% ^* R+ v9 f+ O- }" {
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! t* I0 I, ?/ u6 l7 a2 v9 ]
//  ProgramCompare.java         Provided by: DRS3 P: w2 S; ]4 q9 {5 c6 d
//$ L9 i! Z% W- g% O1 w. b2 |
//  Program shell for Assignment 2* a" ~* a( t; ~: O1 L
//- q3 V$ W& h$ \, H
//  Compares two text files line by line
0 |, s; B+ y/ M8 @* K; F//*********************************************************************  N% y/ M- D1 N) s% ^8 w* x+ g
! \' n6 a) P2 I; v) T8 t8 {
import java.io.*;
3 [0 N( S. _. @$ k, m+ n0 D$ q
4 u9 L* E) f' _3 i. mpublic class ProgramCompare. x6 L. l1 `3 z* _% y7 f
{
" ^9 P! y' q3 g# F" b* a9 Z0 c        //-----------------------------------------------------------------( i4 v. N" ^9 r; N
        // Constructor! d9 R" D8 }' q8 i7 D  Q
        //-----------------------------------------------------------------+ L3 r" m8 v9 J: E
        public ProgramCompare()
: v1 v4 g% a3 o  h        {8 \4 r& E/ A5 `# i, P
        }
' D& Z, ~9 ~2 V) I9 t  s2 b+ H2 u( G+ x$ A
        //-----------------------------------------------------------------: n$ `1 {; g) N5 z+ d: P" M
        // Method for testing that class has been reached
2 d* U+ Q8 B7 P  a- W$ Z" \+ ]# b- K        //-----------------------------------------------------------------        , }9 n( Y8 l* x) U! z4 N2 x1 I
# g. w; W3 i. L- q+ y
        public boolean ProgramCompareReached()        
& F9 B+ }7 M  u( X& c/ @, Q        {
- _$ Y% i1 x4 s* k  Z% T+ {      try
" ?2 ]* p) W) t   {        
( B, M3 H/ p0 d- }& q4 E4 f                       
3 h: n1 {8 J: p9 o                //********************************************************************& m$ D/ W3 ]* m0 V" i
                // Try-Catch Statement is used to handle exceptions - such as file not found . H0 q' {5 K7 Z* n: e; `0 t
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 }% j8 J0 d( _3 k                // For more information see page 534 of the textbook" S  Q' u# f1 w. |. ]- g
                //********************************************************************& Y/ h+ R- K, J9 W$ `
                     # J$ X2 P% {/ J
        }) m( Z3 ?& ^% P. D. {; \% D' b% [
             catch (Exception ex) // Exception caught here and message displayed to the screen
7 q2 l% T4 ~/ u3 [5 [1 |. {3 ?          {, O6 p( `* }$ H
                    ex.printStackTrace (System.err);
5 \4 g( Y" b. C* L" l( O2 j           System.out.println ("Error message goes here"); // Replace this error message with your own          / |7 y, J# k2 u5 M$ F1 X- r4 ~
        }
2 f# G. C0 e2 n# O! @  C                return true;
% Y& G3 j& J" W, q( B2 k) O5 t        }
+ {. a- }  m% Q! L' b- l, e9 `2 B5 i, p% Z; O6 a  g; e
} // end of class ProgramCompare
) J& c2 H0 w6 K& P* }7 f2 h: w- e! p
4 G4 t7 l! {/ {+ m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- t% L( x7 Z0 B" k//  ProgramCompareMenu.java    Provided by: DRS
0 B! a) W3 ?6 }. Y5 D8 P( ^+ X//7 d5 P* m' z0 N' |0 q
//  Calls AuthorisedUsers.java and ProgramCompare.java+ {7 p# s+ B4 y1 X3 \
//- B6 l8 j4 i. _" s% m
//  Driver shell for Assignment 2.
# H: R8 @' \& B* Y$ N6 j' ?//********************************************************************
3 }1 N2 l" o% m3 J9 ?) P0 U  [  M, H3 B9 D* N" Q8 R4 T
class ProgramCompareMenu
# E; W0 p" I2 H! M' ?  h{
. k" z# L! d; {    public static void main (String[] args)4 W8 v8 Y2 o( M3 t
            {. v1 l: i% T( Q% ^6 Y! b
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; L7 j/ q3 {/ A; @  G                ProgramCompare reached1 = new ProgramCompare(); , \, f7 e3 k2 W5 _
                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 m0 a, k* `6 E! D. X                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- q+ r! A. c- m: G" [. q9 J! I
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + k& ~: \3 m( _- J  [( P( F
        }
/ |- v* B2 R1 `; \! B. `) O}// end of class ProgramCompareMenu
9 |  ?& ~& H( M: j$ ^: V2 l
1 P) `- b9 v- z% K* ]# w4 v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, L% c$ W  e$ p6 O7 e//          AuthorisedUsers.java          Provided by: DRS
& d8 q' b# z1 U//               
$ Y. R& o; O$ k//         Program shell for Assignment 2: m8 N% j: B" I* J7 @& m6 T. `/ h( ]
//
' w) k  F$ [' t7 K+ W8 b//         Represents facts about an AuthorisedUser
# @0 g/ V; f0 P% T0 i1 [, \/ ?//********************************************************************* G# y0 ^" t1 u3 A7 |; ]0 \

# N( O; N$ @! ~public class AuthorisedUsers9 N) h, b4 B2 O
    {3 E/ T, D2 K, G) n" s  G
) S7 {5 x& u4 x% h
        //-----------------------------------------------------------------
& ~8 [! s6 U" M; f7 }" ?1 ~        // Constructor! L5 m) f/ d4 s2 Y0 ]
        //-----------------------------------------------------------------
' s) b6 P( K- v# d% H3 A6 }
2 u; L7 S' }1 M* u8 r$ R" f        public AuthorisedUsers()
: K9 f  w! D4 ?* j) a4 a) m                {) [  \9 u' L1 A* A* B3 k3 k- h
                }3 T  L/ R$ m) s& p  n
& H8 j0 P5 Z1 L; L, `7 g
        //-----------------------------------------------------------------
  @9 c  N; X1 m) z) m4 Y6 w8 z        // Method for testing that class has been reached
' ]$ \* P8 a6 G9 e% j        //-----------------------------------------------------------------        9 {' a. ?. p. [  c; H- ^% d
        public boolean AuthorisedUsersReached()
: m7 n9 v9 g4 v& V9 m" `/ S                {
2 M9 I9 \% z9 Z9 y                        return true;                       
7 {* Y# r8 `: S- j* ~1 T                }
0 P0 K; c# J8 Z# m/ b* c# n; _                2 q, V  _( H6 j' }0 O( u0 W' |
    } // end of class AuthorisedUsers
% l$ d* a, L7 W3 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 }" c  s- @8 o9 k2 \, F
Shanghai - 20079 @4 ?2 S6 G+ n1 x
Assignment 2
' T* E: @6 |( _5 g* A2 }# U7 YDeadline 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)
" E7 g# `9 |$ D% \6 ]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.2 H$ Y; `* r6 x: Z4 {
The staff must be able to:! {# L5 I4 ?% }# `2 W0 B
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ x: T/ D9 H9 {/ d1. 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.# r8 Q1 s6 l8 @# l+ F' ^
 The interface should provide a menu so that the staff can:
" ?5 Z2 C/ P4 z, Ia) Enter the names of the two Java program files to be compared
! r: [; F) G+ ~+ m For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  c' H2 V6 Z+ N" M4 c
** 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).
# R8 f, l9 \& IBSA104 Business Programming – 2007: Assignment 2- |  K: m1 r) P+ V  {
Page 2 of 5' T, p) b6 W( E0 E
b) Print out to the screen all the lines of code that are the same$ c  q  v+ N+ J6 k9 s1 \0 H) I
 Include the name of the file and the line number of the code being printed for each of the two files
6 i! I) b. `! E: ^4 Hc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ V) K2 C1 r- N& E6 v% y
 the name, username and department of the user
4 A% h9 \2 [1 c8 Y! Y1 J the statistics of the comparison+ }- J4 e  G/ z% I& V% _. \
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
- J0 \; O# |2 J. R% h the recommendation for further checking( R; U) \) C7 |( W+ l/ z/ v0 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
2 ]* u4 [. w" R/ f* c) A5 r the names of the two files compared. f: [+ t7 n0 t
d) Leave the program (exit)
+ ]6 z# ^5 v2 O& vThe ProgramCompare class: (Total maximum 20 marks available)
2 b9 T3 X1 b4 H4 z8 O" u" a2. 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): |- [2 B. o' U! I
a) provide an error message if the files are not found or there is a problem opening them6 v8 C, r- J) Y3 j
b) compare each line of code! T: {$ H$ z+ t2 K+ Z8 z
c) print out the lines that are the same6 j0 Q" t$ y% w1 N' q( B' i7 A
d) count the number of lines compared / lines the same4 a+ l5 ~+ P! S! o9 r9 [+ s, K9 l
The AuthorisedUsers class: (Total maximum 20 marks available)7 O# i  i) P$ Q3 [9 `& d
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)
9 x, p. }: \7 {6 @( Q3 z4. Provide methods to:) O$ ~0 _/ q: P8 C* g9 C
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 match5 T8 K4 q$ u  S1 z$ q5 L6 O4 E
b) return the name of the authorised user
5 d, r( a: L1 fc) return the name of the department of the authorised user
8 h8 c+ J) n! o, h: E& J+ oIndividual Data (Maximum 20 marks available)
( y; q( u4 c: I) D$ l1 x$ G5. 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* i& B, ~% U! q  z( M* Q: E
Documentation (Maximum 10 marks available)
: c. W# V: Z  [& w& n+ u, \6 V6. 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.
. _; D" R, s1 h) }, A: R5 A* iBSA104 Business Programming – 2007: Assignment 2
# l! t- i4 T4 i( K( VPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- X7 s% n! i, Y: H' W! H不过你要翻JAVA的类库说明。你有下载没有?7 _8 h* f/ h- T' g  X
查询关于对比的函数。貌似关键字是contrast,还有compare
. R4 C4 f$ b! @/ f; t9 l- y
+ e5 g. _2 N; a. F/ |/ w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 K# q( t" W% U0 {. O( a痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 d  M: l5 l9 K7 Q
可以下载到的 是 jdk-1_X_0-doc6 L/ Z/ {$ O+ z, z7 W
$ I) t9 t1 v. g2 {7 ?0 P
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-7 04:06

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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