找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1797|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 _; k; r0 P. `" C- ` + b/ @' n+ K# 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 | 显示全部楼层
//*********************************************************************0 G0 x5 a2 E  ]# P3 j
//  ProgramCompare.java         Provided by: DRS
+ I! f0 k$ g  I! b//. U1 T4 x/ k8 V4 S* W1 }
//  Program shell for Assignment 2- m% v. Y, g& O: N: w4 y7 E% M/ |
//& o. Y% ?8 q6 W, ?7 J/ u
//  Compares two text files line by line4 x) ^! K* r# l- \1 i
//*********************************************************************" ?6 @) `1 ]- y4 r
' K& t8 i: ?# h0 S( D2 Z# s" S
import java.io.*;; q2 ]# [5 y8 R9 _9 m& K1 |

  I' h/ ^) c! @' r4 K4 apublic class ProgramCompare
* v9 S( h8 {; p1 f- z{/ H" X/ e6 k6 m
        //-----------------------------------------------------------------; k! O/ J1 _8 s: P1 h" z2 j
        // Constructor
* g6 v; u* G4 h, C3 N        //-----------------------------------------------------------------
: b2 Y) m& M. J! p3 e- E0 m        public ProgramCompare()  g5 C' t! D9 ?
        {
7 H' v! |0 z. L* m' v: u. ^        }
' Z+ b9 l( M: v% X: S0 _7 X( ]$ F& ^
+ [' `+ C+ o' m8 E        //-----------------------------------------------------------------2 S! m/ Z) p. \/ O: x, o# I1 E. ?
        // Method for testing that class has been reached% X4 L+ M. d! i, i  r
        //-----------------------------------------------------------------        0 v! F2 _  L$ x2 {9 X8 |5 @

+ T7 R7 g3 h& e% @& }2 |        public boolean ProgramCompareReached()        
. w7 N- u! f8 a9 d, X        {: s5 L" q& c! e
      try # X. e5 E( ^- q  z
   {        
' z" e" _7 R5 [7 K                        ! u) ?/ E. O" W% C# a
                //********************************************************************* u% V; x" i# _) f
                // Try-Catch Statement is used to handle exceptions - such as file not found 3 M4 ^& a( a# Q" {1 X- w' p/ Z; T
                // Reading the files will need to be placed inside a Try-Catch - just like this one!% N* U& K& i8 d1 s
                // For more information see page 534 of the textbook
* i8 |* u1 v9 ?7 t2 |                //********************************************************************
; L7 s* g% ~% I5 q+ s# }; ?0 N                     # {! F/ t. U% O
        }
/ x7 ?+ p, R' @, F, V# @, J3 R             catch (Exception ex) // Exception caught here and message displayed to the screen
! U: a% R- s5 z7 D5 B6 ]$ `          {
( k8 C& [7 I. U& B0 ?" O- X2 B. ~                    ex.printStackTrace (System.err);
  M' u0 v' T7 T0 N( ~5 b           System.out.println ("Error message goes here"); // Replace this error message with your own          * w9 C( C3 C9 h. d3 ]! b6 w
        }
# p! m4 T/ {; o* H                return true;
+ K5 Z  \8 F  x. d3 ]        }, i6 u3 ]5 B6 L+ T3 a

" z# K5 {+ s. ^/ y" z" j: h' u} // end of class ProgramCompare. T7 G: F, A* M3 a7 e
2 Q. D" L  |) y- a2 `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
; q0 G, Z/ X1 w  ?: l# S, \4 m//  ProgramCompareMenu.java    Provided by: DRS
4 I6 i" m' G( T8 j- \- x0 M7 d3 S//) Z! ]& n( K0 c- F8 P
//  Calls AuthorisedUsers.java and ProgramCompare.java: N! z; ?! K9 c# G$ ]8 v
//8 t$ N5 L6 ^4 @/ m
//  Driver shell for Assignment 2.# r4 E( b6 s$ }9 U) N
//********************************************************************8 p$ |3 H& \$ _& n

4 ]9 ^. o9 B! B% L- c+ B5 B* \8 Wclass ProgramCompareMenu
% l3 B: G" e5 m5 i{" `) V2 T4 U8 I5 v
    public static void main (String[] args)2 t0 s* q/ x- Q( s. e6 y
            {8 _! e( N$ p, {9 m
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable/ h2 [2 {4 Z, N8 w4 s1 [
                ProgramCompare reached1 = new ProgramCompare(); , [  O( ?( S, H! B
                AuthorisedUsers reached2 = new AuthorisedUsers();       
. k5 a7 ~3 N. r7 L5 x( o6 P5 t                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());% j+ Y3 a2 W4 o# B- K  \( t
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        % G! K2 h9 I) C: r/ m6 A+ Z
        }
% r* H% R: L4 \3 C! t6 J4 o2 T. f! ?}// end of class ProgramCompareMenu" x1 I9 g3 D. g7 F" E/ _' v

3 o9 C% h* _4 ]6 _3 v' `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  ~& K8 {3 n& {1 S* ~& k2 p$ |//          AuthorisedUsers.java          Provided by: DRS9 [* z; r3 A- Q, V  G7 @
//               
: Q& A9 {) S2 N' i& m" {4 b//         Program shell for Assignment 2* z2 v4 y( m- T1 T# }. |
//
2 B$ M# B  @8 @! D//         Represents facts about an AuthorisedUser
. S- H& [2 `( T0 U% n; A3 Y//********************************************************************
% H7 D7 O# @- C$ X8 k! F: i2 W; b9 m5 E. ]( T6 @- x* I
public class AuthorisedUsers; N& H/ Q5 D# V. R) S
    {
. ?1 p: q. E  d2 }* C4 {  F* |% N! B7 G
        //-----------------------------------------------------------------
9 z& D2 M6 a% f+ E" g5 n2 k( N        // Constructor
' j. R& P8 b( q8 k1 r# s# k2 O0 A5 v        //-----------------------------------------------------------------: E# j6 ~: C5 A4 ?; P% X/ e' i3 P- ^
! O( X: `7 {; ]! w1 p6 t
        public AuthorisedUsers()
& ]! n' J( u! H& |8 F" p1 k                {
. U! B7 H( f3 K                }( f8 W8 F4 t# e: E7 S' y

- b" B2 J# a0 }- L, B* r0 q' h1 D* H, i        //-----------------------------------------------------------------; `' j7 `0 S) Q& x4 h0 i2 q
        // Method for testing that class has been reached
0 m' Q( R" |1 D" M, ^4 r0 T        //-----------------------------------------------------------------        ! i  a# ?% j$ @& O
        public boolean AuthorisedUsersReached()
8 t1 f! p: f7 U) D                {
8 }5 E/ }" i9 i. r2 R                        return true;                        0 n" ?( q' J0 T
                }
" {4 w6 r% m6 t                " F% C( C3 A: g5 H$ i! `) o
    } // end of class AuthorisedUsers
: e* B% ?( |) L! _8 f5 S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, M0 v% ?% G; l1 c9 @; x! l1 j
Shanghai - 2007' ]) a, k  t/ L4 [3 v8 M7 L
Assignment 2
1 z3 Q) \& o& m5 wDeadline 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)
2 K% M2 N$ P) R! G$ Z, S1 k1. 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.
5 T3 m# }  l2 m! d; Y, }! GThe staff must be able to:
' Y: {! B( R; q  a+ o Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
$ E+ A4 s0 f4 y8 n$ Z6 q8 H# Z1. 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.7 C+ r% M4 F% r9 Q
 The interface should provide a menu so that the staff can:
: O3 E% g/ d2 s* T# P( ~a) Enter the names of the two Java program files to be compared( B0 e4 h' q# |/ G3 |; ~
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.. T/ z, L- n2 l2 j
** 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).' x* J- N  g7 N- p6 f
BSA104 Business Programming – 2007: Assignment 2
* T  q) ^; u$ O* k) b2 n3 CPage 2 of 51 o8 V' s" B" k# L$ I
b) Print out to the screen all the lines of code that are the same
" {% V* o" Y0 O( t* J* N: T Include the name of the file and the line number of the code being printed for each of the two files7 g& Q5 `: [: F3 ]) ]) \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" k& P9 w- E0 q( W( X9 d
 the name, username and department of the user
