找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1383|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急' Q. D* k( o$ B |6 ~ 9 @' v) G5 D( n& q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************/ R- G2 I4 Z7 g2 C
//  ProgramCompare.java         Provided by: DRS1 E: d+ G. }0 v% e
//) m6 X) R) ~! b
//  Program shell for Assignment 23 Y. g# |  k; r8 G
//
. H) t9 `1 D8 D7 O. B//  Compares two text files line by line
5 c0 @4 [2 B/ f3 k1 J//*********************************************************************1 O1 m. n; E- c

! d- `- x( B0 N" B; M8 l! d% Fimport java.io.*;* A$ I5 j% k" D1 b' b6 V1 B% G
' {! c/ N# V! ^% c) j# e$ M0 b( l
public class ProgramCompare$ S" y8 R1 |+ y
{" j- ^. y4 [2 J
        //-----------------------------------------------------------------
6 U$ {4 K* |/ s) n' Y! P1 v        // Constructor
+ U8 _$ U! X( U4 Y  S/ n, @        //-----------------------------------------------------------------% J' ]. J) `- W2 T
        public ProgramCompare()4 H9 z% @- V- v
        {8 ^: V. V* |; H" H7 j0 ~) L# t1 w# A
        }
7 l- u4 E- z1 o$ A9 c! ?
, P( n+ J$ e7 z9 J9 n! P" o, t        //-----------------------------------------------------------------
# ~, U5 z4 ]" ]        // Method for testing that class has been reached
, M# V5 r. R; k8 \0 l' @! I# j% V! |        //-----------------------------------------------------------------       
* G: Q. H2 `9 f1 w6 V+ x+ t* {1 A6 G  V1 p( E. B* }
        public boolean ProgramCompareReached()         & [' ]6 B3 s1 j
        {$ ~: x* ?* ?0 u' ?- z1 e# }$ [3 y
      try
: Y; i7 a  g0 Y8 p   {         & @% w) E) u& a8 t( y
                       
% x& X' F% d. _                //********************************************************************# j+ \6 \. i; `6 g1 p: F! b
                // Try-Catch Statement is used to handle exceptions - such as file not found + V/ C6 R7 `  P1 I
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 `& t( [$ Y! [# s: p5 K0 k                // For more information see page 534 of the textbook
/ a$ P0 q* D6 ?# d! O6 l                //********************************************************************
: L/ M1 n! b: `                    
& q) \3 F, O) L1 |- [        }- t8 I7 R$ l& @5 m1 U
             catch (Exception ex) // Exception caught here and message displayed to the screen
# k3 q% K: [$ |; N  Y          {
/ u/ f- N) X! y, S! M& n! k                    ex.printStackTrace (System.err);* Q) I8 D; n* _6 e6 F
           System.out.println ("Error message goes here"); // Replace this error message with your own          & q( {" B2 v& E& f
        }
0 z& v& h5 U3 c, c+ L/ S                return true;
9 S; `8 B; ^- b( N# y4 ~6 X: j        }
( U* N/ P- `- B" `9 Z( U: q
( d/ `2 b* l0 ~" p} // end of class ProgramCompare
, U3 a' \4 ~+ m1 ?6 W8 D5 A. n
% m8 E8 U' I3 m9 C6 z9 l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ A! g6 Q1 Z! I
//  ProgramCompareMenu.java    Provided by: DRS
9 v7 p4 u8 B$ J3 G//
" E7 s, V6 o# q! ~* B; r//  Calls AuthorisedUsers.java and ProgramCompare.java" a' I5 |( d- M0 q% E6 J2 B
//$ h6 f6 o! r1 k% I, K) Z
//  Driver shell for Assignment 2.
. v( y& X- L+ a5 e//********************************************************************
+ W+ K7 B! T4 Y0 |5 `) `2 ?9 A/ X8 B
class ProgramCompareMenu
3 B( s5 j2 D/ i9 _{
3 d) M7 r2 S! G% @: y! g7 N) |    public static void main (String[] args)
; z7 }5 W8 ~" f; z! T2 a# X            {- z3 z  z# i8 s' t8 A/ r) C
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
( ?4 F- |$ O( q$ R                ProgramCompare reached1 = new ProgramCompare(); + t5 v; f7 b6 W) e9 F- b+ s- a! R
                AuthorisedUsers reached2 = new AuthorisedUsers();        6 C- i& T3 ]) ^. r
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) \4 V% M2 }& X( {& D: j. S                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 s! D1 g. n! g2 ^' M4 J1 G# }
        }1 d1 s& W' Y' A! U6 `0 d
}// end of class ProgramCompareMenu
0 |, _/ w6 p$ N. u* v7 s6 L2 n0 y$ T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 n6 |2 b* T0 c/ z) u//          AuthorisedUsers.java          Provided by: DRS
5 A' H5 n; r  a) J/ d6 |//                " P- h" D/ r; L% k
//         Program shell for Assignment 2
' a- n- T# V: T/ H# r//
2 }" |- R# O$ k8 z//         Represents facts about an AuthorisedUser% m( b  y4 I' a
//********************************************************************
- H3 q0 b9 m! }6 M* k& i
  c% k% y- ?" p% Kpublic class AuthorisedUsers
