找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1205|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 R4 t- {: }: S+ b: I5 C1 \! l * J! B6 H) w; E7 v
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************) @; |- J. U: _4 o+ M
//  ProgramCompare.java         Provided by: DRS% P9 g" I, c' v0 N" `& k/ Q
//
' y- r4 W' `" y5 u8 l' L' r* a//  Program shell for Assignment 2
( z' v! j9 w( |- b5 V" u+ L# m) I//
9 `' U  Q- }, @" o8 \* O//  Compares two text files line by line. [* \3 z3 K/ [0 F
//*********************************************************************  D) b2 q! J% ?+ H3 Y

3 |& f  _" |, i" L+ ^import java.io.*;
- d4 X1 G4 n6 v4 B: o. ]( P' r) O; i2 @' O0 S( \, Q  V
public class ProgramCompare
6 [% [' m8 \5 L0 y' h- \+ Y+ |{
9 H- ]) z, P) t        //-----------------------------------------------------------------
& a" [# N5 V9 R2 X        // Constructor
5 _' E! e9 K+ a        //-----------------------------------------------------------------, R- V  L' J. O5 g
        public ProgramCompare()! S1 ^7 |" S9 c4 s3 ]6 O
        {
: s+ p  D& K: J% i6 z" l9 W2 d        }  I1 U# W, q3 S" o
! L4 ^! _! b: c
        //-----------------------------------------------------------------0 D' C3 }* c/ u; d! h( e: }
        // Method for testing that class has been reached! y. [/ A- b. e5 @# ~/ U
        //-----------------------------------------------------------------       
2 w3 P( D7 ?( z( x5 k  N2 c" n6 W3 k) K' {( s
        public boolean ProgramCompareReached()        
/ c9 X4 o7 H4 _2 S& M6 X0 t        {4 A" ?$ G) T3 e/ r
      try
/ c# Z6 R) X) f* a  ^   {         ; D% t; S, @6 }2 V7 n
                       
* W" {, c) I& t" _3 Q' v  o                //********************************************************************0 T+ b9 Z* Q# A5 w4 ?4 F
                // Try-Catch Statement is used to handle exceptions - such as file not found
/ n& Y% [+ T7 u% [* f: k                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ [3 i  s  b- E  ?2 J6 d
                // For more information see page 534 of the textbook) P+ i; R& ~2 A  B' Y
                //********************************************************************2 V$ o% {/ ~+ n. B* q+ M8 p
                    
! ]) G: ~. d2 b        }
3 P4 I9 B- M% V% J& }7 L: }             catch (Exception ex) // Exception caught here and message displayed to the screen
2 ~& |; |  T) F$ P# |          {( C- ?3 H% c2 A, c( T
                    ex.printStackTrace (System.err);+ y' B$ J8 l. ^4 G
           System.out.println ("Error message goes here"); // Replace this error message with your own          % N* N/ i: _" X$ E) }' o: H+ ?
        }
8 E8 L, d9 D; |                return true;
& k4 @1 X+ E' i        }
/ n/ `5 U$ h- Z/ B$ B* Z$ P. T5 e9 q/ s( O9 S; i3 Y: R
} // end of class ProgramCompare! J/ Q: w7 z5 U1 U, o* }) {  d

& b; _% Y, M7 U4 q0 I8 N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ t& }( @8 A9 H% ]6 ?9 f. z//  ProgramCompareMenu.java    Provided by: DRS/ v9 D% H' q* F2 o
/// f: I; E7 g5 R8 O
//  Calls AuthorisedUsers.java and ProgramCompare.java, _% f- z* F, ]$ Z/ o3 ^) d) @
//
2 L$ t, e* s- ~. V- z  I/ [//  Driver shell for Assignment 2.
& f, }% s- s& a3 n( @//********************************************************************- d- x) V& T2 _. h3 n
  H: f; l8 \, ^
class ProgramCompareMenu, f4 ~! ]% W$ j6 M
{$ N! V2 f( ?  J% s
    public static void main (String[] args)
: k! R) F. D: J, w8 z5 L            {
; X- l+ K; J8 T0 N                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, a3 B8 f5 \8 N9 {  [- g                ProgramCompare reached1 = new ProgramCompare();   r4 Q$ f5 }; ~' d9 m
                AuthorisedUsers reached2 = new AuthorisedUsers();       
& {+ t" ^6 E) h- L: N6 l                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# {0 _- ~, T5 p' g3 K. c
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 X) ^1 i: Q6 @0 j: b- Z
        }' D  K$ o9 K! Z6 Y( P+ B9 K3 P
}// end of class ProgramCompareMenu
5 S  |: Q% D* N8 o0 {
$ e3 C- w  F( d; r# z5 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ h* p. q7 }7 [' `/ ]1 e6 V- r
//          AuthorisedUsers.java          Provided by: DRS
- C# k6 q" G9 T  `% C2 H//               
8 ^+ T# b( Q/ }$ h4 S* u//         Program shell for Assignment 2
$ t" O: {4 J( Q9 d3 B5 q9 p, A//
- M4 G4 _8 u+ X. q1 M; x$ o* v1 u//         Represents facts about an AuthorisedUser
5 R5 p  h2 F5 R5 v4 E* {: ]//********************************************************************
# K) W3 k' ~! r' Y+ I/ Y( u' Y/ q4 c" f6 z& ?' f8 X
public class AuthorisedUsers. t/ ~/ t9 c: n* r
    {' Q8 S1 T0 R. `- _1 M5 ~) D

) {3 o, q+ J4 d8 L        //-----------------------------------------------------------------
1 R4 y! K" |+ a$ H0 y        // Constructor
3 L* J. l6 N( Q& i/ r: V        //-----------------------------------------------------------------
. }* x3 }/ F% ?& ?$ d& i7 s! G& t: G& o; h* V1 m. g
        public AuthorisedUsers()
" J6 X" ^4 K1 E! S                {
7 \  B. ?" j2 c8 M$ j2 O                }% s% G" r% X% I7 w

* }. h. o" Y' ^        //-----------------------------------------------------------------
! A; a9 a( V/ [. I        // Method for testing that class has been reached
( l  ~, m% H# L* g# ?& R) }        //-----------------------------------------------------------------        , T3 `' x' h4 }" q, d% x
        public boolean AuthorisedUsersReached()' M# ?# N& n1 S- C
                {
, q4 [* j5 o1 W% Z                        return true;                       
) Q+ `" O- y$ S# T                }
9 p- @+ u1 Z2 C; l               
  j& P$ `9 y1 _0 Z( E    } // end of class AuthorisedUsers, P8 N" `  a$ o7 ~# R2 a
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
+ A$ h9 D* b( f, h/ K$ [  r: i( E1 R) fShanghai - 2007
: p' C) c+ F4 d7 dAssignment 2
) G' f) E1 C# A- [& \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)1 P1 k+ c7 C! y/ w/ c* |8 s# _
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.
8 L3 p* V. o+ L3 zThe staff must be able to:& ~1 \0 ]$ v& S4 b4 N
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 T" g& @8 c/ K8 _5 {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.3 M/ Q% E: ~# j8 G
 The interface should provide a menu so that the staff can:
4 i7 U4 f2 ?% P+ |" @2 za) Enter the names of the two Java program files to be compared: N' P6 Z& P& H* D, Q/ H
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  |1 a1 S) G9 U
** 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).
6 l2 G4 m  ?& w3 |' M: oBSA104 Business Programming – 2007: Assignment 2% c* {3 M: h3 N& e. P
Page 2 of 5
. s0 T9 b, m: M( T7 `* N% M* {6 qb) Print out to the screen all the lines of code that are the same0 Y6 W. B( w0 m6 W3 }% v4 `
 Include the name of the file and the line number of the code being printed for each of the two files% }3 Z8 w$ e# v- T/ J2 o
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 f8 g1 ^$ V# J9 y
 the name, username and department of the user; l6 b8 n. T% C' z
 the statistics of the comparison0 Z: Y/ X' j9 @, H9 N2 G1 Y
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) Y5 ]# `- x$ n) ~, {
 the recommendation for further checking
9 J5 @: x; t4 f0 \- 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 closely3 J6 f8 h! t2 g, l
 the names of the two files compared: V7 ]0 e; x) h5 b' B' Q/ F: q
