找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1411|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 N, M L; N" k ! r$ {! g0 }4 E" N/ d- b. @, r
回复

使用道具 举报

 楼主| 发表于 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. b2 z  {. u& B//  ProgramCompare.java         Provided by: DRS& t: z. n6 D" @) X  |
//
- w! o3 {$ Z, C& A//  Program shell for Assignment 2
* D3 ^# T0 {1 F1 S% V  o//
* ?  o" w1 X% ~//  Compares two text files line by line  Y; B8 T6 A: j& H- v/ v
//*********************************************************************" s* l" ]4 }3 _" W

/ u3 _: i; F5 |4 M' \8 w% zimport java.io.*;
+ j  u1 ~8 |. ~$ j  C# P+ D- T" I2 e( c( u. y, L4 t' v9 m6 i: y
public class ProgramCompare' p$ N7 L$ A0 y+ M
{
& h. J4 o8 V1 Z1 Z        //-----------------------------------------------------------------
7 U# L0 k0 L  _; Y% j' o        // Constructor
5 m- E+ {$ F  r5 q' r2 V: `        //-----------------------------------------------------------------
) Q( g! k' h5 t, G/ [1 D        public ProgramCompare()
3 W5 ^( T: T3 J9 x8 N3 V9 o        {
9 J6 R) `0 h) @( }        }
" T/ F# w# P  v/ F
8 j) H# ^. P$ @& _$ O        //-----------------------------------------------------------------. @* }7 v* Z, q' K
        // Method for testing that class has been reached2 V% C! o4 q; u6 X, z: A& v0 k' u
        //-----------------------------------------------------------------        3 `; o. \  z) B0 b; k

& X( u2 M8 @0 M# l  o4 T        public boolean ProgramCompareReached()        
7 m9 O, i( L; e0 v* N( D) `        {! R1 q* |( |' X) x
      try ( n2 k3 g/ \) t
   {         / S& i1 k0 p: P; k* `  \# U
                       
4 R4 y3 _7 F3 A                //********************************************************************
9 G7 Q  q  F/ C" Q1 ^& t! d4 b                // Try-Catch Statement is used to handle exceptions - such as file not found 2 `3 Z- }& L( m' k2 ~
                // Reading the files will need to be placed inside a Try-Catch - just like this one!# d: Z! t4 D. `( O# {
                // For more information see page 534 of the textbook! @2 d" t& K: O- |
                //********************************************************************2 J( U% K3 k4 @9 @
                     5 |9 c6 G; Z4 D" Y) J2 T, Y( U
        }  x& W* }5 X1 p- f+ {; W7 L- z
             catch (Exception ex) // Exception caught here and message displayed to the screen 7 n, s+ }* S0 f# u
          {
$ x  f, p# V5 H3 {7 U* s7 C                    ex.printStackTrace (System.err);
& s  b. p) E& B/ C           System.out.println ("Error message goes here"); // Replace this error message with your own         
; O  ]* _: f) V- }8 R% m" R        }' h0 ]% D/ @% M8 t
                return true;
4 T- }! d4 w7 P* E: W3 d6 s- N% z        }
9 i" R1 P" r' J! n! J# ?" p1 n4 p
} // end of class ProgramCompare
9 N' |1 c7 d6 C5 x- R$ `4 Z
8 b6 G% i/ }5 y, D5 Z6 A" X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" L4 I" o* q. l" y7 C
//  ProgramCompareMenu.java    Provided by: DRS
6 Y/ Z" ^1 K  D# k4 m* @//$ _9 |4 Q9 X- ^* Y  x, c
//  Calls AuthorisedUsers.java and ProgramCompare.java4 I8 W: q8 R; U6 \( y- t* Z3 T
//
' v& s/ C9 u8 _2 X5 E//  Driver shell for Assignment 2.
2 L1 Z- c: W$ B: V# k) B% s//********************************************************************- ^( J( {$ J& `; o0 a2 s
& R7 R% y3 z6 T! ~9 X4 o9 Y3 N
class ProgramCompareMenu
& {) `0 l/ E# ^' L2 D4 _) h{9 n# ]9 J' G. A# D3 v' W, r+ R5 L
    public static void main (String[] args)
* A2 X0 J; |2 U            {
# h4 v& e$ ~" h6 x. ?                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: ]: ?: y# |$ I4 ^                ProgramCompare reached1 = new ProgramCompare(); 8 q- O+ u7 g1 I
                AuthorisedUsers reached2 = new AuthorisedUsers();        4 ^: {/ `* h7 S# H# z. }
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. X7 z( H1 b. |% h& ]7 p
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 O5 f1 l& Q, I  [# v        }5 ?: n$ K2 q3 A7 X
}// end of class ProgramCompareMenu
8 p- R# g9 Q1 W. D7 o
% A$ A3 P$ S; t$ _- L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
8 @2 ^0 N3 A7 K: d& O7 F8 G//          AuthorisedUsers.java          Provided by: DRS# s" W) h' N# K1 q& I' e
//                & i) E9 Y2 l/ }) V
//         Program shell for Assignment 2
5 V" b0 g5 j& j! Y6 g+ X2 y//1 D+ }; e/ M2 n6 F
//         Represents facts about an AuthorisedUser* ?0 n0 T( w% E) t  y- p$ C
//********************************************************************+ k/ j  e( m- B* Q5 R& ~5 ~4 S
* u8 K$ K2 Y8 X" b5 m
public class AuthorisedUsers" G7 M6 f! q% E/ n8 r# s1 Q3 t
    {' H2 i; m& e+ h2 Q

7 Q4 d. ^7 N2 n        //-----------------------------------------------------------------
+ U  O& `( }- O/ L. `' i( j        // Constructor" U8 m! W/ J& |% F
        //-----------------------------------------------------------------
! Y: @9 R8 H6 j) g6 w' q/ z+ T, {( q
        public AuthorisedUsers()
