找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1632|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急! X% T1 A. z* z( I2 D 8 G6 D3 I4 p& r
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 A3 F+ I  G+ N5 ^
//  ProgramCompare.java         Provided by: DRS" _8 Y8 O0 f% a! M- O* n/ j) Z
//
2 y- r( F+ ]! o9 c: ]5 n//  Program shell for Assignment 2. p# h5 X- V- H0 G0 |
/// p' g- ^- g* J- U. O8 k
//  Compares two text files line by line) Y& h1 v% r2 w/ }( F! e" {! X# s
//*********************************************************************- f/ |) T) b9 D" a0 j1 P
  Q1 x3 Z. E9 N, e: q1 }" b- y
import java.io.*;. V' X2 h( J! H7 D6 L* y4 o+ W
6 I( s" {8 U$ A' ?0 l
public class ProgramCompare
$ Y' o: [; @; k" ]) y  N* K3 N{5 ?) X$ H0 F: F8 K+ C
        //-----------------------------------------------------------------
9 z+ F) [) s6 B        // Constructor
& D- i2 U6 `5 c4 e2 p: |$ }  M        //-----------------------------------------------------------------1 y% r5 h- l1 _0 G- K! Y' Y
        public ProgramCompare()
; l( m" Y7 l* S/ O        {
  m: l/ \4 Z* E7 G- }0 Y: t        }. g5 H0 ^5 w! Y+ ?+ M

, C( n# y- T" g0 q        //-----------------------------------------------------------------
, I8 D6 P8 K$ }. j$ S! p        // Method for testing that class has been reached
+ N. `4 ]1 [2 X4 Z) {        //-----------------------------------------------------------------       
, W( N7 o) t4 u4 v1 L& z: o& e2 x  `; U$ }% C2 g
        public boolean ProgramCompareReached()        
3 |$ K* a' A6 P+ p% I; V7 o% u, v        {
6 {5 q6 c! g$ ]5 B/ ?) u# D7 @& M      try
  r4 |! _5 x2 M  V) F8 U5 S   {         8 z7 U8 s3 Y' j3 O, i! s. K! A
                       
" s! @5 W$ E3 C, d6 ?                //********************************************************************
$ t- @$ D0 b- ?& F& J; k' a                // Try-Catch Statement is used to handle exceptions - such as file not found
2 d: o0 J5 `# \) y                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 Z6 I7 X: G% e                // For more information see page 534 of the textbook0 G& H- b9 P2 {# h' ~9 y9 P
                //********************************************************************
/ k" x8 e6 q% R4 U                    
$ T4 l0 S. }' S7 I; v2 x3 W        }7 \" J5 u+ q, C" K1 {) [6 A
             catch (Exception ex) // Exception caught here and message displayed to the screen ) z" a* p, A$ U& y# V/ ^& G
          {' r6 @  [1 M6 ~3 c
                    ex.printStackTrace (System.err);! j* b% M( @2 q# _
           System.out.println ("Error message goes here"); // Replace this error message with your own          # J8 y% I3 `  E
        }
) r' O& k* [& F                return true;- G: K) E& c' x0 u  ]
        }1 T* M% h5 g% s9 O+ y7 A

! n. \0 ^! T9 N8 ?} // end of class ProgramCompare
0 f0 f% v( d1 g
7 `0 F* ?$ w, p4 X# Y0 }6 Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 m5 v9 H6 X# ]- M8 T4 J1 D//  ProgramCompareMenu.java    Provided by: DRS' Q) D7 I0 A& s: {
//
0 P; X: ?' W" s//  Calls AuthorisedUsers.java and ProgramCompare.java7 o8 [  o. h: x$ I* R
//! u4 a; [# h* I
//  Driver shell for Assignment 2.' V, z- B# C- O- _1 U9 z$ }) p
//********************************************************************
' ]2 h" C& K6 H3 ]* c2 T' B
7 b8 J5 q# ]6 d1 tclass ProgramCompareMenu
( ?6 S6 ?/ V: g0 w1 _7 u{6 v2 m* F# B( |! Z
    public static void main (String[] args)
# O4 I* S2 W- o  h  o3 K3 D            {
5 g* C3 B' U1 Q. u- [1 k, `                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! Z9 [7 o, J* h. {
                ProgramCompare reached1 = new ProgramCompare(); 7 z5 V* c: \7 z3 e8 E
                AuthorisedUsers reached2 = new AuthorisedUsers();        ' o- H. L9 e1 ^& r. J, T% O8 |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
4 Y7 z  Y' m' l                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ z* N) c" f7 V$ z5 I- i( _
        }! B/ Q* ~) k  ?5 R3 V
}// end of class ProgramCompareMenu
) {& t5 O9 B" I; O) J
+ C' S" O7 r( c/ a3 j. z5 b//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" \( l2 [2 v0 x+ [+ ^//          AuthorisedUsers.java          Provided by: DRS( x0 x9 _; X' B  S* N3 u
//                ( U: U3 ~: x0 {: @! w
//         Program shell for Assignment 2
" G- v1 x* L9 q3 y' C& }//
( S  T4 N' `6 M6 B- Q//         Represents facts about an AuthorisedUser
. @3 |/ o% X, d2 E) ~* w, d# H2 w//********************************************************************0 B) q6 l) w2 }$ C) [

  n- Q  ~+ O) L$ U8 S$ G9 G9 ppublic class AuthorisedUsers
