找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1436|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * Y+ w7 ?1 o, R& h! K! I+ F9 G8 C( v2 v9 j4 q0 n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************# m, B: w% T  I1 b8 \
//  ProgramCompare.java         Provided by: DRS5 [: V/ L. r) A4 j
//% e* ?3 T$ X$ s. P# h
//  Program shell for Assignment 2& r! t2 V& k* e# O+ [8 l  {
//, ?* v1 u/ d; Y/ ?9 A
//  Compares two text files line by line! p3 l! |7 ]& C% C5 U. Q( `* \
//*********************************************************************! }$ r1 D5 I9 l7 x  \; R$ ~

0 T6 I% m  d) Wimport java.io.*;4 f9 M/ j0 m  ]" x/ W7 ^9 l. P

+ h$ n1 L3 {7 T- t. ?  w3 N0 j- tpublic class ProgramCompare7 Y0 r0 i9 r$ x) N! m
{' l  x! G. K' v- \! X
        //-----------------------------------------------------------------
% Z5 O; E& L3 J, H5 d# i2 o        // Constructor
! q( c; P- Y' s        //-----------------------------------------------------------------
5 l0 I9 Z0 w& \& M        public ProgramCompare()7 B0 b8 B) x; [' x
        {/ x- J% x* }+ C; e
        }+ f% F# J; u  H7 V0 X0 Q" i. q

: S9 ~$ G/ I5 y7 T        //-----------------------------------------------------------------% K! B( B4 a1 ]* g5 n
        // Method for testing that class has been reached
$ h1 ^; x' ]: }, r        //-----------------------------------------------------------------        . h: x- _: R) w1 j9 C' N7 U9 r/ k  B1 O
% A9 l8 N4 C/ D8 ?
        public boolean ProgramCompareReached()         2 S) P- t0 L0 e$ R
        {3 M* u7 @  u2 Z0 |, O+ ~& E! x
      try 7 |4 v# X1 L0 [7 T, h  w1 w+ n  e
   {        
9 ~* @! g# E, Z. q( v                       
4 G! M; ]; I! }$ H( S0 X                //********************************************************************
! v5 r/ e% A4 {( i2 E/ R                // Try-Catch Statement is used to handle exceptions - such as file not found 2 L; N+ b5 X9 |7 B+ N" o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
% O. |6 V2 K( c) g# v( Q, n                // For more information see page 534 of the textbook  e# y  O& p, L& F0 E  r% d. j; l
                //********************************************************************
: o. P% {: m  [0 F; ~: U. I                    
+ }) [. \' g0 ]2 J! J  |/ ^        }, X+ h. \& \) m' U4 U
             catch (Exception ex) // Exception caught here and message displayed to the screen
5 l5 Z/ i6 J! C5 G7 V          {
' r3 M- U7 n7 L: Z, B                    ex.printStackTrace (System.err);
# L7 Y+ E, Q1 U6 w% F$ J2 v           System.out.println ("Error message goes here"); // Replace this error message with your own         
: F7 @# ^* ]9 }( |* q% \        }$ O5 y' I' k# Q- y/ ]* g
                return true;
( U  |5 I& v7 `3 D        }$ X) u- a+ J, K# l. p
5 D! C1 G7 `/ ?. n; q
} // end of class ProgramCompare
7 i0 S; z1 r$ [
. N, R2 `$ I/ h) Z7 B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ n' o" I% a2 ]2 C. X# f9 t: f/ K6 H: G//  ProgramCompareMenu.java    Provided by: DRS
& O/ c6 e  G3 k! P4 P- n2 M' v- u//
' O3 s) _& u/ G3 |! C//  Calls AuthorisedUsers.java and ProgramCompare.java- |6 g. p5 O, Y* B# d8 M
//; c/ D# O( ]- \; ?. e8 f+ B
//  Driver shell for Assignment 2.2 i/ K$ @1 w( ~3 l
//********************************************************************: ?) x3 q: o7 h% \: e- a
8 m: T* }: N3 Z# }& S
class ProgramCompareMenu3 O2 q$ F; \" |  K1 u, V  v
{( }- ?; [. d4 @* Q5 Y  s& Y) Q
    public static void main (String[] args)
( \4 K% L$ k" q. f* _& Z            {
$ y& S2 t, Y+ \& M9 X- @( k8 I                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable' M/ n& X8 d+ U; o6 U- {( u
                ProgramCompare reached1 = new ProgramCompare(); 7 {* G5 _* d8 k$ e2 B. v* h1 f
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 c7 y5 F  V6 r: F/ S) \; a: O2 Q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 [, {1 |% W) q4 }4 U) G
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" j! `' u- A4 g! ~/ R; }/ F        }
6 h3 V7 @6 O7 l* l- E$ a, l# W4 ~}// end of class ProgramCompareMenu# @/ l5 `! q# m3 y0 `

/ C: I+ O4 O, K3 S+ _7 P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************9 ?4 H) O8 j' j  W$ f
//          AuthorisedUsers.java          Provided by: DRS
8 w% k# z/ I/ }& S6 B0 R( N//               
+ \+ ^+ U4 X( G+ W$ I, x//         Program shell for Assignment 2
5 T% Q7 C8 ?2 Q8 P//
+ W& M% }! V2 p, Q' C//         Represents facts about an AuthorisedUser( l& G9 O# S! ^9 q; u/ l9 V
//********************************************************************, v3 Y* f, g. o

3 A  |# s+ Q# u: d  gpublic class AuthorisedUsers
* `2 R- P3 {- G4 ]+ Z+ K( p* k    {- ~& X2 Z2 |2 B$ Y  e$ A

9 s# l% R) w; v% D        //-----------------------------------------------------------------# x! l& s! ^$ C* s. Q
        // Constructor
8 U  Q, t4 z; e        //-----------------------------------------------------------------7 @3 w8 |. \$ R

8 n$ N5 y4 k7 \; X3 f        public AuthorisedUsers()7 Y6 u& h; K# z+ Y0 w6 h" C' \3 l
                {
1 g' y) s3 a6 n- v                }3 s+ f9 l9 I+ ?/ I( R* z3 Z
9 h& E! Y* z1 |- D7 F1 N9 }1 b
        //-----------------------------------------------------------------
: [3 B* F4 ?8 f) y        // Method for testing that class has been reached! \, k1 c, C: V8 B$ q) l
        //-----------------------------------------------------------------       
5 {0 z: e8 I! M& Z0 g9 |        public boolean AuthorisedUsersReached()/ Y  X% w# p: g% r7 I. G+ p
                {6 t5 i9 U  Z- h
                        return true;                       
8 x9 S4 x  L6 r3 w; J3 O0 V                }
. @/ k1 z% X; X7 c, b6 n! y               
+ }: G6 n* G/ C+ ?6 S* I" A    } // end of class AuthorisedUsers9 |7 n6 z6 {7 [5 H2 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 J2 M/ E6 v1 ]( R9 lShanghai - 2007
: {+ e! P! Q; ]. l  |5 w/ tAssignment 2
: ^4 C/ C, s# l0 R" }) HDeadline 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)4 b  X4 p( o( F9 i) _# `, q5 ~
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.: C# }. }0 t. W. w7 P
The staff must be able to:
4 i0 m3 d' Q5 Z* ~# W, L5 o- u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% n: k! ], M8 |% u- x0 f2 e
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.4 ~. _# d* F: j7 U1 n1 g8 p
 The interface should provide a menu so that the staff can:3 q2 s0 F) A3 _
a) Enter the names of the two Java program files to be compared
  f$ [* F7 L! Q8 S For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% S8 X5 r. `6 G) }# A+ x0 `7 G
** 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).
: i0 y  M0 @# WBSA104 Business Programming – 2007: Assignment 2
) L' O, _2 h  O6 d; {1 m$ L4 dPage 2 of 5
2 C* m& O$ i& n9 }" D2 eb) Print out to the screen all the lines of code that are the same
& a' K" e; X3 u8 J Include the name of the file and the line number of the code being printed for each of the two files
( C  g" Y/ j# c7 y8 }: nc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: B( C; L; _* d! k the name, username and department of the user
+ R- o; `$ r. @) X0 u the statistics of the comparison0 V4 j, s" V8 Z4 w7 F" o7 N& D
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 _' {1 Y  N5 F, q+ R) Y the recommendation for further checking4 a% K3 {$ c5 t% H- O: U1 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$ g1 b" E5 `! U
 the names of the two files compared
8 p# x8 t" Z& r5 b* ~9 n% pd) Leave the program (exit)
6 I) H+ k9 y3 Q% @The ProgramCompare class: (Total maximum 20 marks available)
; \9 |% o* Z; c2. 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)) t) z  v: d$ h7 }6 s% _
a) provide an error message if the files are not found or there is a problem opening them* P" z: w+ B1 U' _& s/ m3 y
b) compare each line of code
# b# W" C7 o8 m/ ?c) print out the lines that are the same
3 b% P9 K4 y' o$ f% Q! O2 ]d) count the number of lines compared / lines the same" @4 q- E& }! O
The AuthorisedUsers class: (Total maximum 20 marks available)
  m; ?" T; H/ R" m) c" q3. 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)+ `4 }9 o' R+ ~, R) p& ?- p
