找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1606|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 d/ u- l8 L. }5 r9 {5 u3 G4 S! _ _# N* l; Y( ]8 r1 ?# b8 ~$ J
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
2 m' a0 o: M* w1 C& e/ o% h9 p* K; M//  ProgramCompare.java         Provided by: DRS- h& q- M& Y5 H$ p6 J( |
//
" |- k# B" i4 X& r; Q/ |/ ?2 I//  Program shell for Assignment 2
$ R1 ^) r# K7 ^1 e* D//. Y0 m5 G9 s1 \, h9 a
//  Compares two text files line by line9 ?' w% {( M( y) Z0 h. o( }9 z" q
//*********************************************************************9 b) Z6 @% m, ^7 x) I
5 Z- f5 |% M6 t6 @: y
import java.io.*;- f# E! P- I) g# Z6 y+ j  q

  B0 I0 X- [3 y7 J" e% n* jpublic class ProgramCompare
- N8 c3 u0 n- _4 s{
) l6 h0 O% m! K8 C        //-----------------------------------------------------------------* F$ I; y( @. |9 P" K+ B
        // Constructor
# w( O( Y7 Y" C$ d, S; W& O+ h        //-----------------------------------------------------------------
/ f2 \! B1 F+ \- Q        public ProgramCompare()
# Q2 K: M  @: f/ K/ f7 H$ }        {
- h/ t: P0 ?- b$ ]3 E# [        }9 _" c& P* b  z6 y( e0 f
5 |0 S" j( q/ O
        //-----------------------------------------------------------------
