找回密码
 注册

QQ登录

只需一步,快速开始

查看: 967|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 y' A& W/ A' b* m1 B5 Z % Z- o$ J6 o9 ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 |5 r, N  _2 @
//  ProgramCompare.java         Provided by: DRS6 [" m: J% a/ \9 w$ n' j' r' F
//" Y, g, ]9 M* ~' c
//  Program shell for Assignment 2/ `' h+ q; ^, L
//
8 N6 U. C6 t  E, o//  Compares two text files line by line
( o  Y) t4 N& C8 S* S0 d/ l//*********************************************************************8 k6 ^) y# y% Z8 j1 Y

  I: z& _: O$ B' ?( K( Jimport java.io.*;
9 r9 c6 J9 }1 L+ ^3 j: Z
  L; l% z8 K" d, r: b5 ]public class ProgramCompare6 B" D$ G5 ^2 Y3 ]3 M: n
{9 j  ^0 d/ w% f7 O7 Y2 c1 Y
        //-----------------------------------------------------------------
$ f) p7 t$ }4 W; z& R        // Constructor
+ S) W$ c' D+ u& F! R        //-----------------------------------------------------------------! t2 _# c/ H# i6 U  x
        public ProgramCompare()
+ H+ a2 ~$ o/ H/ G8 u1 d        {. ^8 T9 g0 |4 C( _
        }
  T0 c2 I9 f* I1 H0 ?) X. g5 K, w1 T) Y
        //-----------------------------------------------------------------
+ o6 W, T6 \! E3 r# w9 ~        // Method for testing that class has been reached
: t. I9 H  B; S6 ?- Z        //-----------------------------------------------------------------        8 z( O( c; h4 c! X8 X
2 b+ ~% |9 h7 p3 @7 B2 F: a
        public boolean ProgramCompareReached()        