4. Provide methods to:
# P" `8 |1 g8 w6 e9 a( ~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
2 w- [2 Q, t- C1 a6 ?b) return the name of the authorised user% P) q5 j% r# S
c) return the name of the department of the authorised user( Z0 S0 U' o: h1 n1 H! U8 {
Individual Data (Maximum 20 marks available)
) |( g2 e8 y% q* k% J4 t5. 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.; F) ]/ K1 ~# @- K5 }! K& f- B
Documentation (Maximum 10 marks available): c5 o4 d5 E3 p& w
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.7 {4 _  Y3 Z3 Z
BSA104 Business Programming – 2007: Assignment 2" `: W- U' `' r
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 E) Z: i- m, }1 T5 L- @/ M
不过你要翻JAVA的类库说明。你有下载没有?
7 j9 o2 R. ~' C  p8 R0 x1 p查询关于对比的函数。貌似关键字是contrast,还有compare+ Q5 m/ Y* K4 e8 e. {

6 M' m6 e, x7 F3 E) D[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# ~, U6 M5 e/ `1 J
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。$ M# S8 C. C( r* o
可以下载到的 是 jdk-1_X_0-doc
) x9 h3 f$ G1 P6 Y. O
( j, e0 `6 o8 l+ Q# @[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-5 05:15

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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