找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1268|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) `: n( b2 ?9 g `5 G 8 e; V, L! c8 Q1 H
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% J0 ~5 }7 w- B- n/ V, b) t1 d
//  ProgramCompare.java         Provided by: DRS
7 c( F* e* l) }  f7 s6 q0 S//
6 m- h% l/ h$ N) X6 d' E! P//  Program shell for Assignment 2
0 v- ]8 Z2 P" {5 A) _% k' E//
, _: P7 f& G" B5 W# v, ^//  Compares two text files line by line
! R+ D3 ]8 o# d7 F* p//*********************************************************************
, m, j4 U0 S9 F+ Q$ R- [! |' F, p* V3 E' K/ z4 ?
import java.io.*;* `+ x( ]$ A& j1 V# S
# a3 ~' Z+ \0 t" w* {+ N
public class ProgramCompare% N8 f) t- \: c" H
{
& u8 T8 m: P6 ?- c5 M* M2 {% L8 ]        //-----------------------------------------------------------------, d/ a8 ~# L1 q. s8 D
        // Constructor
$ d! d" ]+ b8 ~/ T+ ~9 t. q; e        //-----------------------------------------------------------------* y" w9 g/ {/ J, g/ ^
        public ProgramCompare()
2 E8 e4 C% P) I8 V# h        {
+ s; S1 P/ c* D# A% d        }
& F0 J/ O8 H  F+ ~
/ W8 L* t9 a5 K        //-----------------------------------------------------------------
: {( ~6 t8 P5 f& W7 g        // Method for testing that class has been reached. P& R7 `$ _( w- q( K. F( K
        //-----------------------------------------------------------------       
2 ]( F. q% R! p6 x( a: K  b9 R. {- R& P) B0 ~5 X
        public boolean ProgramCompareReached()        
* H' w% A7 D* X2 \2 P, T  }        {: `; v; x5 }5 B) o8 u
      try ) O4 f* m! \9 Y  V$ a( i+ A
   {         + \0 |$ u/ _0 N" ^& r. A
                        9 H2 B# h) ^8 u
                //********************************************************************7 h- B, |+ L4 U; f5 V, C. K
                // Try-Catch Statement is used to handle exceptions - such as file not found 5 H- ]/ |$ ~0 ]
                // Reading the files will need to be placed inside a Try-Catch - just like this one!5 i4 `. j" D+ i" g2 m( K( v
                // For more information see page 534 of the textbook: i0 B4 ?1 q# T% M  E5 r7 f
                //********************************************************************/ ^' g: q% u! [/ W/ I9 u' I3 j
                    
  @4 Z% v( x8 _- L: z' G1 b1 P        }
/ ~8 H) u4 {0 L. a# w             catch (Exception ex) // Exception caught here and message displayed to the screen ( }" l8 @, W" E, ?
          {
. C9 j! R& W0 R3 }* t6 V; D$ C                    ex.printStackTrace (System.err);  A$ v3 {0 i, q9 p8 e$ [9 B
           System.out.println ("Error message goes here"); // Replace this error message with your own          7 f, d- Z0 N' j6 V# S( w
        }
, u5 J9 k6 R" ]) e3 ]+ \                return true;. e3 R. ?$ x3 p. N
        }- z% w3 P5 B+ R; Z+ P9 T

/ {  j% @6 {, ~$ b# d7 H5 B} // end of class ProgramCompare
8 ~) |% b& c1 L0 y& P9 H& K9 ^+ K* y' s6 l, [( T1 w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
; Y( ?4 Z3 T. }) a  d$ O//  ProgramCompareMenu.java    Provided by: DRS
6 I! N/ q& c' x& \//6 Q1 u1 d/ r3 Q. C6 I3 V/ E) d1 L
//  Calls AuthorisedUsers.java and ProgramCompare.java! o6 U" s" V  @6 W9 F1 Q  r
//  P6 a- r. b7 s0 `( L' u! ?5 ~* q1 C
//  Driver shell for Assignment 2.  B, T! z, d$ y% ]
//********************************************************************% f2 y* |) T# N4 M' u

& p2 Q# Z( ?  C1 r# t4 ^3 Dclass ProgramCompareMenu
8 b' }; v5 q5 G  w{
& O+ }. V- D3 j    public static void main (String[] args)! V5 R: r) F' L' t5 J  h4 W% |8 b
            {7 e; o! I0 h& G. P: A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 f+ N0 p0 N5 j
                ProgramCompare reached1 = new ProgramCompare(); ' J6 }- Y1 t; @% V' m6 F
                AuthorisedUsers reached2 = new AuthorisedUsers();        ) h  ~4 e) ^: h7 \
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());  Q4 a7 S+ x* q; W! o) ?' m
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , T% J, p, c% ~+ }
        }
