找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1318|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急( G7 |% ~% f* q7 s9 r ; m( S5 A1 `0 w) \+ I. \7 r/ U H
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- C3 E8 s3 \; c8 ^. E//  ProgramCompare.java         Provided by: DRS4 ]: i8 M/ f9 i* c: S3 m( c! k0 {" S
//2 j, C' v6 F/ }  J7 \
//  Program shell for Assignment 2
: `2 W6 q/ @( X" G: \//; I& w/ X! w! ~7 k, f
//  Compares two text files line by line
  S' N4 e# i2 x, a//*********************************************************************4 o# c2 \; a) Z  Y2 }. N1 L

; L% l, l& Y+ o! V. s2 c  _import java.io.*;
- o6 Y3 x) D0 X; b( e" e: J( r
, o  w( H2 |& O. j/ Xpublic class ProgramCompare
6 n; ~* x3 }* p{
( J# l) W1 b# ?7 f$ N/ Q. ^        //-----------------------------------------------------------------
( f; P/ a, h" C8 G8 c        // Constructor
5 W. H( P' I5 T        //-----------------------------------------------------------------4 a! q+ M1 x# Y
        public ProgramCompare()
+ i9 T( E: N+ w( H2 T3 l% ]        {, v# _7 b/ r. d- Y5 w
        }
5 n( [/ p0 h8 L, k& D/ d- P2 G
7 |3 P+ M! K7 G" Q        //-----------------------------------------------------------------
3 A6 Y" |+ E& J4 H        // Method for testing that class has been reached8 c* q; b8 V( d& d
        //-----------------------------------------------------------------       
( n/ s! l" g0 C" R' d' @5 d, Z8 N2 e
* u" C; C2 q2 J* A1 J; P0 M        public boolean ProgramCompareReached()        
4 V! |8 G) g- _        {
2 f% ^) M! E& \2 T# m1 D) {      try
# ~7 \5 Q* [6 S6 q1 y   {        
$ K+ K& R, `# U: E8 r                       
4 V. s( U/ E9 E) _8 p) k" L$ _$ `' `                //********************************************************************8 e- r/ Y5 V  x1 y. W6 r
                // Try-Catch Statement is used to handle exceptions - such as file not found
( c/ r6 r+ N6 R2 g! W7 p                // Reading the files will need to be placed inside a Try-Catch - just like this one!
' W2 q' b; E4 G: L                // For more information see page 534 of the textbook
, ?7 m) Y, C) U, ]                //********************************************************************
6 g( N$ N6 ?! I( l, |                       h2 k! s. r- [
        }
! e8 r+ f# k$ Z% K" y+ u0 U             catch (Exception ex) // Exception caught here and message displayed to the screen
( I1 D3 @- ^0 h1 R( j          {
( }: O! V; A2 k. L                    ex.printStackTrace (System.err);
" ?: R' ?. r# Z: p0 S" R           System.out.println ("Error message goes here"); // Replace this error message with your own         
! j" \! |8 m/ R1 Y        }/ g/ s4 x4 f8 ~+ \- M, j/ v
                return true;9 E* X6 g1 H. Q& s
        }
% h/ J' U) G6 w. Q/ d: }) s6 L$ X! V- ^
} // end of class ProgramCompare
, M; Y3 M4 O8 |3 R1 \5 E  t
; s7 I* c; |3 D/ a/ X' P3 a; D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 F! f0 R( e' I# i& r
//  ProgramCompareMenu.java    Provided by: DRS
0 k4 `" P: @* a, n  \% ^- [//8 Q/ V  x1 P4 r4 q3 ^& K. f
//  Calls AuthorisedUsers.java and ProgramCompare.java
  \( U  f7 P# i& ^//: K+ g6 ?2 ?6 [2 C
//  Driver shell for Assignment 2.* g* G2 D3 O5 X8 B0 T$ N# I' l. e
//********************************************************************# m' ^4 U/ d% @9 g

& G3 z2 d1 ^$ r- w' k8 Yclass ProgramCompareMenu
' _- p' D# v; j! X{
8 O7 S! m- ]& [6 |    public static void main (String[] args)
" i5 r) y* I  b; L! n) X            {
, y* s2 i& B) B, F                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
1 u- J% `$ ^5 B, I                ProgramCompare reached1 = new ProgramCompare();
6 y: M: P5 M' G# ]# o                AuthorisedUsers reached2 = new AuthorisedUsers();       
  t, S& H. x3 Q7 O6 b+ U& m                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());+ k; W$ k7 m. j. X* Y' B/ [) e; L5 p
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ! F( {4 L5 U' U4 k) @: Q
        }! H! y; \6 o3 O1 G
}// end of class ProgramCompareMenu, U& s2 `5 i  c# T

' S3 |3 n- [! {, ~( H5 V, s! I$ T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) q; Q+ s9 C! z3 p2 ^
//          AuthorisedUsers.java          Provided by: DRS2 k: g% h8 R8 {( v  P
//               
+ r# S+ D  F$ ^4 ]5 U//         Program shell for Assignment 2: t: }  X. [# M! m  d; \
//
6 J' R/ r1 z, E2 ~3 z; e" `//         Represents facts about an AuthorisedUser; ?6 ]3 U& d" t  m
//********************************************************************, s$ Y8 T# w2 h

5 k. G. J- |0 @- A9 \public class AuthorisedUsers
% s0 {8 B2 \3 l( I- s    {3 f% b1 K9 P& N% G8 T8 g
: k& n! |6 {9 o, f# @4 C  v  [
        //-----------------------------------------------------------------: u/ Z- I5 x4 P  p. _4 K5 s  O7 K
        // Constructor) y# r! X2 o. e9 d5 [
        //-----------------------------------------------------------------. |4 [: B0 m$ y* K: `& L" S4 O
1 R/ X0 `/ H' G3 `! K: O+ R# Y. N
        public AuthorisedUsers()
3 m) x2 [. t& B! a                {
9 H3 D; G( y" n4 @; w0 e  H                }
4 W& @( l& k: d  ^2 p: Z
' C/ S0 o% }, z& U9 N0 E! j6 O        //-----------------------------------------------------------------
7 [4 t; b1 F" ~0 c4 k4 ]        // Method for testing that class has been reached
4 [7 u% S9 D' b. o( r! s- |        //-----------------------------------------------------------------        / ^! H9 j' N! ]+ j
        public boolean AuthorisedUsersReached()
7 N5 U6 c5 ~6 R' w: A& _- `                {
( O8 N& j; L, H                        return true;                       
+ g( s% ]9 A6 p  \( B$ a                }
/ J# G/ ^) J) P$ t2 L0 m. m1 @1 t               
; q) E6 M: B- E7 c    } // end of class AuthorisedUsers
5 h$ @$ {( Z' x: E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
- Z: z5 D1 X( ?Shanghai - 2007
* L4 }4 M. U) c; y8 X1 HAssignment 2
$ b* m* d5 f6 F% MDeadline 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)7 r0 p+ J+ a0 e0 ~7 V9 q
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.4 G: b+ o+ k& e* N$ G/ N
The staff must be able to:
2 d3 }% _: ^7 d6 k9 P& ~$ k' z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
8 x0 t4 ^+ \8 N  c" w1. 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 v+ _. p* _. h6 V! W6 z6 Z
 The interface should provide a menu so that the staff can:. w& j! F; `6 \- l1 s/ E& \2 h1 M1 Z
a) Enter the names of the two Java program files to be compared
0 t, P6 }1 A1 G- P- e For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ G0 V; o6 C- r** 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).
( I4 U, O( L. M# W' FBSA104 Business Programming – 2007: Assignment 2( \1 Z) ^  b9 j4 i
Page 2 of 5
1 q7 g. {! t7 A; i# ]3 Zb) Print out to the screen all the lines of code that are the same
: X% t; d. Z  D/ U! M5 R Include the name of the file and the line number of the code being printed for each of the two files7 i3 V+ D/ s6 Y1 U
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 p, O4 a& K% B( P& G
 the name, username and department of the user
4 Z+ y7 B' h+ ] the statistics of the comparison
! O' d8 `+ {. B/ [6 ]; a3 q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 c* y  V1 L+ W# a6 G% ]
 the recommendation for further checking/ v( J& p8 G# K. i# I( M9 G2 J
- 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
0 [2 e# G" z: }5 h' Z the names of the two files compared
& L1 {2 u. b4 ?# Q4 e, T* Md) Leave the program (exit)
# t/ ?, `$ r% @% I9 d' @The ProgramCompare class: (Total maximum 20 marks available): n" [8 K8 \' s# s% ?2 B) s2 a
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)) c, k+ d8 X4 [  n: A! V
a) provide an error message if the files are not found or there is a problem opening them0 A/ p$ ~$ {, n* f4 B  n
b) compare each line of code
2 P0 p  W( C$ B% ~, M* @c) print out the lines that are the same
2 [' t% Y- q2 A/ \5 K$ ]d) count the number of lines compared / lines the same7 o% Y0 S" ?+ f( R
The AuthorisedUsers class: (Total maximum 20 marks available)
- x; T; R( P: d1 Y: p# }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)) T. P7 N5 X- r
4. Provide methods to:' z+ r9 F! V) P& @; Z# F5 ~
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 match. n& {, z% ]( G
b) return the name of the authorised user9 K2 h) S3 m% u7 Q$ X" [5 V5 {% i
c) return the name of the department of the authorised user$ V: d8 b! q* O* A$ _3 S
Individual Data (Maximum 20 marks available)3 O7 N* M- \. `% d$ ^) k1 \
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 L$ R3 f+ F6 ?( fDocumentation (Maximum 10 marks available)
6 P8 y5 o7 C* X& W6 b$ p6. 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.% ?' j3 c1 B( {4 m1 u
BSA104 Business Programming – 2007: Assignment 2
2 A5 M+ m5 n6 rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 f' P. @: u4 w0 S) J* {' M不过你要翻JAVA的类库说明。你有下载没有?
+ W( K- c5 j" u: w  @查询关于对比的函数。貌似关键字是contrast,还有compare9 O' ^; U# ~' R! k# H. s6 J
9 l5 _2 `& s& _5 g8 \& U
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
7 ?- @( u$ l* S& i! w- w痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ D$ x0 g; H  F5 y- ~8 x- ~
可以下载到的 是 jdk-1_X_0-doc
1 p3 z9 H$ T- a) ]+ t
  W( F: x) e, j% m' t) Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-27 21:19

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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