找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1716|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # Z! A- E* p* ~1 W2 g8 p t. N; ^2 V" p
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************1 [- t4 @3 q) g/ q8 ]
//  ProgramCompare.java         Provided by: DRS
& c" U' L8 @: Y) X4 i//
4 |7 x6 W7 C) g) G3 s2 r. x+ ~) g//  Program shell for Assignment 2
! I: S# `( y" @) \, S; b* N//
- x9 B* E7 `* q% X; M//  Compares two text files line by line  h! F: y! j* u. A) ^# I+ v9 |$ S3 Z
//*********************************************************************8 [8 n) Y' c' g  ^- S
" R! ?+ p% {! j* E# ^0 G
import java.io.*;
: |1 ~2 p( A9 d  X8 u5 @9 A: M$ @  m9 k  ^
public class ProgramCompare! k2 ^% G, d: ]( J! [4 T/ r4 b
{5 N; l9 F, R' C# O6 [) U- X
        //-----------------------------------------------------------------
$ ~' n, s! i8 j* l        // Constructor! j  @. o6 M9 A  m+ V5 J
        //-----------------------------------------------------------------
- X* Y2 Z$ ~* |& d+ n" r' Y        public ProgramCompare()* l8 j) Y! Z8 N$ d
        {% {: O3 P, z0 C0 E* m2 R. L
        }5 u3 `1 F* G" z9 O% T0 H7 q/ k/ D

- H# `9 O1 z9 F# y1 d6 D' s' e! C$ z        //-----------------------------------------------------------------( r2 j* F& h7 Q
        // Method for testing that class has been reached, }8 g$ H1 [. C* C3 I" T
        //-----------------------------------------------------------------       
7 z- W5 M: E9 ]$ s
4 \# x4 A0 |$ x' I0 P        public boolean ProgramCompareReached()        
- ?$ X) |# Z5 T2 F        {
* Q* w# ^7 R( t% B      try $ P) }9 @+ E" r) A: }5 k: ^' |
   {        
! s+ \) V* S1 U5 X" O% v* X                        : L7 t! k7 y, x  r; M+ q+ C
                //********************************************************************
6 A. d. D5 Z: ~; ?                // Try-Catch Statement is used to handle exceptions - such as file not found
  z& \2 c1 c- N& F                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  z( _1 Y) ~0 B& Q, `5 c; X0 F                // For more information see page 534 of the textbook
' N+ S- n4 J* F                //********************************************************************
0 P7 R, ?6 X9 N5 W                     " l3 c& }$ K" M# Q! K
        }
( Q0 O3 a. v* ^  n2 `; x! L             catch (Exception ex) // Exception caught here and message displayed to the screen
' r- M2 p! Y5 e; `4 Z" Y2 S          {
8 T5 F! w8 A3 G& p; E8 @. Y                    ex.printStackTrace (System.err);
" c$ {) L: @1 H2 h5 p           System.out.println ("Error message goes here"); // Replace this error message with your own          ! e$ Q0 q( X- E
        }( C5 O+ V7 _! \/ }, ^' i# N" {$ _
                return true;9 o+ t  t+ |0 n; G% {* Y3 D( F
        }$ A% y( e* B# ^- B3 H) v  @
& p  ^7 l' s1 P4 U- g* y
} // end of class ProgramCompare
) J% _0 F& J: w* J3 |, v0 T  w( d% y+ B/ h. U* V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- N* d; g  i8 _3 Q//  ProgramCompareMenu.java    Provided by: DRS/ Y9 d/ c6 K+ ?( [
//& Y& q$ D; E7 R2 V
//  Calls AuthorisedUsers.java and ProgramCompare.java5 A: e) Q" L# N4 O
//
) d; o, H. h# X" X6 e! E//  Driver shell for Assignment 2.2 H7 D2 v- ~, d  o
//********************************************************************- q' A+ e0 j# D3 P7 B3 o