- \2 y' q) _5 \% N}// end of class ProgramCompareMenu6 {; O, d& j, b' o3 B7 y% }" [
7 u- p2 \# I; ]" c- S
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************9 {' Z& y0 l  A% Y; g
//          AuthorisedUsers.java          Provided by: DRS
( e9 k1 B3 e- u//                : V8 ]5 @7 H& n( M  a
//         Program shell for Assignment 2
( m& L  t9 {- J3 p9 h, Z+ d# P  M//7 `" V4 m4 N' r7 |
//         Represents facts about an AuthorisedUser9 y% r) y# X) o) i6 w. V0 E
//********************************************************************2 h, ?( E$ Y' Q

8 g$ d# [' s( z8 j2 Bpublic class AuthorisedUsers
9 e; N2 w5 y, Y7 V# q4 C    {
: B: H: F, k# ?
' j: x* s5 |: m+ C- v4 [* U        //-----------------------------------------------------------------, ^! _3 }2 D) t! d8 q9 |6 w. z: \
        // Constructor
1 j6 O* s0 w# p        //-----------------------------------------------------------------
5 ~6 g' G& Y! k4 i# b
9 V5 S1 L8 @# h2 ~% t4 U" a        public AuthorisedUsers()/ V3 k: N& V" G7 g* \  T
                {
' ]" i9 K. Z5 p% z* c                }$ r# o8 \2 L6 [2 n

- A; v8 L0 w* I        //------------------------------------------------------------------ `% k, `/ U$ g
        // Method for testing that class has been reached
/ q0 I. S6 Q5 G. y  D/ K. h        //-----------------------------------------------------------------        . B2 b% d! I' q9 }% l% `
        public boolean AuthorisedUsersReached()9 }( W+ O1 M/ b% Y5 N- Z9 y% k& s( q# q
                {% @$ [8 I8 z2 P, F& k0 v: M! B( w
                        return true;                        . O% y1 g7 j, v+ W1 E  ]
                }7 `, U( B0 J/ W. ]3 o
               
" h2 K% s' P5 b5 H# M    } // end of class AuthorisedUsers
: r# |& Q7 h: M  E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# j; @3 |8 Z8 S5 k- |Shanghai - 2007
4 o/ _+ C1 d" e: U/ qAssignment 2, D$ X3 a, {4 f# Z* q1 \
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)- L! `! [' R/ u3 b3 r' s* G* }; ?
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.
5 X/ A. t( Z( F1 [& b' PThe staff must be able to:
1 m& n; [2 K5 P; |+ W7 b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 K7 i9 _1 ~6 c% M) ^# h$ q3 a
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.
3 m/ ]& [9 k0 j2 @4 Y8 V7 Y# H3 m The interface should provide a menu so that the staff can:( C- I3 H( L% J* J
a) Enter the names of the two Java program files to be compared' ?" t' X/ L4 h" y: @: o  e* s9 N, }0 ~$ ~
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 a3 K3 A- S8 F) i6 m
** 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).
! z3 W8 i7 I9 H' f8 S( p7 tBSA104 Business Programming – 2007: Assignment 2
1 z( i: F& _# p" n9 [; Z$ ]Page 2 of 5
% @) M2 x$ ~; R, g# gb) Print out to the screen all the lines of code that are the same: O. e: I& h5 \2 r2 X' A6 Z! |, X
 Include the name of the file and the line number of the code being printed for each of the two files* _. I* r( ]7 D  T) j: l( h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: w1 W$ N1 D% O* _0 k the name, username and department of the user
- S, J% C$ b% [3 j; S the statistics of the comparison+ |+ ^& H# x6 b* H
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
+ X5 V7 Z- ~1 D the recommendation for further checking% J  F: A. v+ _2 s3 ]
- 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
* {0 Q/ g' s& y4 Q- p& l8 Z the names of the two files compared
. k! y9 i, Z1 L' O/ _( Ld) Leave the program (exit), O7 A( F( J7 G% m% _4 x2 I
The ProgramCompare class: (Total maximum 20 marks available)
. R- ^7 H! S0 h  d, T" Y% R2. 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)
, b! Q% V; d, `' W' R  {9 t# T! }a) provide an error message if the files are not found or there is a problem opening them( O: w1 F( l, l# p% E; X
b) compare each line of code" U& c8 E# e/ x2 J1 a  `
c) print out the lines that are the same! x; i6 T; B. O
d) count the number of lines compared / lines the same
! N& j% d# i3 i6 ]) H' bThe AuthorisedUsers class: (Total maximum 20 marks available)
  `1 Z8 U! V) K. W3 b) l3. 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)
8 Y' u' I# w' \9 ^4. Provide methods to:7 X; X& d! }4 _
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
/ N4 N. h8 L" @) g' L0 zb) return the name of the authorised user! X' x5 R; C9 M8 R
c) return the name of the department of the authorised user( K8 N0 u8 R$ y( |$ \6 i2 \
Individual Data (Maximum 20 marks available)
& r5 B- u+ s/ _3 j$ N3 o; p5. 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.
. x1 E- p( E% g3 a( Y( pDocumentation (Maximum 10 marks available)5 s9 `0 N3 a6 c0 A% T
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.) [# G" [2 m/ a" z( i; F* p1 ]! C
BSA104 Business Programming – 2007: Assignment 25 A# t( r  p' o( Z
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 t1 t; M& ?- X5 R) N8 N
不过你要翻JAVA的类库说明。你有下载没有?5 w3 K8 v. O  |3 ~
查询关于对比的函数。貌似关键字是contrast,还有compare- y3 H: I! y1 h" Z& v& ]0 T
8 F% @+ g! q+ f/ B4 r
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -( o( M" B6 l9 Y/ X" u
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 I/ d7 H* @4 j( |  Q# }, ^
可以下载到的 是 jdk-1_X_0-doc- O+ h6 N) F' E4 U
2 k. o% f3 C: z. c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-12 22:23

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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