找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1455|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 a) s; f; I8 J6 \/ G " N+ r1 O2 O. I. [' y3 O M
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! s) c0 i" I. M; O: V4 N& q
//  ProgramCompare.java         Provided by: DRS7 E9 b! P8 F" i) g7 e! ~( C4 d
//( j( H6 t6 A, {6 ~" ~
//  Program shell for Assignment 2
  Q; w! O$ q7 q# M+ b0 y! q. B% t//; C1 ]5 `2 }4 ~/ O) Y
//  Compares two text files line by line
8 j. P, X1 U: U1 d4 I//*********************************************************************4 p0 N$ ]  A4 ]5 P. |7 F
2 K; t& n2 P; }! g8 _" S5 Y
import java.io.*;
, v3 [$ \8 y& {1 o" m- j0 o
2 \) N3 `5 E# {5 R+ y4 r4 ?public class ProgramCompare" T: }; Z' U4 L4 c: O5 Z
{
3 w" w' L  Z/ `6 g, n2 r' o5 z        //-----------------------------------------------------------------
3 ?# ]% B: Q/ o4 [        // Constructor
" M% E0 Y& L3 K8 [        //-----------------------------------------------------------------
% y+ S% \) H, I( t+ [        public ProgramCompare()
) |2 V( h' C; I) E        {# p( q1 N8 B# T* Q3 c1 ]) T9 F+ J
        }! V4 V0 t7 Y% O  |1 }+ J1 D5 @, {5 Y
2 }1 B! E" U! w' @8 X, v7 k( N" f
        //-----------------------------------------------------------------
. V) v; A3 Q' U+ D7 p: w        // Method for testing that class has been reached1 |( A4 `2 l* W( {+ t9 b
        //-----------------------------------------------------------------       
, Y0 J( u" ?) v8 ^% u* i/ B( i! k
# p% w1 k3 p5 W! B8 O8 t$ S        public boolean ProgramCompareReached()         . }: H4 |: L. o) j( H; a0 _
        {
# B% N; D# j& K! [      try
1 }- F5 K6 L0 F   {        
/ h2 a- W, l3 j' ^& i                       
: V" A0 k3 I% }                //********************************************************************2 R; N, ?$ V9 w3 `
                // Try-Catch Statement is used to handle exceptions - such as file not found $ p9 ~3 e' ]3 `! W8 V" S$ t* X$ Y+ h
                // Reading the files will need to be placed inside a Try-Catch - just like this one!5 l9 Z  T# k- S# X, H( J& E" r
                // For more information see page 534 of the textbook
# q) i$ S( g7 N7 H                //********************************************************************
; N1 q2 S: k: Q7 B* Y& @                    
0 D7 d' ?: ]5 ]) j- Z        }
6 T$ E5 N) w. Z             catch (Exception ex) // Exception caught here and message displayed to the screen * U, q" H8 M/ Q& x! J/ L7 X3 r0 C
          {' y1 {' H3 h0 Q# \7 X$ q0 s
                    ex.printStackTrace (System.err);2 @. i9 l4 j, f0 A$ d- O* I
           System.out.println ("Error message goes here"); // Replace this error message with your own          : G" @$ O: Y, y1 z
        }
' n5 n. c2 S- @! O& c& Y                return true;
7 k; k$ `' J6 ~2 E+ d! V, `        }2 d5 l/ k/ a/ ~. c5 M
# ^9 n& @3 K/ U. ]9 M' l( A- e
} // end of class ProgramCompare
# W* F. F) P% P$ W& t, q8 m- ^
" _3 ?9 h9 k1 R  W- h/ J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************% X" ^6 V" k  g! g
//  ProgramCompareMenu.java    Provided by: DRS& t/ Y' Y+ X  C1 p7 v+ E
//
# k+ @! g+ A/ ~9 k6 E7 I//  Calls AuthorisedUsers.java and ProgramCompare.java
/ B8 U0 Q! z% E//
1 p9 c/ t* k$ N//  Driver shell for Assignment 2.
) Y. o- g3 P7 A$ W& K//********************************************************************6 m1 a% y9 X1 I9 h# r2 B