- Y% V, R/ C7 p: P( Zclass ProgramCompareMenu2 I' H0 }! }$ ~; x
{
- i  g& u% D7 @7 w' o0 y5 i! [/ t    public static void main (String[] args)
1 K3 ^' [0 D+ p6 S. l            {5 ^# N0 ~# M4 ~( R" W. C: u! Y: _
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable. k- l7 Q0 Y' F* N# }+ G, L
                ProgramCompare reached1 = new ProgramCompare();
  d2 R% ~4 k- j                AuthorisedUsers reached2 = new AuthorisedUsers();       
& A  m0 Q5 u4 y9 K6 C. `                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());* \2 ?$ E  D6 Y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 b& ]' D; H5 |3 N7 ]* }
        }- z7 D( ]; R/ T% L: _
}// end of class ProgramCompareMenu
+ e' [: Q) z+ A; O1 R  `
/ c5 u3 e8 G2 |7 U- I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ X8 F$ Y' `2 t# M# h//          AuthorisedUsers.java          Provided by: DRS
4 L, \* A: F5 B4 {! g, V8 w//               
3 b" F' F" _9 r" s5 f//         Program shell for Assignment 2
3 G/ z4 L7 O, T: X1 M1 {2 F; x//0 V; |+ y# b0 M% S% ^
//         Represents facts about an AuthorisedUser# _- G" e* U$ L6 n5 ~% K
//********************************************************************% _; S+ A( V* W, ~2 t4 m& n
, ~% Y, Z& Z4 M# c% y
public class AuthorisedUsers
8 D0 X* Q3 S/ \" H0 e' E    {( ?" W+ y& n+ F) Z

, e$ f. ~9 q1 m! R7 k        //-----------------------------------------------------------------# u  |) |8 j  W6 _; P
        // Constructor+ _; m' {6 k  |) M) h& [
        //-----------------------------------------------------------------7 i2 m% \# w2 c9 f* P6 ?% B+ j

  Z. i' C9 V2 u7 |        public AuthorisedUsers()8 c3 Z0 x$ y  ?1 s" S
                {% f9 \1 z0 w9 `. I7 U- |8 Q
                }$ w( J- r7 M" I$ I4 j

7 Z! \, I$ h0 ?        //-----------------------------------------------------------------
6 X) a+ d7 r5 j, r( O( D& m        // Method for testing that class has been reached
& A3 X5 d3 ]6 d4 t; S8 n- T        //-----------------------------------------------------------------        2 u7 @  b. }0 u0 j; \
        public boolean AuthorisedUsersReached()) [" R- {8 }  x- d2 {
                {
6 Y4 e" ^4 Z% r7 _8 i0 v% |                        return true;                       
5 g# H, p/ _6 D8 }& \                }
7 L) E1 N0 B6 e               
6 z* f: L$ I  P- B' d    } // end of class AuthorisedUsers* _" O) }7 O7 Q( W" j! t: I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 n5 C  h4 L8 _" v9 m/ s
Shanghai - 2007
! M/ T$ n, z% S2 |' y7 ZAssignment 2
' L: p* X9 A3 ?! Z7 G: `9 a2 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)+ c: R4 w& Y/ B) X$ I+ U# I  W
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.
) f  p  q2 G4 p- wThe staff must be able to:
  p; w$ U( }& g" |( t$ \ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.2 O! _7 G) ^* R. v
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 D- ~& c1 p0 t9 z6 a: v The interface should provide a menu so that the staff can:
% P8 e: Z, e8 G$ f: t1 x# Xa) Enter the names of the two Java program files to be compared; g4 h* M5 {* d+ j5 I
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 i* i9 E, N% ^) v4 O0 p$ L
** 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).: U0 M* L- b9 C) ~; \' y
BSA104 Business Programming – 2007: Assignment 2/ X- A6 K+ W" [
Page 2 of 5
0 ~# r1 g" Y( l9 F. J( v8 Jb) Print out to the screen all the lines of code that are the same
6 X7 d- o6 {4 C# _9 k" Y9 a Include the name of the file and the line number of the code being printed for each of the two files! F! ^& B% H. P: |! Q! [
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) g& L  \; `4 K
 the name, username and department of the user6 s$ P. {, p9 J) f2 I
 the statistics of the comparison/ ?- E" u( M! U1 B/ O* @
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, c; Q7 D6 l. l# [
 the recommendation for further checking. L' I3 `; w! A1 @  Z1 H. P3 v
- 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 closely4 o: u# i! t9 y) T
 the names of the two files compared
- O2 v( ~1 v2 vd) Leave the program (exit). l9 D) a# L( [9 v3 @. _. i, S
The ProgramCompare class: (Total maximum 20 marks available)4 N; {- ?; ]* s: T
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)& g6 V& K: n' Q- b6 l
a) provide an error message if the files are not found or there is a problem opening them& \" F- A1 X0 C: }  }
b) compare each line of code; Z# s+ U+ y1 u& O+ g1 t5 F, k9 b: `
c) print out the lines that are the same' K1 T; ?! ^1 H. |
d) count the number of lines compared / lines the same' `  H: K0 s+ H* d
The AuthorisedUsers class: (Total maximum 20 marks available)
0 ^8 r9 E$ D" P0 S0 p3. 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)+ h5 ]& K8 k! v/ O
4. Provide methods to:; r2 a4 \0 J+ G0 q
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
! c8 ^: G' P' P" M. Tb) return the name of the authorised user, ^( d5 L. w# u1 }" |
c) return the name of the department of the authorised user, r/ v; K' |! U; U
Individual Data (Maximum 20 marks available)! p' E5 `# z" r! ~. F  g7 r+ i5 B
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." V) ?1 U' {/ o; `6 a0 L
Documentation (Maximum 10 marks available)
- {  S: H$ H% @8 z6. 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.! g6 _4 @' c- p& Q8 \
BSA104 Business Programming – 2007: Assignment 2
8 G" Z. T. p) [# m+ @: ZPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( Q! M6 b8 P$ m不过你要翻JAVA的类库说明。你有下载没有?
0 B2 I" l7 i) C# o( Z查询关于对比的函数。貌似关键字是contrast,还有compare" ]! q* P$ z5 V9 U1 e

( }9 S# |, z* O5 b3 w- }9 R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -; `- Y. ]; S: L# t' c" \: g" {
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 h5 I) `5 H/ V: [可以下载到的 是 jdk-1_X_0-doc9 l6 v* I" E. L: \& M/ `  }5 a

5 ?, w" w0 T& @! ^7 U6 V: u" U# J0 y' [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-9 22:54

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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