找回密码
 注册

QQ登录

只需一步,快速开始

查看: 879|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急' O$ X, l) N; A, A8 w. B. a, i5 | 1 U6 o8 l {7 w* T1 E
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
8 a" P/ }& m9 F( R9 l4 U: m//  ProgramCompare.java         Provided by: DRS
; y& \; _- k4 O1 W* N//
. X* A# \3 ?4 n' X//  Program shell for Assignment 2
% k4 R& D" h  O& N# k//
8 x/ C% a; X, G3 h0 T//  Compares two text files line by line. @" |1 Z, t5 u$ _2 W, y8 r
//*********************************************************************
) C2 `: C" }" O( p) `0 X( `; Q# R+ N4 l$ o- \/ H( s
import java.io.*;9 a# ?# F8 X/ ~: X' h
. T' U. m7 j0 G' z+ q" A
public class ProgramCompare  i' @7 t' n3 w. R  r6 A
{
3 ]- O9 o! h6 V- F        //-----------------------------------------------------------------4 M* h" i# D0 N3 @  F
        // Constructor
5 o. X; H7 G  d6 g- {+ R        //-----------------------------------------------------------------. D0 v& J" I% a7 m2 j
        public ProgramCompare()+ Z# ?$ X! z, l' G' D$ g  E" G
        {
7 I* s" u% G$ N  U1 u3 D        }7 [9 Y) T1 s9 t: c; z$ r
, k: I, q/ z  {: U  F+ g0 h
        //-----------------------------------------------------------------4 O9 d6 M! y+ U3 I0 j" P
        // Method for testing that class has been reached
! P- K8 t2 @+ y. |        //-----------------------------------------------------------------       
7 H0 e' y' e) _, h  o
* ]9 K. b: Z5 u! ]5 ~  Y+ h        public boolean ProgramCompareReached()        
2 [% V) B# D. d6 T3 o5 O$ D        {6 {4 h' l; D% F* K; d
      try - U5 J. ?' u  K
   {         & N2 o/ n; x, x: Q- O3 f8 k1 n
                       
" R: t' A7 [, x  F* j                //********************************************************************
) F( v6 ~0 z  \# V% i                // Try-Catch Statement is used to handle exceptions - such as file not found
* y  n5 C# D. W% y3 V+ w* j( y4 ~                // Reading the files will need to be placed inside a Try-Catch - just like this one!
: ^) O8 S. E8 v. _                // For more information see page 534 of the textbook
5 u% k. _7 ~3 L                //********************************************************************8 z4 t' ]) u+ L$ C$ @
                     % A2 ^5 B' e7 E& v$ ?2 w/ K3 f0 F
        }" }$ l0 X1 U1 s& s" ^
             catch (Exception ex) // Exception caught here and message displayed to the screen ( f- D8 o4 I' h+ u" U- |
          {
0 x! ~5 }$ q' r* F1 G1 F) p% ^% H                    ex.printStackTrace (System.err);
9 R  V. ~3 e6 J8 J3 h7 F           System.out.println ("Error message goes here"); // Replace this error message with your own          + L5 P3 K5 |8 R# F7 N; n
        }
1 Y- R2 C5 W: F( X! @  o                return true;* p  s4 S/ I5 ~  D& m( r
        }$ T. Q' x( Z# `7 B+ q  Y

: ?3 j# F$ p' a- R& {} // end of class ProgramCompare) H9 K1 N4 W# s- B
( T$ p9 X5 f4 [% c* B3 U) `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
5 {* f, P% U; L//  ProgramCompareMenu.java    Provided by: DRS
& c; B' I6 l: a//
1 r8 q$ O9 C4 W//  Calls AuthorisedUsers.java and ProgramCompare.java
7 u$ _- E. g) V  O& n* V, Z0 F//# B' [( ?2 y# _$ n. D+ H5 {( I
//  Driver shell for Assignment 2.
0 L3 z' |3 o) q3 y6 Y! h//********************************************************************  k$ L- k9 D- C2 E5 ~- |# X( H
1 Y; l9 D2 S6 g, i- M  l8 c
class ProgramCompareMenu
5 a1 K8 |" \" \2 V6 S6 `{
% H' h6 Y. l) y! W) _5 d    public static void main (String[] args)
: `% v2 D# D* O" {            {- N0 c, U1 q; S0 N+ o7 s1 }" t
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 c% d) }" m' J; H  e$ [                ProgramCompare reached1 = new ProgramCompare(); 1 @# T+ o6 l( m! ]% W2 V" D
                AuthorisedUsers reached2 = new AuthorisedUsers();       
! z  W; [% V/ x, W! ?% Y                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, I2 V- q' U4 v4 o4 I4 _                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 x; B$ Z% f" T" k; K1 T        }
2 e4 a4 r) O8 |7 q0 `}// end of class ProgramCompareMenu
" |2 T, x& }9 v" ?' r8 V
7 _4 Q3 g8 _& v; ^5 {- k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 i) {3 e9 J5 |$ @" z, g0 c: \% X7 f9 J
//          AuthorisedUsers.java          Provided by: DRS9 s, K; [: _( l- V7 v$ {; r% S( D
//               
' B  l1 c) m  r//         Program shell for Assignment 2
) E$ }7 l+ ~! p. m9 j! n9 R1 F//
2 Q8 t9 E' A" c- b0 n! T" A//         Represents facts about an AuthorisedUser! v( }3 Q/ C0 V) s
//********************************************************************
! J$ i: t# l/ P3 q5 ?  H* \6 ^6 K0 T  w
public class AuthorisedUsers# H$ P& W8 C+ u9 C+ x- P
    {
; _. Z% \* j4 N1 y) C. `" y1 Y' W' f9 ~0 s
        //-----------------------------------------------------------------
4 F) ^) b1 |& D        // Constructor; h, o3 C" t  p( Z1 [
        //-----------------------------------------------------------------
  p$ a5 j! W7 i! d" x1 ?# X% {! s
        public AuthorisedUsers()
/ m( z; u  n0 x8 t                {
! }, C4 k1 d1 i1 I                }5 p9 E/ m) T; [
4 z4 \! Q8 Q! r2 B
        //-----------------------------------------------------------------
- U& v) o  ?. ?# t8 ~        // Method for testing that class has been reached% L4 q/ D9 }6 c  p
        //-----------------------------------------------------------------        8 n& A9 w, A/ }; T
        public boolean AuthorisedUsersReached()% {  j8 o; j/ B4 m8 `- @  W; }" V
                {! p8 N1 ]) g2 Z3 Z. a1 I! }1 l( i
                        return true;                       
2 n8 F3 W, t4 Q                }" k' m( ?2 U+ ?& A8 C
               