7 C4 i3 O5 ^+ c# |. ^7 Aclass ProgramCompareMenu& C+ l9 |* R, t& l% [% I: i! v. E
{
9 S( J: L3 ?  K6 L& ], p2 y- i    public static void main (String[] args)8 a# f3 y% U1 ~  T8 |0 G8 p0 j1 V+ e
            {+ G1 m4 |" A% l# K( a
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- E. B4 v1 y" a6 g+ h
                ProgramCompare reached1 = new ProgramCompare(); . T1 G8 Q& N- |
                AuthorisedUsers reached2 = new AuthorisedUsers();       
% [4 h% o; J% |- b7 Z0 u                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& D1 g9 ]- U5 n% f& P7 F6 k9 a" u                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 y9 s& e" V/ E        }
8 a4 g5 V' s; h6 G/ t}// end of class ProgramCompareMenu9 I4 |6 \, d0 ]
  @* c# u2 M/ ?" m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: G& U* j7 z2 L/ S8 C//          AuthorisedUsers.java          Provided by: DRS
" ^" m: y9 T- |7 Z//                ) ?& [# a- V' d8 ]0 v' z$ W
//         Program shell for Assignment 2/ H  J2 v/ b- E1 d$ j) u
//: {0 O: n, F5 b- ]: U# f
//         Represents facts about an AuthorisedUser: F( l' @7 P* O% A
//********************************************************************  y0 K( \7 ?3 j- X; _

: t4 ?8 m3 S; \public class AuthorisedUsers
; D& s$ {( a" h' q' L2 _7 C    {
8 L$ d' P! {5 H5 e7 m3 s% M' R+ G
6 {- w% h! L' W+ }0 ]+ K- Q. T        //-----------------------------------------------------------------
, P6 G/ Q" q, U/ @2 r# ]- P        // Constructor' s. j4 p& L+ i% _7 G
        //-----------------------------------------------------------------, P: A9 Z* v. u# _5 Y( P' p4 e

1 z' H/ Z2 Y# y* ?5 _2 v0 _        public AuthorisedUsers()* r  Y4 |" A2 D, v
                {) S5 V; f* J* l8 K! l" x. b
                }' q6 a4 W1 T6 c" K: M3 H9 G
7 n$ N! y3 R+ w" d- _/ o& K: C" ?
        //-----------------------------------------------------------------& g3 \  a7 D8 G  w
        // Method for testing that class has been reached
* U  U; e/ B9 ]  S( B% [        //-----------------------------------------------------------------        9 ^4 h- K3 O7 l" j  Q
        public boolean AuthorisedUsersReached()
7 X6 M; ~  r/ O1 s7 C& A                {3 Q5 d1 Y) Z# E3 H2 w7 K2 A& Q* X
                        return true;                       
2 v& `4 o+ b/ e" Q6 L+ ~                }
% C0 k9 C" x  F4 Q                , G0 O/ k: I# a1 S3 ]# I9 r5 W
    } // end of class AuthorisedUsers
; {( Z* A# B- B( d/ E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! f" y  E/ q9 P3 e. t( `Shanghai - 2007- p! U( f  J) ^
Assignment 2: `2 A3 G% i: F/ E; e+ n1 b- R, {
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)% R: ~) |* |9 y/ U& e) M) K
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.
' s( ^& i0 H1 K* k5 x2 a2 V; n  oThe staff must be able to:/ \9 f$ P& W8 s5 \# p
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.8 d. w# }( T& s# s. x; D
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.
+ e9 j2 F* s2 X' B. F4 L The interface should provide a menu so that the staff can:
- g  u4 W2 W" b; {3 Q( ea) Enter the names of the two Java program files to be compared, ]7 x8 b5 b% R, F3 ]
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' F' |# `1 c8 @& Y2 c7 x8 u** 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).
) N8 [$ ^6 u9 u' ]$ q. z) ~5 ?3 hBSA104 Business Programming – 2007: Assignment 27 ^5 f* y0 H' ]
Page 2 of 5
3 ?0 U# C, g/ W9 s0 C5 D! ]3 v+ P! cb) Print out to the screen all the lines of code that are the same
8 j% J3 k* w$ v9 P& O Include the name of the file and the line number of the code being printed for each of the two files
& y- N* m- a( l& e* X) j) jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
  E. E, _: N8 I: e" l. }' j the name, username and department of the user5 H0 |. f% Q+ R" ^2 ]0 b
 the statistics of the comparison- h! @4 S" d/ h) O9 _- D# c
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different5 K6 R. D  S8 x6 m" j1 x
 the recommendation for further checking: J2 ]1 H/ s  n/ 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
. L1 c0 Q0 K5 b9 t+ f+ e the names of the two files compared
: m: ~, i. h) |& x! Wd) Leave the program (exit)
. i- S3 F/ ]) C. x2 ]The ProgramCompare class: (Total maximum 20 marks available)
8 R7 V& c2 |/ a$ E( I+ d2. 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)
$ k! U% T- ^3 v8 ya) provide an error message if the files are not found or there is a problem opening them4 h( b8 p# A5 y, S
b) compare each line of code
: |  k. [7 d7 `8 dc) print out the lines that are the same
1 m+ v1 N9 I% |7 E3 Y# Jd) count the number of lines compared / lines the same* F; W* b8 s. n) ]5 b
The AuthorisedUsers class: (Total maximum 20 marks available)
/ m9 _' P0 l3 w2 ]' N1 M, Z3. 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)( ]) W4 K  P, L; |4 C
4. Provide methods to:8 H4 V7 Q! A, Y; ^. t- I- q
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 v! H' ]7 ?/ Lb) return the name of the authorised user
$ b1 j4 G& l" e& [0 Yc) return the name of the department of the authorised user, w4 j1 `* @- p; g1 P
Individual Data (Maximum 20 marks available)
" k3 ?5 j# I5 `  m% ^5 P! h5. 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.
  U5 S- S. B5 l% oDocumentation (Maximum 10 marks available)
- s- `; ]( s+ ], f: p! J" _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.
4 X: i+ A4 ?4 _* CBSA104 Business Programming – 2007: Assignment 2
6 G! U8 k& m8 Q# d2 BPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
9 N2 I& b& G5 g不过你要翻JAVA的类库说明。你有下载没有?
- D) l1 _0 H3 g2 C查询关于对比的函数。貌似关键字是contrast,还有compare  r) ], ?. f' g. }& q  o
4 D9 a# g+ \! Y' S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
% Y7 l6 f5 e' X" c) d痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 P+ v) _/ \7 d* ~* q可以下载到的 是 jdk-1_X_0-doc
3 w2 }' k0 a9 T% n% n. e0 v, f) c* y5 V) x- S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-13 17:30

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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