找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1265|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 C3 H* \3 J' J5 L6 e/ a! U' ` k+ Q" D Z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************/ A4 f1 m5 D/ a# ?, \7 F1 C
//  ProgramCompare.java         Provided by: DRS: ^5 L0 ~6 T6 V
//
( v. u3 g% H+ G/ N9 {4 S9 P//  Program shell for Assignment 2
/ H; A; F: y. g! Y4 v! \5 H//
5 `. Q0 r+ Q) G1 m1 Y7 ^//  Compares two text files line by line
* n; `' d5 n. i1 U$ T( y+ M; b& j8 F//*********************************************************************
; t8 L+ o8 d; O( a5 x+ m% c/ O/ L5 |' C9 G6 X
import java.io.*;6 p- H9 M  _& h% X6 l. W  D
& p" ^0 X5 I6 V$ @4 }( K
public class ProgramCompare; H$ L6 j/ v+ E# D6 Y% C
{
$ @3 u* {8 V4 v5 C; P9 R6 U        //-----------------------------------------------------------------' I) y4 O& q/ |; M3 H0 k5 Z4 a
        // Constructor& Z( J% k" n- t' w, y. F+ B4 p: T
        //-----------------------------------------------------------------
* |- m* J6 \% S5 D, v        public ProgramCompare()0 a' c3 m* S7 t
        {
' `7 x9 V5 F& J  t        }2 S, `1 j* s! \- S
& k/ A& P- I2 [; x, c
        //-----------------------------------------------------------------
+ \5 s# B1 p6 D% f/ z8 {. _- ~$ |        // Method for testing that class has been reached
* M. y. x2 t9 L        //-----------------------------------------------------------------       
1 O/ S$ z& ^* m$ C; W4 J# g, ^4 R
8 l: ]3 F& ~5 i/ J/ A4 @: e& j2 E        public boolean ProgramCompareReached()         0 t+ L' o) R6 Z! h$ i1 d2 g
        {
7 f9 v5 e$ Y5 d0 @& W( T      try
3 @5 f+ \4 c: U( p   {         + ~5 ?# E! X+ v" F% p
                       
" Y2 |& n0 b3 q                //********************************************************************& n! d6 X  a0 L. w% T+ ]
                // Try-Catch Statement is used to handle exceptions - such as file not found # Y7 ~1 `6 n5 j& g" L: O3 ^0 c1 U
                // Reading the files will need to be placed inside a Try-Catch - just like this one!" h9 l8 F$ K% Q- G
                // For more information see page 534 of the textbook5 \& O* o( K2 A2 `0 |+ W
                //********************************************************************7 b, V  M( N' q+ n) Y! a4 ]
                     9 E; S1 b- m0 i# @; X4 G- H
        }: D/ W5 z, m* }! O4 d5 |: @; w& x
             catch (Exception ex) // Exception caught here and message displayed to the screen   Z0 W. R4 s1 B1 I  @3 _
          {
, }  I/ @. l: \; C                    ex.printStackTrace (System.err);
- l3 n) E  s& b; ]           System.out.println ("Error message goes here"); // Replace this error message with your own         
- L1 W1 B; j# V0 H        }5 {3 N9 N& ^) {
                return true;