9 V. R  `* ?  W    {
+ s- z( c0 x. p1 _+ G3 K  b# M/ Z% N4 k/ I. t0 p, h
        //-----------------------------------------------------------------0 d" w9 |1 {! a7 M3 W
        // Constructor
% r8 ]0 G0 N1 U( C3 }$ _        //-----------------------------------------------------------------+ B: _1 V% v% ^; a( s
5 T* P2 h" @6 M  L% B
        public AuthorisedUsers(), t& N8 F9 o6 Z3 J
                {7 f' J5 b- p& a( _, A
                }) v& r0 T" W" R
  S6 U7 p2 y6 ], x  y
        //-----------------------------------------------------------------
3 C$ V* m2 k5 A1 i        // Method for testing that class has been reached( P( M: S2 f' z5 T0 J0 w
        //-----------------------------------------------------------------       
  Q/ W% o; X! ^( ]: y8 f6 C4 t        public boolean AuthorisedUsersReached()7 H3 m2 q% T7 B8 D
                {
7 p- g( z& f) b' ]- h7 p                        return true;                       
# ~+ u8 U7 N& {* c, J                }
* U, T3 J/ J/ f5 i               
% C" _* a! j( v* U% F# K) a    } // end of class AuthorisedUsers
( v  @' ?# D6 h- h0 ]1 T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) M0 X8 v* o9 S4 E9 X: R  i0 R
Shanghai - 2007
! U+ ~% `, Y! B5 F+ x  fAssignment 2
/ x' R( V1 [: J; [, L5 dDeadline 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)
! ]6 O; m# {  ^" l- D& @4 ]* o1. 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./ m& z2 s! S+ V! \
The staff must be able to:  N5 [) d0 g! @! j
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. ^0 y  F2 T" r$ ~+ \. P
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.
) b; I9 p! {# `, P/ } The interface should provide a menu so that the staff can:
! y0 |' B* v, a" l5 ]a) Enter the names of the two Java program files to be compared3 ?9 J$ Y& @* J/ E1 }  ~
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program., O5 f7 C5 Z: Q0 A$ }* D
** 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).# a2 S# O4 s0 _2 y( I" d9 m8 ~# R# \
BSA104 Business Programming – 2007: Assignment 28 [* y/ r/ `- z! B; ?! d
Page 2 of 5
- I! |6 J( X" Q  qb) Print out to the screen all the lines of code that are the same) ?" L  e  ?! m
 Include the name of the file and the line number of the code being printed for each of the two files
; e. U' Z2 [4 J3 dc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, s: U3 q+ S1 v4 x' ~7 `
 the name, username and department of the user
9 C- K/ h- |! J the statistics of the comparison% ^: m" R4 e4 S6 r: ~4 Y& J
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different7 U" ]# k% v" t& E7 B# q
 the recommendation for further checking
' w) p( N/ n9 @( ^( J0 }- 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
/ b' Q/ X0 {7 d* z" W; b- S the names of the two files compared
1 {% W4 N: W! W% P" T2 I- p3 Hd) Leave the program (exit)5 b1 `/ p8 t; V5 `! ?; a! Z
The ProgramCompare class: (Total maximum 20 marks available)/ J( ^+ y. G  f6 w4 @2 C
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)
& S; `6 o! C3 N) c, H- ]- \$ ]a) provide an error message if the files are not found or there is a problem opening them2 X2 m" M; q7 R$ n, S4 B. X; Y
b) compare each line of code
9 I1 r4 i/ X( @  a. s) Y0 @c) print out the lines that are the same
) `6 S( g6 Y% b& O+ X4 zd) count the number of lines compared / lines the same/ R: }4 o' v+ u0 ?# M2 m/ M: J
The AuthorisedUsers class: (Total maximum 20 marks available)- ^& C! F" F& Q* ^
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)4 [6 M8 l5 L& E7 }1 {  {$ G0 N
4. Provide methods to:
3 `. f: l+ }. C, Z* Na) 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
3 C$ n) E( `2 E% F/ n. G' Kb) return the name of the authorised user
' d, q; B" `' F  |$ r; Qc) return the name of the department of the authorised user& w) ~8 ^  m8 O8 F* U
Individual Data (Maximum 20 marks available); W1 k/ g, Z" E( a
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.1 d. b; P9 _% ]2 @5 C% g9 d% \
Documentation (Maximum 10 marks available)
! O: U) {/ y7 T6 C( j6. 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.
- o. i- F  {, Y. d- U- C. R- CBSA104 Business Programming – 2007: Assignment 2
. ~8 {  |9 Y5 O; wPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 V8 I$ L  q: R6 S* |
不过你要翻JAVA的类库说明。你有下载没有?1 j3 {6 u: U- ]1 u
查询关于对比的函数。貌似关键字是contrast,还有compare0 p- b+ M0 e/ [8 y) x

# j$ r8 x+ g: `8 {5 i- F8 A/ D, T[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ }2 H9 ^+ T+ r2 y0 N6 l
可以下载到的 是 jdk-1_X_0-doc
) w3 R4 J) f4 A! ~9 G
, W& i/ y" d( Z6 V( ~4 o+ E( T- s[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-15 02:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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