& A# n! Z/ k; _" H, T' b        {
$ }0 E/ Y3 }) L( Y' S      try
) M( ~6 Z9 Y" |, b8 c5 Z   {        
# Z( f* D0 D0 b                        & ~1 W3 G: l4 y' R: m- A
                //********************************************************************7 r5 f. M) Z* U; ^; Z. X3 v
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 p% q+ ~! S) {- a8 N" P! B4 W                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 e0 }0 ~6 g' z8 ~* l  G
                // For more information see page 534 of the textbook' Z, {: {& m$ Z8 x( U/ z$ R( p
                //********************************************************************
& W+ x4 d( s( E' q4 o                     7 t6 Z, _% _6 M% z- h
        }/ K6 c' P" s% m  U" j4 Q3 A
             catch (Exception ex) // Exception caught here and message displayed to the screen # e! O' i8 C3 j, k3 y3 j( V
          {; t1 C% m( F5 ^3 ~9 ]  v
                    ex.printStackTrace (System.err);
9 u) F, s$ v$ j' k# F           System.out.println ("Error message goes here"); // Replace this error message with your own          1 |8 h, v( c! t& _+ h) P2 {
        }5 {/ h  g/ Q$ F7 x( w- f
                return true;; S; P/ D7 H% ^. @
        }6 \/ a9 U7 J' Y+ }# O1 a; m

+ m6 z! ~  K2 Z8 C& ]3 e} // end of class ProgramCompare
3 x4 z1 O, k" y1 o5 g: I& b( w
- Y: i. {+ D$ {. f0 _* T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************1 A" Z( q% B. Y5 b
//  ProgramCompareMenu.java    Provided by: DRS5 B7 h# R% R0 x5 y" V# C& p
//6 I) S( c% t3 s
//  Calls AuthorisedUsers.java and ProgramCompare.java9 f0 U8 B. z% i  n  q' {$ ~
//
9 t' a! V9 n4 `- H7 i//  Driver shell for Assignment 2.5 U2 P& i8 V3 K: \! Z
//********************************************************************9 w- t* O4 [9 w8 [# V; j0 w1 S

% Q9 c, q! O5 B  G2 gclass ProgramCompareMenu# R& |* W1 s$ y+ S
{: Z! p* A+ l6 f7 e6 w
    public static void main (String[] args)
: [4 R- i7 [1 D) _            {
& q! J6 K. |3 W7 R$ ?. {1 T& l                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% x$ g( y" x) ?) f* i                ProgramCompare reached1 = new ProgramCompare();
# L7 p6 L' H  Q. D& v5 M- i. r& o  T                AuthorisedUsers reached2 = new AuthorisedUsers();        * h) z- W7 x* i, ]- B. T4 ~  A
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());; \4 d3 J3 M( s# m- U3 a1 ]" w
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 A8 \9 U" c( ^7 J. N
        }9 k/ d0 d+ w- b) S) @3 j/ K
}// end of class ProgramCompareMenu7 q9 w7 s0 F! f) z2 I
5 d7 y: ~. u9 L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
8 T: c6 H( A  a0 u4 Z7 ^! ?/ I//          AuthorisedUsers.java          Provided by: DRS8 P/ B% e) C- P* }
//                / O1 E$ E9 \9 b- S" c
//         Program shell for Assignment 2
# d( c; p3 A- s/ a/ V& X4 l//
! n9 O) x9 M+ p" U//         Represents facts about an AuthorisedUser
9 K- `2 ^6 _! W5 K& G) U% C//********************************************************************
( S+ `8 ~, y" l- _" T; t* a' \  N% n6 a5 `% H/ I. g% V7 O6 Z
public class AuthorisedUsers3 g3 q- R7 L9 S9 n# N
    {
. \& `" v, b( c3 m* ?
: X! O  F3 G) J3 k        //-----------------------------------------------------------------
6 w9 Y! i8 ^) @% D% G7 q& |+ W  B        // Constructor) r$ T1 f5 q, Q0 b) h# {
        //-----------------------------------------------------------------
. Z+ V& ^8 L, ~- d2 b( C* x
4 _" K- [  @* c4 J2 R& L        public AuthorisedUsers()3 V( `5 G4 w  O4 X$ }+ x
                {
( O4 d/ i* F* {                }
( l5 E$ _; Q/ ]0 F
+ M+ N" y/ ], Q( B9 O) g. o/ F7 j        //-----------------------------------------------------------------& I$ |9 J6 i: g, N4 ^* a
        // Method for testing that class has been reached
  m2 w, `/ R+ }3 }3 h        //-----------------------------------------------------------------        4 e! L8 T; V  P9 W4 j3 j
        public boolean AuthorisedUsersReached()" P$ Q% }7 g( b$ _& y% g
                {: z5 ~& B/ p& f2 m6 K" k' ?  B
                        return true;                       
6 b0 F# o; s9 v- N: F                }2 F1 O& z3 ?; `5 `! l8 e( k
               
4 K4 D% g4 S! f4 C    } // end of class AuthorisedUsers
9 U- o+ }, U3 ]7 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
  A2 m% G9 V/ e' T9 l8 k% x; BShanghai - 2007
# d9 w6 x1 Y0 Y! \Assignment 2
: K; e2 D! D, n5 }& nDeadline 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)
8 Z' K+ ?9 x  X8 A+ r3 f1. 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.
$ O% U- ?+ ^: ^* Q0 G6 i" aThe staff must be able to:/ p% k' |3 Y8 O% Q1 Z* L+ R' E
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: N" O6 ~  U  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.2 C8 H6 ~6 z6 ]1 R9 s) g( i1 i$ U
 The interface should provide a menu so that the staff can:
( N0 ]$ l) \3 q6 [) k4 j  z2 Da) Enter the names of the two Java program files to be compared
! O* K( P4 U3 T) L$ ?, L For this assignment, it will be assumed that the two Java program files are in the same folder as your program.2 f' `' d. [. i  S% s+ E6 w  M
** 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).) s# a# H% N8 W: T8 O& L& {; L
BSA104 Business Programming – 2007: Assignment 2
6 }! i* w) o7 [Page 2 of 5
  h# D# @+ t0 n+ `* V" j7 Z" sb) Print out to the screen all the lines of code that are the same* I0 a$ z3 r8 S4 u0 K
 Include the name of the file and the line number of the code being printed for each of the two files4 \$ J  L' W& Q) _; m
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
( [# T; v* c6 n# m% D the name, username and department of the user
5 o  T1 v% H5 \/ }9 R5 C7 @ the statistics of the comparison
. b2 P8 u+ j# R0 `3 v6 y- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( e6 a- X- D* h4 c/ @ the recommendation for further checking
; |; e% m7 e: b( r- 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 closely2 ?' Q3 M7 E! }3 V
 the names of the two files compared. e9 m( X& r0 |0 u9 T
d) Leave the program (exit)) g% }: Q7 j% Q" k: N
The ProgramCompare class: (Total maximum 20 marks available)
! S5 y* I. |8 i* g3 ?% L, O. Y+ A2. 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 y% V: a. ~& B" X9 G; E
a) provide an error message if the files are not found or there is a problem opening them
- f0 E% l! z& [$ Q% Z- v( D0 A/ fb) compare each line of code! ~; u) H" A, K9 Z, f/ a
c) print out the lines that are the same; b! \3 o- d  B0 K( o
d) count the number of lines compared / lines the same
! t6 L* @5 y( s! t$ ^The AuthorisedUsers class: (Total maximum 20 marks available)6 I! ~! Z/ Y; d1 _2 N% d
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 w) Z/ E2 w. n, ~6 L0 r7 J4. Provide methods to:, x' G8 b8 R) z1 N  S6 c. T: R" k
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
0 N+ m  |& k% h& b8 P: yb) return the name of the authorised user
/ G, {$ m/ l' F6 }c) return the name of the department of the authorised user
7 e+ O/ J4 k/ p  f  d" T( j8 I7 JIndividual Data (Maximum 20 marks available)( i( c1 p% j, P6 p7 W2 a
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.
; l' y& e6 X5 ]' C1 qDocumentation (Maximum 10 marks available)
: t  r- A, V* Z2 x6. 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.( o- l" ^4 }3 G2 A8 f9 z8 w
BSA104 Business Programming – 2007: Assignment 2: R" i/ c" `0 z. |$ R
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. C- P, H9 T9 R) Y不过你要翻JAVA的类库说明。你有下载没有?% D7 }5 V5 R; v# L1 r
查询关于对比的函数。貌似关键字是contrast,还有compare. k$ g& Y2 z- g5 G  {0 q& ~: z4 A
! K1 ]! k4 i6 W' p- f. t( y) A
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 ]8 v+ r2 X0 F; Z# y
可以下载到的 是 jdk-1_X_0-doc9 l* _3 K# o' t5 M0 W
5 ~8 F$ K8 G: y7 n* }1 j
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-25 19:37

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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