4 Q* B1 ?% x% G, e) G3 B! _5 _        }
) l3 B3 r8 b: |- J) ~. G2 X7 h2 h# Z
6 G7 V" `' B+ j( ~; V} // end of class ProgramCompare
" \& `! `7 B  G
. w8 B& m( d: C9 t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 t3 n8 Z  `7 N' O: w- [
//  ProgramCompareMenu.java    Provided by: DRS
. }: h, z0 D+ d! k) Q  Y. d//* D* z% S1 T) x9 m( J
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 P# @% H8 T% e) V2 W+ I7 R//
% G6 T% c! Q  y+ l//  Driver shell for Assignment 2.6 ~0 n1 u9 s9 d0 ~/ H
//********************************************************************
' C, f1 M3 [" C
8 C% p* a' Z1 l1 t5 iclass ProgramCompareMenu+ V( g5 E3 t% y$ D( D
{
- v1 x0 R+ `* Q4 O1 X5 y2 s    public static void main (String[] args)/ ?" d) J9 [4 D
            {
* L  c! J3 q. B# D$ K                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) K# H$ d& Q" v  q                ProgramCompare reached1 = new ProgramCompare();
' a3 q9 B& F6 n: K& G                AuthorisedUsers reached2 = new AuthorisedUsers();        / D9 U: g# q/ T6 `0 l" B
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  y0 i$ n% v% l                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) C- O+ F9 l% ]2 R0 O# V
        }0 f' ~) H1 @9 v( [
}// end of class ProgramCompareMenu
) f. `2 W4 t( m' [' v$ x) ^2 h$ e; ]! u. x( F# z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: t! ], V8 C; O, |+ {# f# x% ?+ c//          AuthorisedUsers.java          Provided by: DRS
, `6 D1 g* x2 L1 m' u! [( r* z//               
; ~3 ]% D; j0 r; e8 r+ X  W//         Program shell for Assignment 2
) s4 t. x; X  q8 n% _' `//
" Y7 e# S& J8 s8 B8 H) D3 d//         Represents facts about an AuthorisedUser
! e1 v" q# ^0 y9 _" B. P# L//********************************************************************3 r* }' r+ T9 a
" Q9 n: r9 Z) ~- B
public class AuthorisedUsers" k6 L9 }$ V6 A
    {, X* W$ _# Q4 u( X+ m" Y- ~

+ W6 J2 N$ E3 P( ^7 l        //-----------------------------------------------------------------
9 ?( E" B2 z  }6 |: o1 b        // Constructor
# C- }0 C8 m/ `3 A2 V        //-----------------------------------------------------------------0 O( P0 u: p+ Q$ j
8 y6 w; }# Y; r  b+ k% e9 F
        public AuthorisedUsers()0 T; @0 @3 R+ h/ I8 ?  T
                {
- L3 b, c, C9 d+ ~                }
6 |: x- y& L! @4 V; v( f# j3 ?4 _
        //-----------------------------------------------------------------7 V( X* v7 E/ L  Q4 c
        // Method for testing that class has been reached
1 p' e4 s$ V9 i7 f5 P        //-----------------------------------------------------------------        * `& R+ j. F; o% V
        public boolean AuthorisedUsersReached()$ j1 j0 U; M+ M5 j/ N/ }; s* r, D
                {
( w% k* C9 O! C1 ?9 O% E                        return true;                       
: k3 Q/ b/ _& R& S& c                }
+ ?; h3 R2 X" q$ N4 g               
4 T. m' y, n2 L9 ~9 x# t3 u    } // end of class AuthorisedUsers7 `6 x* T: v# H4 }% V$ G: r% T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming7 Z( x5 R9 G" N6 Z( |
Shanghai - 2007
0 m9 R, ^$ Q& v* K* iAssignment 2# s# M5 O! [0 W, t1 p$ d/ z& L
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)
6 ~" T4 `5 J3 r3 x1. 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.% `" u6 g7 N# n& d( n% L; w6 z" c& c
The staff must be able to:9 C9 o# ^: r1 g8 M, ?& l
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.0 y2 k& |8 V8 H0 N9 D2 ]
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.
8 F( T: ]- I  v, ^  R The interface should provide a menu so that the staff can:
; w+ r8 I3 [, g" ia) Enter the names of the two Java program files to be compared& V9 o! W& i$ h0 J: H' u& ^3 T* ?9 N
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 R2 p+ g( f) k6 h( Z# ]** 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).
$ u8 O$ d: u! Z# K5 \BSA104 Business Programming – 2007: Assignment 2
/ H+ t7 \2 J& k$ P+ u# B0 U) \Page 2 of 5. U1 M- u5 S6 c3 K; }3 y8 n, L1 z+ p. x0 P
b) Print out to the screen all the lines of code that are the same' f7 ]3 e* D9 _$ w! Z
 Include the name of the file and the line number of the code being printed for each of the two files
& t5 X, X& c3 Q3 jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" ]! P: t4 V& `, e# y
 the name, username and department of the user
) B7 m4 s& r6 I8 W) Q* o the statistics of the comparison
( ~. S: v4 J% F1 Q1 }; s- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
5 R0 x) f# i- d8 |3 T/ [4 V the recommendation for further checking
8 A2 {( q& G6 L- 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
, R8 h- [3 Y9 i6 y# V% A; b5 { the names of the two files compared
6 |' k" R' [. y3 ud) Leave the program (exit)
" X% F- I. D9 ?7 ]( ^: R" NThe ProgramCompare class: (Total maximum 20 marks available)/ u9 h: B, H4 m+ b- d+ e
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)
1 r& u, \; \8 L$ Y3 ca) provide an error message if the files are not found or there is a problem opening them7 e6 ]) x3 p# Y* X5 y
b) compare each line of code9 s$ {! q, V9 s' ?7 V' \
c) print out the lines that are the same: T6 H* b, U* ~. G( m1 j0 X  s
d) count the number of lines compared / lines the same
0 m8 h; m- [6 l* c; t- qThe AuthorisedUsers class: (Total maximum 20 marks available)
7 ]8 U5 n# e# d, z( _, M! b3. 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)# a( K+ m: n, K( ^" S. p
4. Provide methods to:" r2 `, y& z4 ?+ ^
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
8 p% t( n; a! T  n' }) ub) return the name of the authorised user7 {: V# k9 G" G* P. z  T
c) return the name of the department of the authorised user, a5 k- o6 t( L- b2 t2 S
Individual Data (Maximum 20 marks available)' x. Q+ i+ w. ~+ @! J9 ?2 Q4 f
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.
5 H; r/ T) N1 l! z* ?8 d7 \) pDocumentation (Maximum 10 marks available)
1 L8 f8 c, j4 Y8 ?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.: C% W5 c3 X3 L" _( Y5 N9 G
BSA104 Business Programming – 2007: Assignment 23 X. q3 @/ r) @+ }- i, e
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了! R7 [; x( i8 N8 G1 M3 M% H3 u' f5 h
不过你要翻JAVA的类库说明。你有下载没有?
( ]) H4 v6 r: c0 R" m查询关于对比的函数。貌似关键字是contrast,还有compare
8 h) _# A4 F) A3 l8 d' Q! S2 a: ?3 n2 Y3 B- c. K( g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
3 ]& M) `3 Y  K. F3 @痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 u7 C% d$ h% M* N* \5 |
可以下载到的 是 jdk-1_X_0-doc8 b+ b5 f+ v4 |  J

4 O9 ~8 n6 H; c. @. y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-11 21:48

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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