找回密码
 注册

QQ登录

只需一步,快速开始

查看: 955|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急4 b3 P4 p: O( G9 H# o% H/ G& U 6 i: ?& c* l: k9 W+ x
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
# d- s7 }: P) Y//  ProgramCompare.java         Provided by: DRS/ z% f4 M, g! {4 K$ B6 q9 @! k
//: n2 Z9 c8 X! T. \+ P6 c1 @0 G, b
//  Program shell for Assignment 20 S  I: q& h" u1 W
//
) p& S8 g: E. S8 U0 x' o4 v//  Compares two text files line by line
) I+ x2 y- ~" t1 p1 C//*********************************************************************
8 C* V7 \  N! Y; Y* v. F! e0 ~% a/ P
import java.io.*;
, R; m4 m' o9 Y& H; H
) L$ U- j% o7 V- Zpublic class ProgramCompare
" M/ _  V( h, f9 p) N{
  K, r( ^3 F! G7 e5 v) B        //-----------------------------------------------------------------
9 j7 z; a- J  I/ g        // Constructor9 U8 b' ?9 N9 b: L$ a- z  V4 v! e
        //------------------------------------------------------------------ L# R; y: Y0 r# v7 V6 J5 J) s, J
        public ProgramCompare()6 @# k. A/ A, r7 S7 F
        {
# o* S0 c- x$ k: x        }
8 [7 X4 I9 _: @7 `" W7 G' F$ l' K
        //-----------------------------------------------------------------
: E4 y$ J$ V2 D4 D. W" a7 P        // Method for testing that class has been reached& s& X5 I) J; _+ q, ^* O0 m
        //-----------------------------------------------------------------       
& T) m2 g: e1 F6 _  D
7 n- F5 P* F% [1 T) P        public boolean ProgramCompareReached()         7 Y' ^' p  t0 x2 w" x0 |6 |
        {
! `& I& n5 _* j      try ; C* M# |& ]: E9 N" g' u8 T' P/ u
   {        
' `2 L, a; j8 n# Y5 U& z( L0 y9 V                        * l+ f/ X. J$ @% n+ _
                //********************************************************************7 x, r4 \/ A5 F' r! z# T
                // Try-Catch Statement is used to handle exceptions - such as file not found
$ a* N, t9 a3 m2 \# R* l, o                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 E7 s) J3 l) Q. B. N                // For more information see page 534 of the textbook# B- H+ R( E9 ?* b7 t: N
                //********************************************************************$ j+ }3 {* n0 C. G
                    
6 l  s+ w6 F' m/ ]' P* S# r+ s8 G        }/ j* p* |" b# ~* j* F; P4 a
             catch (Exception ex) // Exception caught here and message displayed to the screen
% o: X* r: {8 k/ ^1 B# ~, I( P- r          {
0 e0 ]- F3 n0 V: V  S+ ^: h) `                    ex.printStackTrace (System.err);
7 j& _, P4 B& D$ g  `- d           System.out.println ("Error message goes here"); // Replace this error message with your own          ! G" X4 z: S, m" B
        }0 G* G+ X! O, S) M
                return true;$ H) Z; [6 B# T1 y$ C
        }