# u& h" B2 C+ l8 _. ?( m the statistics of the comparison
( j: A5 l/ e+ d' ~- c- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
$ K6 U0 R$ w" h1 {. N3 B. P the recommendation for further checking
+ Y" \: y- }, w& v  G  @+ B- 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 closely0 I2 \' o( M; b4 i& J  H' W8 }2 S
 the names of the two files compared4 n" e+ K6 i9 d/ |9 k$ N2 ]
d) Leave the program (exit)! N6 b- S" [' q3 A' A
The ProgramCompare class: (Total maximum 20 marks available)
" }# Y( s' i$ I$ w2. 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). O  ?# H' z1 d3 \
a) provide an error message if the files are not found or there is a problem opening them
# B8 r& l" i; n! d  r; S: ?# cb) compare each line of code
. g2 v7 ^  ]% ]" zc) print out the lines that are the same
6 D4 ?* m  o! D" _0 [7 {d) count the number of lines compared / lines the same
: g  F/ T8 B- Y! \; `% y6 a) AThe AuthorisedUsers class: (Total maximum 20 marks available)
# _' |8 i* }) t3. 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)
9 _4 ^8 z$ @1 i) j) V4. Provide methods to:! u0 C# m& f5 M$ N  e
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 match6 B, x0 x. ]! O2 h1 w
b) return the name of the authorised user
/ U# T( o2 y  c8 Qc) return the name of the department of the authorised user
6 D- m' E( U, Y& fIndividual Data (Maximum 20 marks available)
7 n( f2 |# P5 F8 n$ `" h5 S" o; s5. 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 a- f+ g: I. t3 I7 T  ^Documentation (Maximum 10 marks available)( S+ {1 Y6 D* a9 Z; D8 X, u/ b
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.* n5 ]) T9 X7 e8 l; y
BSA104 Business Programming – 2007: Assignment 2
7 l0 G8 k& k, {Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" U2 X  v8 e* ?3 a5 E; l
不过你要翻JAVA的类库说明。你有下载没有?0 `' c3 K; |0 Y
查询关于对比的函数。貌似关键字是contrast,还有compare
7 n7 A# ^  ^  z4 \
0 P( W& k' L$ {, p& d; O[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 ]$ L6 {# X; \% o& M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! t/ B. S. z4 Y0 v9 ^; q
可以下载到的 是 jdk-1_X_0-doc
; K% Y# U1 f+ ?0 Z' G5 N. Q, w
1 x, k0 h6 A; O8 i3 Z! s3 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-3 23:51

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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