d) Leave the program (exit)1 r' |) B7 k/ U: Q; W. H3 {- d2 A" ~
The ProgramCompare class: (Total maximum 20 marks available)9 a' s/ |! D( ~3 M) l6 f
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)
# N" h# U, l2 pa) provide an error message if the files are not found or there is a problem opening them# M( v( K3 m  f$ W
b) compare each line of code
" u; U4 l7 {# Lc) print out the lines that are the same
3 g* j( m9 k0 }! Xd) count the number of lines compared / lines the same: D! V5 T* l4 H$ Q/ c
The AuthorisedUsers class: (Total maximum 20 marks available)
% u" w4 C! L$ _+ K! J3. 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)
6 ?: y/ }. K& h# c  j) J4. Provide methods to:
+ t- w( A+ f1 w5 \' ba) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match3 l. n. A& P* ?5 Q
b) return the name of the authorised user- }6 k( {7 C% Y* U- M
c) return the name of the department of the authorised user, o3 l: w8 v& W5 C, z
Individual Data (Maximum 20 marks available), [; A4 f1 H" G3 o  W
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.
: `! e' Q5 ]  _/ uDocumentation (Maximum 10 marks available)0 [9 ^5 h% G, W
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.6 k  F5 o8 Z) x( u/ x( f  q& a
BSA104 Business Programming – 2007: Assignment 2
# k9 @0 [+ Q; c+ d6 {Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
) ^& Y0 ~+ C* S; {: c% p# e' p不过你要翻JAVA的类库说明。你有下载没有?' ]7 n% P  T+ ~0 N6 _1 |
查询关于对比的函数。貌似关键字是contrast,还有compare" X, B% X4 F' o, N+ E4 }

5 r* M9 \" W+ ]& I1 ^$ S( R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* z7 ]7 z& B7 Y; S8 Z, @: v痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! B  q3 a! N4 X" k4 M: D
可以下载到的 是 jdk-1_X_0-doc
% W3 x" u/ o- ?4 b$ k3 q% P: u
: P4 A; q8 m# ]/ a! i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-18 02:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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