* n  D$ }! d6 U& S4 c& k3 X                {
$ b' y% U* f4 a                }1 {# [4 H1 D- [- h3 `9 }+ R- R

, O7 a. S( a0 \" s        //-----------------------------------------------------------------& {$ V+ F5 W& p- x( S
        // Method for testing that class has been reached
+ Y) j0 g( ?$ S        //-----------------------------------------------------------------       
) B$ b& T  F7 f# {1 S9 r' |: s        public boolean AuthorisedUsersReached()1 c: c9 {* H% P: o: f9 [( e" q" P; w
                {
( E5 }4 I8 ~) e1 M7 M                        return true;                       
  \- U2 U/ s0 M. k; }* e                }
/ N! Y4 ?0 S7 u2 W                8 q, _; q# c& ~* L; l/ U2 o" X
    } // end of class AuthorisedUsers
. D7 r  H9 z: T; i: u& F( i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
) `  ?. f. ~' \: G1 Q+ SShanghai - 2007+ l9 @. f( w/ v0 ]) K
Assignment 2& ~% A) m) z$ s5 \1 k' ]9 r
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)% }! A2 a# L3 ?8 D/ @3 h
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.* j, N) S7 ~4 l' p( g, y
The staff must be able to:
9 B- [- V: Z. x4 f5 b# @+ I1 ~; x Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 d" E* o  A! G' ~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 b7 l: |9 \, F4 S7 ?# V
 The interface should provide a menu so that the staff can:7 C3 x9 d% U7 W
a) Enter the names of the two Java program files to be compared5 M$ ]: s! @1 ^$ `* \0 m
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.5 W; E- o+ c& r8 z/ z5 T
** 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).
3 B. W/ k4 e! z0 i( z  @BSA104 Business Programming – 2007: Assignment 2
+ b5 d: P. Y; nPage 2 of 5: ]8 C) R# Q& [9 u. P
b) Print out to the screen all the lines of code that are the same: r& `5 `: e+ p5 G2 c2 f
 Include the name of the file and the line number of the code being printed for each of the two files  Y) s% u" t3 h% J2 H$ _: ^
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 `+ w! J7 x7 i; B) l& e the name, username and department of the user. S2 X* s9 e! o6 @
 the statistics of the comparison$ i5 e( g- w0 i5 E+ m+ z
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different. p' y! {  q1 G, k7 m4 z
 the recommendation for further checking% w& I+ @3 |) ?
- 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
8 E6 C" a. L, w+ m: d  \4 r- `% ^ the names of the two files compared& n) G( t. F# R- p" k7 {7 R. F0 R( |
d) Leave the program (exit). G3 C1 p" |/ l" C# e( r0 n
The ProgramCompare class: (Total maximum 20 marks available)
' z9 f2 I/ R' }6 M2. 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)
, N/ n3 B5 `! u1 Xa) provide an error message if the files are not found or there is a problem opening them
0 S3 ]: h) P8 wb) compare each line of code4 D$ y& W2 s5 y1 p
c) print out the lines that are the same
$ |: o$ F3 x/ I) E  |1 g8 I* od) count the number of lines compared / lines the same, j! l1 Y2 V* |5 H# R6 x
The AuthorisedUsers class: (Total maximum 20 marks available); h/ }/ \* c; d( d( 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 ~# _% M5 o  ?5 o
4. Provide methods to:/ }  ?8 o; h0 J# A( p, ~  m( A
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  z7 L0 h; t% O. L' {" J
b) return the name of the authorised user
+ R0 ]  ]& }( Z4 x7 I" a& ec) return the name of the department of the authorised user1 _2 ?: U* G/ T: x- \6 M9 ^
Individual Data (Maximum 20 marks available)! e# N. R' N6 _) i- ]. q
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.% N9 i; W/ X$ S1 c
Documentation (Maximum 10 marks available)
3 a0 l+ a) C- u, q" [" n* 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.+ o8 l. B/ Q; n) A7 X# E: T, h
BSA104 Business Programming – 2007: Assignment 2! k7 C2 j, ]+ ], z0 k- {
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 s- F; I9 v* b7 u* d# @& z, T不过你要翻JAVA的类库说明。你有下载没有?
0 k: X; b/ |* k4 z+ o# Y0 i: e8 B7 D查询关于对比的函数。貌似关键字是contrast,还有compare) E4 j7 G- q6 }" z

7 a1 _6 c# h  m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# \# P' d- R1 ^
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。  U- l# j, Q: Y
可以下载到的 是 jdk-1_X_0-doc
, b) u) h: c1 y6 X9 G2 M: B6 G, J  x( F) h' B) V/ {
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-24 11:17

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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