3 \, f/ n+ r0 L    {
" l5 y( f8 C3 |' M; k3 Z& S* `
# E! q/ G8 Z& i; `) k& Q5 E        //-----------------------------------------------------------------
4 M$ J1 s5 Z! F# K% }* `        // Constructor
1 ?$ o, }/ i9 w0 C$ ~  u' Y        //-----------------------------------------------------------------! X$ ]( S/ O( f2 {2 S
" E# f. J; F9 P# k
        public AuthorisedUsers()
! H: A4 F, g3 e. W) |( Z                {: d5 j" L4 A5 o- \' d/ E8 {/ g
                }
$ O8 A! x5 N8 }  y. G
; G8 W/ s3 m# W+ b        //-----------------------------------------------------------------
, Z/ M( o/ |4 C6 a+ `  R        // Method for testing that class has been reached
! Y1 f/ E/ V- ~, D9 T1 ?7 q0 o        //-----------------------------------------------------------------        3 @, K0 c2 i+ W+ j$ x2 Y% Y
        public boolean AuthorisedUsersReached(). ~4 D! ?7 h7 W) ^& g
                {
  T8 r. I/ S6 N8 {$ Q3 W' P: W                        return true;                       
3 L8 ]' }/ V6 O( @8 K2 m                }* g8 o* u: y5 l' T$ n
               
4 I  T& q, g% p    } // end of class AuthorisedUsers
3 i0 g. E! ~7 ]& r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming6 ?7 A2 O' f2 A
Shanghai - 20071 ^' ]: |* A) n8 ]2 ^7 V
Assignment 2
' |1 F7 }4 ]3 r" D/ s" ^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)9 [" b4 I- q6 ?: n$ i- R
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.) d  ^9 Z9 E  m3 q
The staff must be able to:
( c% p; F, v4 F5 ]/ O Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.: S0 F1 b" r6 z) ]( ]  u
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.
3 n) A0 P2 e6 B2 a9 |6 w( c& F The interface should provide a menu so that the staff can:
7 Z& B0 K$ t1 |0 z# Aa) Enter the names of the two Java program files to be compared( G1 s& q- g1 w7 x% d
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.& i4 g, C% _& w! h2 q, M. }2 {
** 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).
' n% B( P7 O8 C- lBSA104 Business Programming – 2007: Assignment 2  ~! l8 t" P) W
Page 2 of 5
/ D0 [1 P: {, G; |' h- o. V. k/ U. sb) Print out to the screen all the lines of code that are the same% n  `9 a( j! U) s; m
 Include the name of the file and the line number of the code being printed for each of the two files- E0 Q3 e4 D9 S% ]. `3 `
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# y' Y* [! F9 g: S
 the name, username and department of the user2 P* \, V% O, G, Z5 l2 M4 A0 c
 the statistics of the comparison# s1 K/ @% Z2 i0 B. v0 S
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 q) `1 G/ g# @' j
 the recommendation for further checking2 s3 {4 p. X4 `  q- Y' T  l
- 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$ |8 \% Q) @) g7 @* y$ c6 D: B
 the names of the two files compared
7 s) Z8 M* x, bd) Leave the program (exit)
0 d* ~2 t# N& m; W, [The ProgramCompare class: (Total maximum 20 marks available)
+ I) I. b& c8 s* q9 N2. 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)8 L% o% A: E8 W3 ~3 ?
a) provide an error message if the files are not found or there is a problem opening them+ q8 u+ i% G5 S. x0 F
b) compare each line of code
* o  j+ }1 {3 K6 e& V6 v' y) r! [+ Zc) print out the lines that are the same6 A4 b& q3 D4 b1 H
d) count the number of lines compared / lines the same
3 E. s. i5 [  t) \The AuthorisedUsers class: (Total maximum 20 marks available); i) b# O3 V3 e6 ^' F) b  G! d
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)% i  [1 j+ O" \0 z, p1 g
4. Provide methods to:
4 {) }6 A1 y/ z4 Aa) 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# T( s' }% U+ Y) W
b) return the name of the authorised user% O4 U9 P* z, Z( {5 M
c) return the name of the department of the authorised user+ N9 U* W  W# p: a: \
Individual Data (Maximum 20 marks available)  e7 `, z8 y( {$ X2 V: I! c5 Q" u
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.
3 \- Q( ^+ e. n8 v. rDocumentation (Maximum 10 marks available)
, X" L9 x8 X4 i3 z6. 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." ?- U2 I9 ~9 d  n1 w
BSA104 Business Programming – 2007: Assignment 2
+ M; F* c( P9 z) b% ^- [4 GPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( {$ _& O& p; C* y. h1 \不过你要翻JAVA的类库说明。你有下载没有?* [$ K* |* y/ h) T! ?. e3 I& i" h2 c  v
查询关于对比的函数。貌似关键字是contrast,还有compare7 _3 d( v, s+ \$ A+ W0 e
, ~: F! b" w: r6 ~" J  W
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -$ G4 z' n3 Q. Z* ]& `" m% J
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' P- d0 g  B' x1 q可以下载到的 是 jdk-1_X_0-doc4 h; K8 T% E1 p$ i0 M: a3 j

% A2 _. _' D2 g; @+ y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-17 01:23

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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