找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1677|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急1 Y3 \7 ?' y' d! s' y. G 9 v! n' P% E6 P5 n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 U- A2 e* ^( _8 |0 O: _
//  ProgramCompare.java         Provided by: DRS
% }6 K* k9 `5 q8 C+ i! b/// G9 R4 |# i2 f6 u& I; l+ O
//  Program shell for Assignment 27 W( z' P9 c" m7 r: M3 P
//
8 G8 i5 a, x7 y8 f! k//  Compares two text files line by line6 B) ]8 @5 U, n& I: a
//*********************************************************************/ S2 h! ]( }' D( D' E
, J0 l* }/ \6 v/ Y7 a+ e  P8 S/ h
import java.io.*;
4 H1 Y3 @# E! X5 A# w) j0 \- ]& C9 _2 j+ Y
public class ProgramCompare
3 v+ k- G+ a5 I8 Y{
0 x2 `1 o* \/ k6 Q$ o9 U        //-----------------------------------------------------------------2 p# }5 l% g8 X; L, s
        // Constructor
" d. `# |) b7 k8 d        //-----------------------------------------------------------------
9 R$ j' n) s( S2 W( ~( O4 J        public ProgramCompare()
1 o& _9 t  c+ z- U* n6 A* A( X        {/ ]& r( V4 l: l# [5 }. s
        }
, ]$ G* m+ `6 C6 F* ]" C$ e! z2 F
* h0 @9 f& ~# w/ ?: I4 S8 I        //-----------------------------------------------------------------
5 W. a; c& C) A! T1 h' F        // Method for testing that class has been reached
/ Q1 ~/ u9 G2 A4 c        //-----------------------------------------------------------------        / ^5 U' I  I4 d7 e; p2 p% p

8 I3 E( a* g# G: S        public boolean ProgramCompareReached()        
; d, Z* b; X$ U: x/ l; |; {        {
' P* E& d- y/ I      try
) I' T2 X$ o: A( n6 b) b   {         2 U7 E( N# A4 I" v" _
                        * A( H. C/ s8 }, }2 h0 U, }
                //********************************************************************2 e, _% Q6 x4 w* _2 w
                // Try-Catch Statement is used to handle exceptions - such as file not found
: R+ r7 l! N4 O: `                // Reading the files will need to be placed inside a Try-Catch - just like this one!8 i2 P" c8 T' u3 K  ^* H
                // For more information see page 534 of the textbook8 ]" p' B5 U  _7 S# r1 x
                //********************************************************************
- i6 p- }" h/ W                    
2 E6 i* E- P$ P8 ?. V7 O' l) u$ o" Q        }8 a& X- }# X! Z+ b& C$ x7 S/ }4 Y  b
             catch (Exception ex) // Exception caught here and message displayed to the screen
3 R& m3 d5 [( p/ @          {# {+ n6 N5 l4 ]3 v4 N& N) v4 E
                    ex.printStackTrace (System.err);! Q( V7 G8 I9 M: c  }1 n
           System.out.println ("Error message goes here"); // Replace this error message with your own          % s7 ?/ e+ j7 c0 u6 ]9 l
        }8 K1 ]& k$ F, o& D6 L* b- F4 m
                return true;
# E* q6 ~* v5 [9 ]' Y        }
- I( c+ p2 h( ]: X2 E$ U, y& ~; S: M
} // end of class ProgramCompare
. N# S' }* ^3 F$ u# J; c5 `7 T
  f6 A1 ~' f& r% A1 c, s+ s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# O, J& h4 J( m* r* b8 p
//  ProgramCompareMenu.java    Provided by: DRS
7 z- p- g$ l+ l, n//: q  \! ]3 x* Z1 k" |' Z% E, C/ x
//  Calls AuthorisedUsers.java and ProgramCompare.java" p" l6 y+ V' k, u
//
5 W* O, {- P) Y" L4 Z$ C//  Driver shell for Assignment 2.
  }" u( u0 }7 [! E- Y$ `//********************************************************************
