找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1808|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 M6 A# N: T! z) x0 O 5 @ P) E' z* z9 L) N+ Q
回复

使用道具 举报

 楼主| 发表于 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 Q7 R# P/ x" k8 C# g
//  ProgramCompare.java         Provided by: DRS+ F. U$ G1 e$ S% |
//! Y0 {) M2 m0 S5 ^
//  Program shell for Assignment 2
& p0 Z- p9 c: I- G1 G. Y$ `- H//. ~3 ?+ {' G: L( `  t
//  Compares two text files line by line
4 S( w. Q! n; g//*********************************************************************2 t" a0 |; ^: }% w- ]8 K& {3 x3 h
2 M! B' a5 N3 k
import java.io.*;
3 ~; k  E# W3 v( E2 B
! I8 y1 l# e; d/ A! }9 h+ h0 v1 [8 |. N' |public class ProgramCompare. z# v1 B1 B: P
{1 D8 @* E1 m# k; m
        //-----------------------------------------------------------------
( i& D8 l. L) ]3 `* f7 G1 S        // Constructor
& O+ F" O6 n& G% z" l- G        //-----------------------------------------------------------------
/ ^% h* n, b3 ^& P        public ProgramCompare()
" h) _! ~1 ?2 B2 @+ A        {
* j' c  O( Q) H5 [4 G5 K        }2 n  _2 c6 ~- o9 Y) z. ]) O

- ^5 g/ w, z# N5 b# \( ~        //-----------------------------------------------------------------$ ?, z" Z; L, {+ L
        // Method for testing that class has been reached
. I) N8 w, t1 m        //-----------------------------------------------------------------        # o+ T& U2 W4 f

  d5 S9 J+ n0 }' W$ ?) \8 E) f, W        public boolean ProgramCompareReached()        
8 \6 j% J3 u7 o        {
4 M% ?2 A- U# `0 S# o      try
' d8 h; ~7 @% g+ O  G   {        
( E" {) D* |0 t                        2 N! Y: K: D+ P
                //********************************************************************- o( ?8 f7 s/ I$ G- x" k9 m
                // Try-Catch Statement is used to handle exceptions - such as file not found
! h' O$ d% s1 h4 P! v% q+ Q                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. @  ^; T/ G! V                // For more information see page 534 of the textbook5 K4 S' V9 _; @0 ^+ t! X
                //********************************************************************& ~7 k, O2 l$ C: G% |' u
                     4 W* ^+ f9 @: W4 ~
        }9 J1 ?- x/ [- I) n
             catch (Exception ex) // Exception caught here and message displayed to the screen   d8 b# `( H3 o" w9 x
          {
* Z6 |3 l* C7 o' n% j- b                    ex.printStackTrace (System.err);% P2 y& t: z5 f5 a
           System.out.println ("Error message goes here"); // Replace this error message with your own         
: j$ ?% Y1 |' N8 V        }) |, _* \5 P" i* j0 r5 n8 }& Y' _
                return true;% E- r$ U5 O1 X  k
        }/ e# A  `8 r1 ~8 z  T& f
9 R& S8 ?+ e2 b' ~, H0 I. e
} // end of class ProgramCompare% {# D- o. m  U7 j- Y
/ i5 l9 |3 @$ k/ E  @' W  z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; z( n$ o+ g4 X" J+ a" x! |* |
//  ProgramCompareMenu.java    Provided by: DRS# m( E7 Y6 F0 e& i( d8 }4 h# v
//, Q/ U1 _4 b% \4 Q; E
//  Calls AuthorisedUsers.java and ProgramCompare.java
, {' s# A) }- h+ C. L//1 R3 b& H8 A6 ]* n; L
//  Driver shell for Assignment 2.
+ u8 D+ a/ x* H  i//********************************************************************
' K. b- a) X. \: }
6 w# O1 {4 ^% t6 z7 |7 R, _9 bclass ProgramCompareMenu  d1 q# _# d) b: a# [
{
# I9 h% ]" p, U9 M! S" w: e+ @    public static void main (String[] args)
7 }4 }+ p8 j7 |9 O            {) `0 B2 P1 w" B& d2 S
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 {/ H9 j9 X3 _# X
                ProgramCompare reached1 = new ProgramCompare(); ' [! }. L2 n$ M) ^$ Q( m$ W$ u8 }+ y
                AuthorisedUsers reached2 = new AuthorisedUsers();        : b2 X+ G% K8 O. q; v! ^9 Z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. F) ^3 x( R' T( H4 l
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * k% U8 J; L# }
        }# L; Z' m8 F5 K' g; ?' f- E
}// end of class ProgramCompareMenu
6 d$ G, c+ g+ H8 H4 d+ m, `' _0 U4 {9 F8 Y* P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  I) E  @6 x9 b$ @5 T) G% n  |//          AuthorisedUsers.java          Provided by: DRS; ?  H8 i9 P9 ~* e
//               
0 w% {" q- M$ V! v, E//         Program shell for Assignment 2  q9 X  f& f9 W: Q1 i# v/ ^% T
//
! i+ a$ e# ~/ v$ g//         Represents facts about an AuthorisedUser2 g! R  b- b' f3 D
//********************************************************************3 f3 f: T3 w+ E' t
( O( L4 I% a4 O" z/ [
public class AuthorisedUsers0 W6 _" `; A9 D" {- k% t+ z- m
    {9 w! T. _; S7 X0 N" O
! l! ?- o% {/ M2 z+ L# S
        //-----------------------------------------------------------------' ?5 O$ J5 N( q' x+ w0 [/ L. ~
        // Constructor' p2 I5 b7 f/ {: L/ P9 P4 q
        //-----------------------------------------------------------------: N" @) d) o7 f+ G8 O1 y
4 N& E6 w# b) I
        public AuthorisedUsers(), y1 B6 r/ D, \' T& p# |
                {
# ?* q6 o. {1 n+ e4 J! H6 Y+ Y9 H                }
( d* L, r! v( r* V0 {* U0 x2 ^9 D) w% A$ }) U
        //-----------------------------------------------------------------  l, ^$ d+ r/ ]& P: \
        // Method for testing that class has been reached
; }. c. ?8 n  N' z4 D) D        //-----------------------------------------------------------------        ) h/ z7 l6 ~1 ]! N. {" ?5 Z
        public boolean AuthorisedUsersReached()
* r2 K3 ]& q) K1 W! F                {) T) Z9 D/ U3 \" u( s
                        return true;                        ; B& m% S, W8 _5 A; K9 V+ Q
                }
/ I7 E# r3 m! Q$ g4 O4 v. p               
+ r% u$ N& k9 r9 x# g- m    } // end of class AuthorisedUsers, |" y4 s  o' D6 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 ^" Y  V( ]1 p7 |- G; fShanghai - 2007; ^5 h2 p/ a, |5 r3 F" }
Assignment 2
5 v/ B. x9 @; G) x4 _  ^  i8 ODeadline 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)
) ]& O9 O( d0 D6 `& X7 m1. 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 o( [1 E, {! j" g8 tThe staff must be able to:) @3 a% \  X% K  I/ U: h/ {
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% d6 `  G$ x# H  ^- o& J, e
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.
9 y+ n% t3 N  I, W# A. S The interface should provide a menu so that the staff can:: P, l% d4 y. W6 ]! D7 W( k
a) Enter the names of the two Java program files to be compared: `# T, J! [! i3 _- N
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 C7 P; g, H1 t# I** 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).: b9 l, A' F, V1 \
BSA104 Business Programming – 2007: Assignment 2
% P, C0 W$ b6 r$ v6 P2 S' |- s$ j- TPage 2 of 5
" S% B8 d9 c1 u' k1 M& ^* d2 Xb) Print out to the screen all the lines of code that are the same! \# R1 \- i. N5 M" ~
 Include the name of the file and the line number of the code being printed for each of the two files
$ ^! q6 G! s. D; xc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: Y+ B- i6 ~5 M2 e the name, username and department of the user; z& Z' P2 p# p4 E' Q
 the statistics of the comparison
$ ?) ?9 ^0 L( y. }1 w0 O- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 `$ z) y2 j3 I5 x
 the recommendation for further checking( u: `1 V% [+ @' V* 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
- S) n' P& g8 Y' i the names of the two files compared. c4 l/ S6 h7 l* z8 W; i0 z" E
d) Leave the program (exit)' J5 ?% [- [8 p3 Z) N
The ProgramCompare class: (Total maximum 20 marks available)
) l5 A" d" A2 r. q) `% V% |8 p2. 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)
0 G- Q- V% N7 @0 K% ]" ~; v. w* va) provide an error message if the files are not found or there is a problem opening them% `  m3 r8 [& o* P6 Q1 j; V  e
b) compare each line of code8 a, `) d  \. c/ u( b& s
c) print out the lines that are the same
: z4 P. k: |1 Bd) count the number of lines compared / lines the same% C9 }2 b7 E8 d" m8 w$ t0 x3 T  m
The AuthorisedUsers class: (Total maximum 20 marks available)! k! [3 `* U5 \& b
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)
5 \/ Q/ ?  f" h) T+ O7 _% }4. Provide methods to:
5 C) |/ k: l9 ]* z, 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 match6 w6 E: D0 O. P6 u% z
b) return the name of the authorised user4 q* x5 x0 X8 x6 x; e
c) return the name of the department of the authorised user. ~& x% l( f5 B$ m  R
Individual Data (Maximum 20 marks available)
* W" o! J' b" q8 a9 k. o4 K" N5. 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.
  [% C0 o3 x6 P. @9 `2 VDocumentation (Maximum 10 marks available)
% Z( X3 @* H7 M" ^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.. D" f) s4 P2 L
BSA104 Business Programming – 2007: Assignment 2
& u  \- P' k& K/ N  D9 l! {/ a) sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 J' h4 \( f/ w) u& }6 S1 s不过你要翻JAVA的类库说明。你有下载没有?: Z1 q! s- R5 B' [% B) U0 F
查询关于对比的函数。貌似关键字是contrast,还有compare
- _$ P* t& f( S; l& L
6 a8 Z5 {: T& d1 B1 ^5 }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 x) v6 s+ T& ^: R( |! R痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ H% T/ D  T, z6 C/ f8 L可以下载到的 是 jdk-1_X_0-doc
4 B# J/ S0 b( b' a$ F  U2 W# f. P: |: I4 Y* H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-9 07:10

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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