找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1513|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 : D% k" }$ O6 P0 t0 T4 T) y ) i( n/ M& r9 H5 ?$ ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************1 k6 d7 q% G5 t" \' k$ Q: m7 E
//  ProgramCompare.java         Provided by: DRS6 {. Y' z, w5 r( n' g+ U' k1 P8 U) c
//
8 t0 q/ ~: T  r  a0 C5 l( J" d/ E//  Program shell for Assignment 2
3 S, R* r! n1 k) l- w* _: z//
+ X; h6 d$ d  q* l, x2 o+ y0 n//  Compares two text files line by line
4 y9 o6 F* y: |) H* p2 P& j6 ^, K//*********************************************************************/ G+ g% h* t+ Y! |0 Z

! n1 i0 {6 E; ~/ k" {9 gimport java.io.*;
  i4 |9 }, N* C* X8 q
! l4 m3 B8 [( Ipublic class ProgramCompare
( {* {! K0 K# ~9 j& O/ C) x{/ F0 C3 d7 o) v7 b
        //-----------------------------------------------------------------
6 m( V, _3 r' @  E' d8 _; \6 _        // Constructor
$ F; H4 z8 f$ R' \: s0 Y        //-----------------------------------------------------------------" ^; [4 g5 q& `8 w
        public ProgramCompare()4 ]# Y$ d- W0 H$ C, v
        {
% ~. w$ \$ N* I; |" d        }/ x( I& p' i$ x! {/ r) i4 t6 Y

5 O; L' r0 ~- v$ |- T" l. i0 t$ A        //-----------------------------------------------------------------
2 p! l5 q& n/ F3 b        // Method for testing that class has been reached
+ `0 J4 q( t, @+ ~        //-----------------------------------------------------------------        # T1 n9 G3 U" i5 `) e& B# F
; x: g* \; @5 X8 R6 k0 Q& L
        public boolean ProgramCompareReached()        
1 O2 P1 ?7 v( N8 l        {8 }: W# W* B4 `7 C1 E% B
      try
( P, q- E. j# }* H# b, d, p   {         , c% M3 f: w! a% Y$ }
                        ) X0 U- k" n+ M- n4 W3 `
                //********************************************************************+ s$ J. x# {' W$ ?: \- L1 G- v+ x
                // Try-Catch Statement is used to handle exceptions - such as file not found , ?/ y3 T' |+ N2 V; ?+ N9 |1 b3 h$ ]
                // Reading the files will need to be placed inside a Try-Catch - just like this one!; X; ?2 J1 V( K
                // For more information see page 534 of the textbook
8 X% \, F7 `# Z* t) _                //********************************************************************% K4 Z, _1 T( a- c/ m$ ~
                    
# w. o3 d, U& |        }$ G" r' A! t2 T
             catch (Exception ex) // Exception caught here and message displayed to the screen . E8 J3 q( h3 u7 P9 T2 t8 ?
          {
% z' d& K' u/ i: S/ {! o' R7 ?9 g2 [                    ex.printStackTrace (System.err);
  g" p, K, r: u$ \2 c+ [, U# m           System.out.println ("Error message goes here"); // Replace this error message with your own         
/ \# ?( `2 A) M$ {        }, H2 Y  g- C9 P( A
                return true;
5 {9 p) `0 ?  e( T+ j* k; _5 n/ _3 [        }2 u! ~& d: i6 f0 \- k9 j6 q1 l% W

6 \7 Q) S7 E' D3 C2 i8 x6 e} // end of class ProgramCompare
( ]8 Z% C' P# s2 y  D6 I% A6 Q; @  j$ }, o5 H5 l% a6 ^; e! U
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
3 M2 A) A+ `4 l, L% ]! @//  ProgramCompareMenu.java    Provided by: DRS
1 Q" L$ I! j+ {' M+ S& Y4 t//: \% K# M8 |4 E# X: K7 D
//  Calls AuthorisedUsers.java and ProgramCompare.java* a" y" _5 G3 |/ J: `/ E
//
3 m; H1 C" F* _8 a" i+ u$ q//  Driver shell for Assignment 2.1 P' u$ {+ ?2 ], o; {7 R8 K
//********************************************************************
/ A8 n: ^* o+ j1 C. o+ u
' V6 e, n: [$ m, T8 rclass ProgramCompareMenu/ E3 c4 J  r4 |1 F) m8 S0 ?* K& W9 m
{
) [9 L( H  W( G' u. v+ v6 \    public static void main (String[] args)8 k4 s/ h. f: r$ s0 A
            {
1 N* R& d, o3 J9 G                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 F: Y( [, a* c                ProgramCompare reached1 = new ProgramCompare();
5 B7 B7 k, N; ~" S' W( ]* ~                AuthorisedUsers reached2 = new AuthorisedUsers();        ( @. O: @, n4 ^2 V
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());( I) b( ]5 U; a, Z" r. D$ A
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 B! j2 Z. i( T9 d' S
        }, x/ F) [. W- F; ]' j4 l
}// end of class ProgramCompareMenu3 ~" g( n' t, ]( f1 G

  k0 W8 G& U( o8 E+ J, W/ U4 U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 m" b9 c) N+ A5 g
//          AuthorisedUsers.java          Provided by: DRS
5 W- T+ e5 Q/ u4 ?//               
( x9 ?, E. h4 Z, V: h//         Program shell for Assignment 2+ B8 E$ p. m. c9 z+ j, N: I
//. X, n6 y5 D$ z& r9 y  c. }; b$ M
//         Represents facts about an AuthorisedUser1 I) H& d) b/ _" J' N
//********************************************************************/ V& c) o1 I& K& F( _, M+ m% d

. {* U$ _6 P/ _- z2 x3 P3 e( Apublic class AuthorisedUsers
' v4 {7 Y' U. E/ Z( E    {* A! D0 M, i" j& @+ b- A

. h' V( e1 H# r, V/ h0 H+ U0 m        //-----------------------------------------------------------------7 b3 `+ G: S& p. F, f( n, \
        // Constructor$ ]4 ~% A( u  t9 B4 h6 _
        //-----------------------------------------------------------------% L* @4 n5 b; G4 l8 g9 w( m6 l& Y

6 c" n9 @- e. C4 V8 U. Q        public AuthorisedUsers()
2 y# q8 @/ m( I( P( P                {
, q/ n& M8 _0 J6 c, o) r$ e                }; `% Y: M" o+ A" U1 k3 @

% B7 b$ G9 J9 L7 U        //-----------------------------------------------------------------1 p: ~6 y. p* O5 m
        // Method for testing that class has been reached- m8 \  |+ |/ v+ }6 X- r
        //-----------------------------------------------------------------       
; d* _4 z  e' N9 w        public boolean AuthorisedUsersReached()
; F6 l$ a2 l- c                {' `  i, e2 B" }/ C7 o9 y
                        return true;                       
: I+ t* f; x: i# X2 v7 ^                }) P+ H6 S4 K* O6 f  C  f3 j: S
               
2 M+ ^6 X) q+ T; Y( J/ G    } // end of class AuthorisedUsers2 Z, H! {- l4 T8 F3 O% n9 G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) \1 |9 K8 \1 L+ w0 G
Shanghai - 2007
) X" e" x) f1 TAssignment 2
% E- c5 K! E. b7 P0 y& [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)
* V* `; P8 @: V/ j* {6 \( U1. 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 P# t  ^9 C, d' x: k  E
The staff must be able to:
6 I& a. w* O) L. }! N Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., t  k+ j0 x7 F
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.; Q% \( L& }6 ^! c6 ?% `
 The interface should provide a menu so that the staff can:
" D; ^3 G( L8 {/ y% ]5 M7 Wa) Enter the names of the two Java program files to be compared
2 C- H7 G# ?3 p, L For this assignment, it will be assumed that the two Java program files are in the same folder as your program.* r* _! V9 U- V' X& Z' x
** 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).
. Y! y1 z3 h2 tBSA104 Business Programming – 2007: Assignment 24 X6 |! y! f1 e0 {
Page 2 of 56 D- l, d) E1 u' t2 d
b) Print out to the screen all the lines of code that are the same
& T5 g0 n0 |8 ?, \1 o; r- t* n- w Include the name of the file and the line number of the code being printed for each of the two files$ k; i# W) x* \4 S; A: _8 k- l
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 j+ P. J' P5 Z0 H# I
 the name, username and department of the user5 m: y" }2 \; N9 F2 J
 the statistics of the comparison: K) F' ]6 ~2 m, e4 x! V% N
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, L. I4 i8 F) @3 J0 R! z) x
 the recommendation for further checking3 x/ i7 Z* A- f) b  T* ?- H+ \
- 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
" \7 y: O$ v0 U6 F6 ~ the names of the two files compared
3 w) s$ e7 ^& N! O( y& }d) Leave the program (exit)8 t* y( Y3 R7 A8 G
The ProgramCompare class: (Total maximum 20 marks available)
/ J& W/ A0 {  C6 s5 ~+ B2. 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). ?. Q8 q) o7 O5 f( O- C
a) provide an error message if the files are not found or there is a problem opening them+ U6 ~5 f" ^* O- x
b) compare each line of code
/ e, i1 Y: Q9 w8 H+ |c) print out the lines that are the same' u6 `6 d1 E  P) L
d) count the number of lines compared / lines the same9 a$ X% f& T- U( Z! t
The AuthorisedUsers class: (Total maximum 20 marks available)9 }+ d# T8 G# F
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)
0 `. P& O6 x( `6 }6 T8 Y4 B4. Provide methods to:
, R" ^4 l& _6 V  S' Q6 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' @" c; M  _' H+ m
b) return the name of the authorised user
; B+ P3 |4 Y% bc) return the name of the department of the authorised user) y9 V7 w" s) M. B$ w7 W6 i2 z
Individual Data (Maximum 20 marks available)
; O, a- H0 O5 V* |- w+ c' E5. 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.
* B1 }$ L+ x' f$ i$ w0 a" s/ TDocumentation (Maximum 10 marks available)+ a+ \$ S5 o! p* d. k
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.
$ V& J4 j: |! K' OBSA104 Business Programming – 2007: Assignment 2
! ~8 |$ y4 Z! @- l, _Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( _+ Z2 |4 L1 o8 [/ W" z  T8 U& D2 d不过你要翻JAVA的类库说明。你有下载没有?" ^! Y1 M- |+ \
查询关于对比的函数。貌似关键字是contrast,还有compare
. V+ q: ~, \1 E% p# `' X
4 d7 Q# D9 @- d( V- `/ T[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -. o8 g5 J% [3 q, u
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) d+ c$ @6 b) {$ U) {& b) S
可以下载到的 是 jdk-1_X_0-doc# w9 M: r4 A6 t" D# h. s
' Z% y4 F/ x  T* d# C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-1 01:32

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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