" S% ]9 q" y. A9 h$ e        // Method for testing that class has been reached1 u) s* x$ E' [& R& e/ R
        //-----------------------------------------------------------------          y/ s% ~7 B( r

) ~! r( X1 \' Q% s        public boolean ProgramCompareReached()        
$ e3 n: B; p) U! _4 K- {6 U        {9 N, [5 \' y8 d: g
      try
7 w4 f  E3 p& T3 R6 O$ x   {         4 O" J6 b% b" V. L0 P/ ~
                       
6 @/ z, f& ~  [- r                //********************************************************************: d% D7 ^* G$ ^4 s
                // Try-Catch Statement is used to handle exceptions - such as file not found
% f7 u( n' T8 }4 T0 `                // Reading the files will need to be placed inside a Try-Catch - just like this one!
: |% @. j+ T7 v) ~0 n8 e/ J3 Y8 N                // For more information see page 534 of the textbook
7 A$ l2 X6 M4 g( J, P, m                //********************************************************************
  w$ C( ?% E( z& `                    
1 ^7 n7 Z# h9 z$ y% I1 {8 J8 u        }. J" S8 x& Z, o! [- P3 j8 X0 M! ]# e
             catch (Exception ex) // Exception caught here and message displayed to the screen 1 L1 T( H. ?& s
          {! O  P% q+ i& M; ]
                    ex.printStackTrace (System.err);
' y+ e' q. H/ l2 V           System.out.println ("Error message goes here"); // Replace this error message with your own         
; q% c5 Y2 G1 `, S0 Y% Z        }
4 K" G5 R& I: b, @* ]9 J" u                return true;
. G# p4 d2 W2 h$ ^        }+ Y- Q8 @, j$ w  G
: b: o9 c+ }. _9 L, N" `0 |$ `* X
} // end of class ProgramCompare
: a1 \! e7 A$ ?, P7 l" v9 W2 R( h- K& p# Q( w5 h" b5 w/ a; d! K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" l$ L) H0 _' o1 Y4 d9 x//  ProgramCompareMenu.java    Provided by: DRS& N* E, R2 b  f7 c: D8 k
//
% W. f6 T0 \0 m3 W5 v& P# s//  Calls AuthorisedUsers.java and ProgramCompare.java/ r; u/ w" y) L5 l
//
& i1 k6 n9 z- s# ~: T0 j3 e//  Driver shell for Assignment 2.- Y% Z6 W* J2 M( b
//********************************************************************5 ^3 r8 r+ P# V. s  M- ^  J* J( ]

# m# f9 u1 {$ z1 G0 N* {class ProgramCompareMenu4 L/ L6 s7 ^" }+ l* B: e& {
{
  N# F+ z1 u* b- ^/ A4 T$ q    public static void main (String[] args)
5 e5 i1 p" s$ e1 c* b            {/ i7 E8 E$ x0 ~+ c, z
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 Z8 W( \  b  e$ n4 Z
                ProgramCompare reached1 = new ProgramCompare();
" D+ P+ O, _' z! G                AuthorisedUsers reached2 = new AuthorisedUsers();       
: l. O  X; I0 M( c# |  X  W# u                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 l9 C+ Z$ k5 m% c( x* N                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( J9 z) Q' f+ n  X  h$ a& \        }  D& O1 J, `1 c
}// end of class ProgramCompareMenu1 @. d4 D7 ?5 y" }$ \

8 i* _" r( C4 K0 h% b6 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ L- }. L! F- d1 o- S2 ?//          AuthorisedUsers.java          Provided by: DRS
: g) `: _1 }5 R7 R" v' {//                6 \4 A0 u0 X- _# n8 W
//         Program shell for Assignment 2
' j& K$ W( d0 U. }) |2 S7 G//
  i  k5 G% b' P  |//         Represents facts about an AuthorisedUser
, t4 u* ?) \( K- q' F# K* J( _& j; v//********************************************************************
; a: M4 M. [, W) J: m
' V! n4 T* g  Xpublic class AuthorisedUsers2 r# }! _1 p# b9 m) N1 I. G
    {, w! }6 K/ E& ~! @- \
  I8 q$ R- S. X/ X" y1 r5 S9 f
        //-----------------------------------------------------------------
. E0 `& @9 ?" Q" a9 h0 Y        // Constructor7 f3 m( B* Y; S) @4 a
        //-----------------------------------------------------------------% c2 w& a0 P' o* ]5 J6 C, @

, r# w7 j$ ^8 K; d1 i1 t        public AuthorisedUsers()+ b4 i5 I3 x* {7 E; V
                {
8 m- _5 a% s1 `8 \3 _$ f! P, ^                }$ b1 @- k, a* k" O6 ~

7 P3 `0 }  @5 L, X        //-----------------------------------------------------------------
* J4 U- h: Y9 y; [        // Method for testing that class has been reached) n- \4 B& S9 |
        //-----------------------------------------------------------------        # ?1 [1 V0 z# s! O8 j- D
        public boolean AuthorisedUsersReached()4 {" a' p! O3 |* t
                {8 Z: _! \8 |' ^, r. n
                        return true;                       
# L. j1 E  u, g: l# |7 ?                }
: U( P9 t- ~2 `  B9 \               
; G0 [. k5 H  |+ N; q    } // end of class AuthorisedUsers
5 E1 w. Z* ?/ O$ v( H) R) j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; Y5 B2 Y* z6 x# @: A8 _' UShanghai - 2007
: I3 J( Q+ A1 oAssignment 2
1 w8 ^: E2 N3 H& `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)
1 j* H7 J' x0 q" V1. 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., {% {6 R% q( `( [
The staff must be able to:, I2 b3 F1 U7 S9 S/ j; T
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 Z* _9 t* e5 _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.
/ J! E. I! K& I: |. m The interface should provide a menu so that the staff can:
/ m6 ]0 u$ f" i& X# U: ma) Enter the names of the two Java program files to be compared
8 p0 S# L3 v) s" ?# b* K5 L9 E For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) ]" R: T% Y3 L! L! i
** 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).
1 l1 E, u$ L1 A+ T& ABSA104 Business Programming – 2007: Assignment 2. z8 U4 A7 O* E' n: S
Page 2 of 5
) m' N: _! Q/ v2 {& ub) Print out to the screen all the lines of code that are the same
3 U5 m* Y# c0 B" [& i  K Include the name of the file and the line number of the code being printed for each of the two files: w0 T9 y$ K$ M& \) ?' [" @+ J
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, ?7 Y4 y9 K/ p0 L
 the name, username and department of the user
% r: F1 K2 Q/ k1 y9 m the statistics of the comparison
* L1 J5 X; i5 B- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" i/ |, t8 e; e the recommendation for further checking
: \0 r- M4 \. |- 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
" V# q. v* G0 P3 w, E/ T the names of the two files compared6 m; C1 Z  \+ V0 U
d) Leave the program (exit)# \& t9 L) K  F, M8 ^) I# y
The ProgramCompare class: (Total maximum 20 marks available)% s5 l$ v& p1 j) M
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)
( v& Q- ?' f$ d3 `a) provide an error message if the files are not found or there is a problem opening them" B1 G, q0 x5 U# U
b) compare each line of code
! i# \  D1 H3 a5 g! `c) print out the lines that are the same
. T# D; R4 G1 d* @1 ^9 md) count the number of lines compared / lines the same  S  o  x- ^/ C% I5 v. w
The AuthorisedUsers class: (Total maximum 20 marks available)
; G' W4 f, V2 U1 o. j( V9 R: q2 n3. 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)
' ~0 B! U4 P  F. C4. Provide methods to:
9 c# `$ H$ Z! S3 v5 Ya) 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: B2 e: h3 h. y5 }7 q
b) return the name of the authorised user
2 Z6 A$ @1 m! w/ t% Fc) return the name of the department of the authorised user* f. h5 N6 g& S# A. K5 \
Individual Data (Maximum 20 marks available)5 X: R6 k8 Z- g5 I& F. [! a) z! k9 \
5. 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! P% ^7 \, n* a1 ?7 V& Z
Documentation (Maximum 10 marks available)
0 A$ B5 D. B+ N, ^& x5 ~/ K6. 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- M1 D: i0 D- g7 U; m' [
BSA104 Business Programming – 2007: Assignment 2
/ k! F  n" V9 `* V! L) j; l8 UPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# x2 W& }, I4 @8 l' T/ R" s
不过你要翻JAVA的类库说明。你有下载没有?
% ^/ o* {7 F+ b3 @, h# ?0 g0 G查询关于对比的函数。貌似关键字是contrast,还有compare: J" h- S/ A" ^4 w
! D+ X* J) H4 q, G/ T! ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' D9 v4 A; ^4 `( _/ D& A痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。. K$ V! Y. M% S3 y# e2 h
可以下载到的 是 jdk-1_X_0-doc- ^" Z# E9 ?$ ~

+ z5 Z, B; B; n3 n( ~4 B[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-6 00:47

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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