找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1316|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! e7 J5 [: _- X $ l+ b3 p4 I5 ^. ~0 D) Y9 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 | 显示全部楼层
//*********************************************************************  C: I& p" \$ `- \& f9 K& @
//  ProgramCompare.java         Provided by: DRS! a- e, v/ q3 q/ n% _
//
- r  h/ N! e/ H1 u/ H! K: A//  Program shell for Assignment 2" P) l  K* ^9 h" [
//0 `0 x/ L: Z1 @' m* n+ X6 M
//  Compares two text files line by line6 ~: Z' C4 ~* H
//*********************************************************************  P: y" }) }/ F+ G, l& m: N7 a
; c+ Z6 D1 J4 x5 I8 }% C
import java.io.*;
% Z8 m; k7 K; q# r6 p3 x8 ?1 ~6 [; i
* \. {+ R2 {/ M# v% W) p0 D4 m, {' lpublic class ProgramCompare/ }. c2 B  @6 |' T; i" ~: d
{: ~, s& @* `4 W5 w: k7 ^. R) D7 W
        //-----------------------------------------------------------------+ a6 p6 Q4 T+ \2 Y/ E$ G6 S
        // Constructor
) j, x* S8 H. }5 }4 Q        //-----------------------------------------------------------------
5 o2 K, m" `) Q+ O" i        public ProgramCompare()
' h9 O7 Q/ j! ]# v/ i, h        {
( d0 n8 B. w. \2 G! ~/ C: m2 O        }8 t2 q( W, m3 k6 j9 s# x9 t  w3 k

8 C+ m: {) R8 @3 I# U% K2 }! K2 T        //-----------------------------------------------------------------! ~* ?  u" E" ~% R0 u! Q( g
        // Method for testing that class has been reached! J0 R$ j$ x: o
        //-----------------------------------------------------------------       
/ |: }7 k% V" v5 b! d! ]
* {8 f3 d; Z, p        public boolean ProgramCompareReached()        
; C  ?- {8 ~. E1 `4 ^# \" f        {/ J1 y/ E  j. p7 {5 E' b9 g# u
      try
' \' Q3 T  p) ~3 b   {         : g. C9 _9 w: N( c3 B! J0 D# q
                       
- C  I. [! g7 Q& t: L9 \                //********************************************************************1 v5 C: W+ G3 t- u4 G
                // Try-Catch Statement is used to handle exceptions - such as file not found : @! N$ `6 @$ A; \1 Q/ r! F
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  A* V! @8 n6 F1 j                // For more information see page 534 of the textbook
/ i$ |$ c, c* X                //********************************************************************
6 v0 y( D( l( \& P& I! }& ~                     % j% L2 t/ Y( M3 [/ J
        }
8 y$ W" Q' O- {             catch (Exception ex) // Exception caught here and message displayed to the screen ( p7 _( o" @9 |% ~5 ?. x' t1 E
          {
1 u9 B. h0 r2 r. z4 Y                    ex.printStackTrace (System.err);
9 o4 Z4 p7 X4 s3 e1 Y) ^. L- [9 Q: q           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 F9 B/ R  Y1 N( ~- U. ?        }% l4 k9 X. @% `, V. G" |8 P8 d
                return true;
# i3 z4 i, ~0 |0 ]  w& H4 ^        }; g9 D/ J* D5 Q- C  U# q, G6 E
8 B; Z* M3 |# M, t5 E) S
} // end of class ProgramCompare, [- d5 X( q/ j% P! L. f: g* X
: f7 _8 x" }# q# i: u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" z$ u, ]! o. w- H8 u
//  ProgramCompareMenu.java    Provided by: DRS
0 o) C# k; J) Y; A: h//
9 ]. K0 `# U$ c  o//  Calls AuthorisedUsers.java and ProgramCompare.java
5 e# u( U/ `; V8 `( e0 L+ {* Z" l" ?//
* g- ^" `% G. C" g" c4 {  a2 [$ B/ x//  Driver shell for Assignment 2.. K& r% N4 n5 e6 A7 u6 S3 q- _
//********************************************************************8 v- F* h, K! N9 [$ j: k
$ _6 k+ n) j$ g; {1 u6 O6 X
class ProgramCompareMenu# d- k/ \" f+ I4 U/ A7 S
{* \3 N. O+ V4 L9 w) J
    public static void main (String[] args). }* L$ y$ Z" M4 t
            {
( E) |4 F5 V  o# m                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 z6 X, D& A# u+ B                ProgramCompare reached1 = new ProgramCompare(); 9 p# _- d1 P1 F+ l% A. p* B
                AuthorisedUsers reached2 = new AuthorisedUsers();        , X6 b7 x' E3 j( L0 \
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());/ z8 d5 n& }! M3 H  u& f
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ; u4 V9 E) s" ], X: h
        }$ d) M: v! [6 I4 g: D" w
}// end of class ProgramCompareMenu+ v( B6 S8 r: b' r" j' A- U

+ P0 U' ]5 e* ]9 ]; h! W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! a/ R; X$ T0 N! S  t//          AuthorisedUsers.java          Provided by: DRS- h4 V, J& V) a* Z3 ]
//                7 O/ t4 P6 R% n. I  p1 v: ?" t. U! A
//         Program shell for Assignment 23 V. p5 s( Y0 `# G) {- q! P
//( v5 t1 n+ x2 |8 U4 k6 _/ M) r
//         Represents facts about an AuthorisedUser- y& w; p7 A: H" {' Z8 Y9 w# F
//********************************************************************
- q, G+ `1 m  @) K, A* F2 S* q! b0 i, c8 ^/ m( x
public class AuthorisedUsers, q1 G7 U* X7 _) h# S1 d
    {  y2 X  {8 F: b5 o
0 h* k: Y# t9 `6 {+ v1 W; \
        //-----------------------------------------------------------------
0 @' Q' `$ ^! \% d. V: f        // Constructor( ^9 o4 r' |6 ^4 ^& E  Z
        //-----------------------------------------------------------------
7 J$ T1 e" w* e; f; Q# e- _1 h% {* S3 h: `
        public AuthorisedUsers()' s( |# n. i$ w4 L
                {
% n  p" b- o. K                }
/ U* S# S- \: {" d3 c$ x. d4 `* \4 n  r
        //-----------------------------------------------------------------
& n/ L" g4 }$ s; c        // Method for testing that class has been reached9 H& f1 U8 [; Z: `8 {; c7 ?, B
        //-----------------------------------------------------------------        ' n. A0 r& x. C5 d
        public boolean AuthorisedUsersReached()
/ k# Z1 y' Z# p* I4 n" u                {
1 V2 o$ Q) t/ F: r. Z" X9 x                        return true;                       
- A# {- y3 r9 P9 u                }
$ ]+ n% a1 x# H: k1 Z1 Z! J1 n               
$ W1 W1 n- J  B4 o8 z' l% e    } // end of class AuthorisedUsers
+ f: T" C- ]# E+ ?& K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 h. q8 H3 u& z) U% _. l
Shanghai - 2007% m; S2 l4 M: a) L+ g# |4 V
Assignment 2+ U! C3 a9 g3 G
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)7 t5 W9 k$ V- n% c# i4 v
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.
" S, r' \  X# v4 }The staff must be able to:% _6 u: o4 l" {8 W# J" J$ a
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.1 q8 Z1 P' P1 q" d
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.7 D( T. ]" T4 s% [) l
 The interface should provide a menu so that the staff can:1 f1 G2 m; Y) ], t( `
a) Enter the names of the two Java program files to be compared- M) Y- S% @$ M1 u  c: Q1 T5 N. q
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( q  E1 b$ `. a& t, S! b** 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).0 [- L  j; _0 G9 ~% ^1 }, g6 D
BSA104 Business Programming – 2007: Assignment 2
5 m  A" |) a( o% q# B7 H0 GPage 2 of 5! _0 O9 X4 a& |7 F! Y
b) Print out to the screen all the lines of code that are the same  h" A9 G1 U1 T$ Y& U4 e9 R
 Include the name of the file and the line number of the code being printed for each of the two files
3 y( L$ R( m5 y, {c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ [0 A) S9 b. r# ?& L, @( D the name, username and department of the user1 K) Z: b/ @5 o5 G
 the statistics of the comparison
* N- S0 b, S, z2 E1 n$ C2 ~- Z5 |- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
2 S; G: P4 B6 K! b5 l; |5 J the recommendation for further checking
) ^8 B9 F# }1 t2 J* c- 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) T: w: Z/ _8 O* _) G& C$ W  }
 the names of the two files compared3 |5 d  z/ B, o8 @7 v
d) Leave the program (exit)
+ D, Q) y9 Q  f- h, m8 Q0 t  ^The ProgramCompare class: (Total maximum 20 marks available)' E0 S4 [+ J; a+ m/ c
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)
: u4 s- Q' V9 V' |  y/ ia) provide an error message if the files are not found or there is a problem opening them, D0 H. |# H* T9 Q3 \* J! O
b) compare each line of code+ S! b. p  C! m2 k
c) print out the lines that are the same
1 j* [' C* x& m% m1 p$ R) Zd) count the number of lines compared / lines the same) m2 u1 g; i! j4 z7 K$ O4 ]) r& _
The AuthorisedUsers class: (Total maximum 20 marks available)
% f$ c  O$ S7 u3 V& d+ u3. 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)
& \7 [$ R! P1 L$ b( f! n* y4. Provide methods to:
$ J+ ?# z" ~! D  d' g5 M( E8 Sa) 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+ V: R: I. H  m* a3 h' _0 |! e+ t! O( r
b) return the name of the authorised user
5 p+ ^- T0 B4 S! i! @: Oc) return the name of the department of the authorised user
1 {! _, J7 C7 t! Z$ U+ L  [. o2 @Individual Data (Maximum 20 marks available), E# L' T: |% i- h0 s
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.6 o; J- U; g3 `7 a1 H3 Z
Documentation (Maximum 10 marks available), d. e" t/ L- a
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.% l( k3 i5 a5 {9 Y
BSA104 Business Programming – 2007: Assignment 2
! z7 C: d3 {8 r: H9 SPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
6 B$ ?. R, g" Y8 Q) |不过你要翻JAVA的类库说明。你有下载没有?6 d3 ~$ \3 j, d( o
查询关于对比的函数。貌似关键字是contrast,还有compare9 S5 s2 V# y. ^5 N$ L4 Q
. F! g8 G1 ~) I: a  Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 s6 y: n/ z9 ~9 p! C
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, w+ C; E, `$ P" L: R% w& J可以下载到的 是 jdk-1_X_0-doc5 {/ |: ~' N7 g: A

4 t; T, Z1 x6 Y# b& j" M0 E+ n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-27 14:46

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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