( j  `' Y9 r5 N' A" c5 E. E
' |- ]1 ^  x5 {* y2 ^4 [8 R2 L} // end of class ProgramCompare
3 e* x* t) q% P5 M9 ~: z8 `) v/ Q. u( @) @3 n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 p  v, d) ]0 P' a//  ProgramCompareMenu.java    Provided by: DRS
( C5 F1 s. X9 I" h" T+ {- A  g//
6 h! Y$ E2 {6 p//  Calls AuthorisedUsers.java and ProgramCompare.java
; Z3 I* o- X! P1 `//
9 [9 F; y- K' k) k7 F( j' \& s" Q//  Driver shell for Assignment 2.
$ U( ^6 _$ e- l  |//********************************************************************
" m( K. K' R) n% _! y  g, n/ e! P% A5 Q; I
class ProgramCompareMenu: o  n# t5 ^: h
{/ u, ]  c; E  g* }4 u& G1 w/ {, |
    public static void main (String[] args)
: b  W/ P$ U7 m. ^  K# `9 l            {
' {5 T+ o5 Q% H" {4 n2 J0 f) x                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! l8 ~% N6 Z! ^# l" U                ProgramCompare reached1 = new ProgramCompare(); & Q6 H, M+ b/ E( r
                AuthorisedUsers reached2 = new AuthorisedUsers();       
3 K$ J2 V8 T& h; k) d3 y                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, z  V7 |) t' l1 ^2 l                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  P- u& {7 Y6 P        }8 q8 S  ~0 y) v; U% e
}// end of class ProgramCompareMenu9 u2 m; x1 `7 P( V  R" u4 ?% l

3 H5 g: R' H% g; I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
6 i- |8 z" A1 k" A8 p) E9 P* L//          AuthorisedUsers.java          Provided by: DRS
5 Q3 R1 \7 ^/ e( S//               
" |& |+ ]* t* `% u+ r6 Z* ?, @//         Program shell for Assignment 2( J" y9 L& N: R# B+ m6 i" o' e
//
. U3 s; n) n! X//         Represents facts about an AuthorisedUser/ m( J9 W7 b% G+ L; D
//********************************************************************
' ]; }& ]  e: y( L# X8 I6 d8 n5 \; L. }9 r1 L
public class AuthorisedUsers; L& n( m+ A6 L$ ~9 {# Y3 [
    {( Q6 h, b5 N* o7 C

3 @2 P+ t3 B3 j. U        //-----------------------------------------------------------------/ o% k+ ]7 j3 H: `+ J! t9 Y
        // Constructor3 w0 D0 B3 s" v* L1 k" v
        //-----------------------------------------------------------------
) U# C$ s8 \- {1 R8 ]- I8 }6 h
. G. t0 u8 B3 L6 U+ u1 O% \        public AuthorisedUsers()
7 F/ f( k7 `' ^                {
9 z6 o9 A% m, |: D8 G                }. h; R, R* ]8 R( v, S9 B' b5 \

5 \& b9 w0 Q; ]; R$ X        //-----------------------------------------------------------------
& c% |' o' }1 h8 h: n2 `8 |        // Method for testing that class has been reached
2 g  H/ {2 v8 L# c  ]1 ~( S        //-----------------------------------------------------------------       
6 e! F! Y* M' C+ n5 C$ ^        public boolean AuthorisedUsersReached(). F+ Y; G/ b& K% H3 O
                {
. i# n! ~) @* W( W& W9 s2 o2 U                        return true;                        $ b2 K5 L$ J$ `+ m
                }
0 t6 l! w0 r& |7 j% m               
1 w* ?5 w( ]+ [1 K, f- R    } // end of class AuthorisedUsers
# D1 O) x, a* U% U2 _5 [* l6 `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; g9 }9 V1 C; g. H% U; ]; _Shanghai - 2007
* R5 L, O8 l9 B& _) o+ EAssignment 2$ @2 @& d( D+ V
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)
/ _& |. d; K! ~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.
" M$ |$ g6 t0 v% M& @0 {3 sThe staff must be able to:
& j0 R; m0 D1 u* r% K* R9 A6 a Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 H: B- j. E) `/ H# y
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.2 b+ z6 C2 e) `- l2 X+ [
 The interface should provide a menu so that the staff can:6 Z' a: w; B' j
a) Enter the names of the two Java program files to be compared
( O) E( O4 S3 G( g For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& i6 _2 y9 k3 ]1 |. 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).; ]! U9 y) x) @% ]7 |8 U- p$ `# f
BSA104 Business Programming – 2007: Assignment 2
3 B" q2 c  q" nPage 2 of 5  V! a* S; C* H  h% V4 X
b) Print out to the screen all the lines of code that are the same
1 e: P: [8 Q0 t Include the name of the file and the line number of the code being printed for each of the two files1 O6 U9 ~5 a) C3 c
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
% N0 |" D* A, E) M the name, username and department of the user
/ @. _5 r7 |0 n4 g the statistics of the comparison
/ C  K2 v4 G3 P- q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% ^+ A4 u- {/ m3 w) ?! l$ X
 the recommendation for further checking
( U% m" Q$ E! a  q- 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
) l, M, s5 y# c( j1 H the names of the two files compared$ T2 c# l+ q: E4 _( K3 Z
d) Leave the program (exit)
# {$ Q4 o' ?) X+ O& NThe ProgramCompare class: (Total maximum 20 marks available)
: q: f$ V2 R1 l3 \8 r+ T( J2. 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)5 c$ T7 P: i' S9 ^3 l
a) provide an error message if the files are not found or there is a problem opening them) N7 u2 V# J. X5 {( A0 W3 A
b) compare each line of code6 i' S& q: K0 K, X4 d2 g( E
c) print out the lines that are the same. l. Q% D* e% d; ?
d) count the number of lines compared / lines the same: |; x, a. w# v4 {: M  K( C
The AuthorisedUsers class: (Total maximum 20 marks available)" d9 o! R/ `0 g# ^8 v  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)
) b1 U- z; O$ z6 O4. Provide methods to:* ?, C- C( o/ `8 g8 K( w8 J
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
) L3 K5 T9 [1 s7 j# U8 t8 H+ G) ?b) return the name of the authorised user
7 e5 U8 Y$ ^/ b- j8 h8 L9 U+ Ac) return the name of the department of the authorised user
1 z# J& A3 H& @3 [5 A. \' M0 dIndividual Data (Maximum 20 marks available)
! a% D0 J- Z; w& w7 O" d5. 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.
8 Y9 Q& G' P( }" {* W+ q+ p0 CDocumentation (Maximum 10 marks available)
6 X/ w. Z7 n+ n8 M4 V* X& C' ?* {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.
9 R" X/ a- P0 S4 }5 GBSA104 Business Programming – 2007: Assignment 2
9 U3 k0 I0 t! [+ l3 OPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 P6 L4 [! N( M& y/ j8 G
不过你要翻JAVA的类库说明。你有下载没有?
7 ?7 L- J) F  |7 X: t* ^查询关于对比的函数。貌似关键字是contrast,还有compare
+ W2 U  w( j, A, q# v8 f
4 Y4 q9 m; Q9 c" g4 v' W! P" t  a9 n& J. c[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 b  n4 b8 J5 A" j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! ~! z) q, ^) Z6 V
可以下载到的 是 jdk-1_X_0-doc
: e! Y' S* \/ K: ]5 E4 x5 D5 r
* [! r4 {- q: Y% A. k; ], g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-20 07:35

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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