. M6 L2 j1 N3 G/ W8 K+ |" w  m: h; y7 h% F3 K9 i! S
class ProgramCompareMenu: H# }8 y; y) D% P+ v0 Z9 s- S* n
{$ G4 m( Y! m$ g( N. N, Q# e& |
    public static void main (String[] args)% f. s( g( l2 `6 S: @
            {
4 t+ e7 A) F. o1 o8 @8 ]: [% E                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 g3 X, w) Y! S) U) V# V
                ProgramCompare reached1 = new ProgramCompare(); . J3 k& j! X) W% c; ~
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 y# U  p# |* G4 S$ ?, @( V# l0 J) D                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 U) z0 z6 q  i0 j                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# U0 |4 I) K8 o4 H' b        }
1 |- V9 J0 T1 K  f}// end of class ProgramCompareMenu
: H! C; _$ G- d$ i  T# `/ X
. _$ i+ t9 C# J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# M, o5 u) X2 Q5 `//          AuthorisedUsers.java          Provided by: DRS2 r2 L. \- F, l5 D/ i( d
//               
4 O% a1 W3 S% U, n//         Program shell for Assignment 2
1 o" g4 y- x/ B8 H8 a( ~) K5 J//- s' \. |' K9 v2 L4 T
//         Represents facts about an AuthorisedUser
8 O7 R  c! R5 b" r! S5 z# {& \1 A6 L//********************************************************************0 G; b+ o" R* K! a

6 P) y7 x* F) _9 N  qpublic class AuthorisedUsers4 i1 Y/ m+ C& S, P! y$ ?
    {
5 [6 `! f* E8 \9 \* z" C4 _
- L: A- J% T* u0 \3 D) {' U        //-----------------------------------------------------------------; d$ z9 u. i( B, h5 s' E
        // Constructor
+ o% _4 K/ Z2 m        //-----------------------------------------------------------------
8 u3 A" Q. z: L1 B5 c5 M" O
& e3 W9 E% }3 a" X. i  F5 l        public AuthorisedUsers()/ R) E* i  }7 D
                {
6 `; Z: j% w+ d! }% N" r                }
3 E0 s1 @. v  o. \3 X0 A4 n+ {3 @
1 o  K2 ^8 {1 k4 Y2 y& f+ G2 [        //-----------------------------------------------------------------
+ ?7 n: y% ~4 x9 h: N7 k        // Method for testing that class has been reached
* J0 u% l) I4 z  X2 j$ }* }/ a        //-----------------------------------------------------------------        ; n' s2 W/ }8 Z
        public boolean AuthorisedUsersReached()
; o1 z' x. P, O: \- v8 u% o- r- A                {
' f: G0 [* r% I  p( k' h                        return true;                        + h" i% \6 t! }8 l
                }
  I- |# J' ]; |. c" [$ v0 H                6 s0 |( G" O0 q8 k
    } // end of class AuthorisedUsers& h, w3 S( j# ^& B, G  N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 [  [2 C& ^7 R2 _( N9 [+ @. b9 |. e3 p
Shanghai - 2007
+ N) v3 A0 T# J* D! c! N. ?; FAssignment 2
' R) b; v7 H2 r' |- Y$ i. h4 cDeadline 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)& [, j# c. c; I$ x" ^
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.5 d* f) ?# D) ?: ]1 _
The staff must be able to:. i, F' V$ N: C! G
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ L: L# b* ?7 V7 G
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.
6 P8 R& x5 l& @5 C The interface should provide a menu so that the staff can:
7 J  r7 ?8 ~( F" w3 ?& Q0 ^- x- ba) Enter the names of the two Java program files to be compared
9 e/ [' n* ?$ r2 ~ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( l$ |5 G3 j6 G1 ^& M9 N; K' ?** 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).
2 F; _4 I6 M/ a" V  a+ tBSA104 Business Programming – 2007: Assignment 23 W& o. h& Z5 w2 S! ^% f
Page 2 of 50 `; n1 v2 K) O; Q$ R
b) Print out to the screen all the lines of code that are the same5 q; [# Z6 Z, Y
 Include the name of the file and the line number of the code being printed for each of the two files
. ~3 S* t& c: \4 uc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 |" q0 o& y$ ~ the name, username and department of the user
6 Y; q/ M  w, {" V( i0 f9 w* J the statistics of the comparison; A( J6 M9 ?8 |" z4 ]
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: G& ~# }# ]( M, B! s4 T: @4 s  K; Z! {
 the recommendation for further checking
# w- V$ c2 i! d# y% g- 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 }3 _% v$ V6 C8 p3 O* x
 the names of the two files compared
- G  V9 c1 V" h3 X1 ?* ^, kd) Leave the program (exit)
. [6 H2 n, e0 L  ]The ProgramCompare class: (Total maximum 20 marks available)# A- O, P. d# n
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)
; A, d" h* I& ^* p6 Ua) provide an error message if the files are not found or there is a problem opening them
1 g8 v' C" U% S) ?2 _( f6 X1 P% xb) compare each line of code8 }- W& t! a+ }0 t
c) print out the lines that are the same
7 F- c8 K: t% Z+ u) v5 B' Id) count the number of lines compared / lines the same
: B$ I# f5 M0 C- K+ q+ ^The AuthorisedUsers class: (Total maximum 20 marks available)
/ j8 _" q( e+ [7 x7 ]! v3. 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)7 X0 W3 o4 W. G$ S. k+ X  ?
4. Provide methods to:
5 d. V$ i- w* K, La) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match7 A, I: f8 x, s7 J% x  g
b) return the name of the authorised user: D  J. S5 l  g. S0 O9 K8 d
c) return the name of the department of the authorised user. L5 o+ j! a$ k; a4 E
Individual Data (Maximum 20 marks available)
; {( N* q' y) w8 L! {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.
% D- t1 ?; n- w, p) f3 lDocumentation (Maximum 10 marks available)7 Q2 H$ r! q  U6 w7 Z5 b. w
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.
/ S/ Z! C: [4 h  l" b/ y/ ~BSA104 Business Programming – 2007: Assignment 2- E$ U' {+ C/ d- t: @  n
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ M1 t" ?# H, |; o& |4 T
不过你要翻JAVA的类库说明。你有下载没有?
1 r8 J8 |8 z* b# Z6 P: k! ]查询关于对比的函数。貌似关键字是contrast,还有compare
! S$ D3 f, k# e$ [( b" {7 i
* Y9 X- e: _( q0 q0 Q# h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -8 h" L+ ^: r6 k' `
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 s* G3 _8 {% ?4 X* E8 u可以下载到的 是 jdk-1_X_0-doc
5 K+ W7 @4 B1 ^, n; ?1 v' J; p' s: K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-27 18:51

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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