找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1518|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% ?9 `0 z2 h I8 a: Z' v : B5 ?' I, T+ ^$ V3 S, v$ s, u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************/ n9 j) |: o+ e# J4 N
//  ProgramCompare.java         Provided by: DRS6 x: ]* p% w& i6 W) ?6 X
//7 q% ~0 ?& \4 |. S$ \+ l/ m( M
//  Program shell for Assignment 2; x# P! e) o6 D5 X! C
//
: `$ w% u* ^' `0 W) H//  Compares two text files line by line) ^7 G9 n# y# y! N8 t; p9 {; O
//*********************************************************************
8 ~7 x9 [' B! r4 N4 m1 Z) w8 {9 ~0 L5 l3 g" ]' T5 v, q& W
import java.io.*;* m4 C& {+ e* q. F+ H% M4 {0 ?+ U. T
" _1 _" q* ~8 ]. Z) S+ l
public class ProgramCompare$ f# X+ v! c$ ]
{
4 v6 t4 x: N  k4 g        //-----------------------------------------------------------------
. W+ y8 t6 j$ \; e7 \5 @' l# Z        // Constructor
  j: e$ m8 b; ]5 X* J        //-----------------------------------------------------------------
3 W/ M7 e! I* E        public ProgramCompare()$ D: U" t. X; q' X6 W* F- _/ k
        {
9 n1 m; u9 g  L" _0 s- q        }& r9 ]. S5 J8 n2 r4 s+ _2 g

% }+ `' [5 p; d. d& `1 H0 g        //-----------------------------------------------------------------9 E# ]+ p( N4 x3 u9 x* H
        // Method for testing that class has been reached5 q% u+ _$ Y( x, R6 ^
        //-----------------------------------------------------------------        # I  D' }$ ^* N* a& E
! y1 }. z1 V2 K- y. M3 c
        public boolean ProgramCompareReached()         4 U: N# b! x2 A; O
        {* W- y8 @1 F' h7 G& t( t, M* K
      try 8 Z' n# C$ @5 {% m$ q8 X0 r( e
   {        
/ ?+ G, Q) y, b, Z                       
6 L( j& Y- R& e( @5 ~+ V4 [                //********************************************************************
. j- v$ i' W& z& S: N) C: I                // Try-Catch Statement is used to handle exceptions - such as file not found
6 }3 U% n$ H# b8 B  g4 N                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. K; f& ]8 l# D, {& [# L                // For more information see page 534 of the textbook; G- o4 x" S+ P7 c* L# O! r) W, ?  l& i
                //********************************************************************7 f- ^8 a0 l/ D2 c
                    
4 E1 l0 E7 p5 I        }( g% @2 q* R5 R+ N
             catch (Exception ex) // Exception caught here and message displayed to the screen " R  X( w6 [& `
          {9 R1 D4 w$ A6 \0 x$ d* l
                    ex.printStackTrace (System.err);6 w- l6 _' S, T) b  t6 k
           System.out.println ("Error message goes here"); // Replace this error message with your own          , t) A2 l5 o: S2 G  _, T' ]  u& G
        }
; q: Z& q7 L6 x" X                return true;
8 ~5 K, m5 `. P& z% L2 K! x        }
! \4 D0 w; ]% U: b/ j* K. E7 s* U
2 e, y1 O9 U# j% K' Y  ^! \/ l} // end of class ProgramCompare
; h. s7 N1 X: }2 ]5 s) N; x; d1 P" j  W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( r$ d( a  @& E4 k) q//  ProgramCompareMenu.java    Provided by: DRS
/ B- e* K; z, R& v//* {  x% m1 M/ [9 ]! @( V! x" |
//  Calls AuthorisedUsers.java and ProgramCompare.java, Q& ?7 u. o+ h* d( f3 K$ m
//  M: E0 z0 o" G& E1 _
//  Driver shell for Assignment 2.9 n5 r& F  t* ]6 H; T
//********************************************************************
( @- H( G5 `. G2 N, u8 }. ]) X/ O) ^9 L9 O' d' F/ R" w
class ProgramCompareMenu. [/ p. V# D, Z
{
( K5 R3 b# |! F3 g% B" |    public static void main (String[] args), t2 L# ?1 s' C0 i7 |- E
            {
3 m/ @0 N# A8 T& p% O& u/ Q5 l                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
4 _! ^) o6 e% B3 Q$ s8 }                ProgramCompare reached1 = new ProgramCompare(); % D2 K+ J: a% H, m
                AuthorisedUsers reached2 = new AuthorisedUsers();        + k) b5 {! c4 ]) m: x1 x- U( s7 z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& L# M+ Z. m% L  V) M! J  H                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 Q5 c- H/ d7 o8 r9 ]        }
) o& ]0 @0 w8 S% K; D, j4 t" j}// end of class ProgramCompareMenu
1 K% N( l0 v/ _9 B$ b9 q1 T+ L6 b% g1 b- g! s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************& J9 r: n* @) ~
//          AuthorisedUsers.java          Provided by: DRS
; Q# ]& C/ ]" h+ H//                : f5 i# Y9 K: Z; K
//         Program shell for Assignment 2
# _+ O& B. F3 @/ q: X//8 N3 u% b$ V3 z' T
//         Represents facts about an AuthorisedUser
" c6 H- z9 Q% R/ b7 O//********************************************************************
9 J) z9 x" i* [# X3 Q, ]  {) q% p0 c" q" F# ~( l9 n. N
public class AuthorisedUsers" W. y. T. o3 B; T! w- J
    {+ D# T* i7 @- u; S0 a9 z, {

# h: D7 Y4 ?( p1 [( V        //-----------------------------------------------------------------
  ~; p" n+ ]  q9 |, m        // Constructor
5 L# q4 ~( q# ?" h- H% X& g, H1 z6 u        //-----------------------------------------------------------------5 e+ O. E4 M* |! d* y' |2 ?

4 t& C3 _9 E4 T8 M        public AuthorisedUsers()  _$ y* x# D1 H) @0 N
                {
$ r: N' A- A' ~& n                }
* B' O. V/ i4 |* W5 g
% D8 `+ p6 @: }" E        //-----------------------------------------------------------------
: v; g9 E( _6 f' A- H) ~8 S; S! l        // Method for testing that class has been reached: e+ {- F( s9 R( }; L* P0 a
        //-----------------------------------------------------------------        9 @6 G0 G& G% U! z
        public boolean AuthorisedUsersReached()
- w5 [. e, z  x  Z* j                {
# w3 u9 f. o0 F( w                        return true;                        1 t+ m  @8 h4 Y7 c5 W7 V! h
                }
. M' c( T; s* Q$ b* T+ i8 [                6 L  k" F; A# t2 F# R
    } // end of class AuthorisedUsers6 X0 M# B$ f* U6 a
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; A1 h- {7 m8 w* W- P. `Shanghai - 2007' E* [* Z& e, C% s/ p
Assignment 2
' J! ]* M% r% Y- sDeadline 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)  m1 n8 X; l  `& L- n* n
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.  \; d  C+ ?! b2 S
The staff must be able to:
& p* n9 m, Y1 O2 N& ^ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 D" B: C9 ?2 X1. 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 U$ S  ^  C; Y3 R The interface should provide a menu so that the staff can:
$ w& _9 l) }2 F. k8 W8 l0 H2 E7 Z) ga) Enter the names of the two Java program files to be compared
# O5 x! @! W0 t$ [$ t7 [# } For this assignment, it will be assumed that the two Java program files are in the same folder as your program.5 Y& ]# ]  T# Q3 }3 T# a
** 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).: x) ^3 l6 [& r) a
BSA104 Business Programming – 2007: Assignment 2
# x: u$ p. Q4 |' yPage 2 of 5! n0 N- k/ P+ w1 l# l
b) Print out to the screen all the lines of code that are the same
( ?+ a6 A+ @6 q5 q- f Include the name of the file and the line number of the code being printed for each of the two files# K; o, c8 F( d" w
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared+ x! `9 D- q9 Z+ R) H8 B4 ~
 the name, username and department of the user' T( J; d7 f; B
 the statistics of the comparison
+ L" E3 A: T3 d4 A$ T; ?. A- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 l. R- G& W, K( Q, M
 the recommendation for further checking
" \1 P) [, H" |- N  M# 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
* y7 w6 ?! ?' p  K6 {, K the names of the two files compared
5 @0 Z2 u5 O( o: E, z9 |) s; od) Leave the program (exit)" v2 K- ]* U8 n* e/ B
The ProgramCompare class: (Total maximum 20 marks available)1 `' `$ ~- P  l4 E8 h
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), {, y5 a6 S1 l) M- A7 N2 V- ^' J: o3 R. J
a) provide an error message if the files are not found or there is a problem opening them
0 X0 x7 H$ W9 kb) compare each line of code
( A% ^$ [5 A# ~8 T5 A- Lc) print out the lines that are the same" R! Y: t  [* S
d) count the number of lines compared / lines the same
+ q" i' ?3 }5 l5 LThe AuthorisedUsers class: (Total maximum 20 marks available)8 a2 w! q0 ~1 r
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)2 k+ {0 H2 d. e: j, e8 [
4. Provide methods to:) k0 H& E) B4 F9 j6 E
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 match7 j$ |; D9 A2 m7 k: B2 K
b) return the name of the authorised user
; M9 V$ j, X' W" A2 ~) Y3 q8 v; {c) return the name of the department of the authorised user( o5 {( M: b  o$ N: L& H8 i
Individual Data (Maximum 20 marks available)( H& \: ]# ~5 V7 Z: F7 W: V
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.. A% h% g7 V  o4 ~
Documentation (Maximum 10 marks available)
6 A9 ?8 u/ r  |; e% D" E1 T6. 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.
: N7 U* U. l- l  @% q4 _+ F$ |BSA104 Business Programming – 2007: Assignment 2
% G+ ~# |" k/ K: kPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了* `) }% l& U; p! k2 ?
不过你要翻JAVA的类库说明。你有下载没有?
8 Z9 H7 B0 A+ X$ `' J% V查询关于对比的函数。貌似关键字是contrast,还有compare
. ~1 A. e* V/ u0 e5 C
, D  `5 \: {% n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: C4 p* X. E5 D. N痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, |5 j6 ]) C' h! h) b5 e7 _- M6 s可以下载到的 是 jdk-1_X_0-doc7 j( f, x9 n% B: l. J; M
* N; P& A- v3 R) y3 [
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-3 18:20

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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