# \2 p4 p; }/ M& Q    } // end of class AuthorisedUsers
  M  n8 f3 k6 @5 M0 y: n+ U8 Z2 N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
2 \; p0 t4 S6 v! ^9 P5 s( nShanghai - 2007
" f* C: B4 r* |+ l7 C4 wAssignment 27 {1 A" Y! A. |( D
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)/ y2 k+ c( d8 J% o4 l+ i
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.0 b7 a: V; ]9 Z6 s% W9 _9 x5 h  d9 _
The staff must be able to:0 Q# u% J+ ^: W2 Q5 [$ m+ `& m
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: [7 U7 o0 J# N7 q% ~% Y1. 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.
1 F. f6 l, x0 u9 y  O& L/ F+ @ The interface should provide a menu so that the staff can:) s6 j* Q5 L6 C1 ~
a) Enter the names of the two Java program files to be compared
2 k% ^9 j3 E& v( b! f4 w. T- z' l( @5 ^ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 n" t* }) k. P** 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).
- H  O- h  h" I/ f' e2 q8 IBSA104 Business Programming – 2007: Assignment 2
0 p  C. w8 Q! b' OPage 2 of 5. G% a, C; ^8 T$ I# @+ m+ y8 Y9 b: [
b) Print out to the screen all the lines of code that are the same
( S7 G7 U/ S4 T$ F Include the name of the file and the line number of the code being printed for each of the two files
7 F! i: x/ Y# |( w& [# ?; {( G1 ~# uc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 ]0 U8 B& [, B+ a' X8 G$ x; k/ V
 the name, username and department of the user7 |. D" i; k. m. k
 the statistics of the comparison" I" k3 m3 [2 c# y5 F# S
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 A) W! E+ v! Q- `* A4 F+ A
 the recommendation for further checking( a; h! `1 z, W, F4 c) x# Y* j
- 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
# R, s6 C  O  M: m the names of the two files compared' p4 i7 F+ ^8 b, R& Q4 P* l
d) Leave the program (exit)
# D1 T) b7 {8 t  A4 o% xThe ProgramCompare class: (Total maximum 20 marks available)2 V. v5 K3 D$ q; F/ Z+ m2 a/ F
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)
, k0 F& q. s! t# }4 ga) provide an error message if the files are not found or there is a problem opening them
1 b% d9 V9 I2 s5 \4 \) I" G6 Pb) compare each line of code5 e0 i. I8 D( L2 _% I" C! o
c) print out the lines that are the same1 {* U/ p9 w  r9 j. S/ E
d) count the number of lines compared / lines the same( k0 Z2 @3 G+ B; M, U* A; K
The AuthorisedUsers class: (Total maximum 20 marks available)
* L" s7 |1 A2 M8 V) \8 f9 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)
( T! B$ a2 y5 z1 K  I4. Provide methods to:& V8 y! r% E$ s4 O" s) u, j
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- ]# a; f% }- _3 Z4 t
b) return the name of the authorised user
, Y) m8 c9 ?' bc) return the name of the department of the authorised user. g6 n4 M7 O; D4 u. w  P
Individual Data (Maximum 20 marks available)
; Z( Y/ w0 `5 p% b' Y5. 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.  g% e& Y% c) ^7 R1 ~
Documentation (Maximum 10 marks available)  m( J( }/ o+ U3 @  E8 H
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./ {9 D& q1 n( X  _
BSA104 Business Programming – 2007: Assignment 2& i& V% `7 V3 Y2 V: [* n7 ?$ Y/ H; U/ g
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
: ]. M0 v! k7 K+ c8 x不过你要翻JAVA的类库说明。你有下载没有?
( m# b9 M: l0 R% K查询关于对比的函数。貌似关键字是contrast,还有compare
+ q' g' \: C' _& O3 a5 \, _: D0 G. t% R6 t+ n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -2 l  h+ n& I% W0 B4 S  F
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 E% ?6 X# H7 \7 [1 _- p
可以下载到的 是 jdk-1_X_0-doc
" `+ d: k; v9 r/ \" w8 |+ O' v% \4 g* x, w5 C+ y8 Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-5 06:14

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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