找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1865|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急) l9 i, T" ?5 N' H 1 H$ @) I3 F1 Z0 u( T' _
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 x& d9 d7 t2 U3 [# [. i
//  ProgramCompare.java         Provided by: DRS, Q; i7 U; m& T% Y- }( k
//
' K! M# M8 P. s( A5 K5 ^" t# m$ t//  Program shell for Assignment 2
* L0 W; X& y9 S4 O& q//" Y8 I2 a% O+ y; ~* a
//  Compares two text files line by line
3 ?0 F. w7 \/ W0 O4 O$ D/ w; T//*********************************************************************
4 g8 O& [+ X0 X  f5 ~7 ~. N- u- e6 ?. S6 A, f* w
import java.io.*;
$ g% |4 L9 H# o/ [$ F0 J, g
% x% o0 D" f' |$ z+ T- ~1 ^7 npublic class ProgramCompare* X; m% I$ P  Z4 g& o2 e$ @
{
3 n: r- t- {6 ]        //-----------------------------------------------------------------
+ |7 y" E; {! @7 X        // Constructor" w# ~/ R, H) J$ {  I% ^5 \
        //-----------------------------------------------------------------
/ Y' ]& [0 H6 K        public ProgramCompare()
7 E& W( _9 v, g8 R        {
; X$ Z% o; i: E+ n2 O+ ?: C        }
0 i/ l3 X% ~  I/ y9 t6 S
9 R! `2 H! D1 O6 V8 U. G6 I        //-----------------------------------------------------------------
# C: ?6 K3 F8 {8 ]7 S2 ~        // Method for testing that class has been reached
% K. [* O. R( A/ J" B* h4 Y        //-----------------------------------------------------------------        ( R# B$ M1 U7 C( Y& ]$ Q9 s
% ]4 ?4 ]# L5 s  {: z
        public boolean ProgramCompareReached()         ! R( t% P3 X6 A3 [; W1 S* p
        {* i$ g# t* V2 c5 c( S8 G1 X: P
      try 0 |5 r* X# K6 T  ?( h2 W. ?
   {         8 C+ x  T0 i# L6 q
                       
& D$ p, P$ j( ~1 D, }                //********************************************************************# V0 V# e5 `+ Y- p8 H
                // Try-Catch Statement is used to handle exceptions - such as file not found
! V/ v$ P1 J5 j/ Y# o                // Reading the files will need to be placed inside a Try-Catch - just like this one!$ M' [- N+ C( M' R
                // For more information see page 534 of the textbook8 g4 y  f/ S7 x% C7 T) K3 k
                //********************************************************************9 G1 O, Y5 f; \4 b8 R' K. U7 Q' z2 g5 z
                    
' S# I9 `% v$ i8 G        }
( [+ i$ m* M0 R' L5 B* \- k# H% p7 b5 }             catch (Exception ex) // Exception caught here and message displayed to the screen 5 u% |2 x3 B' N9 V, }0 j
          {
9 O1 Y9 H: E1 o* V                    ex.printStackTrace (System.err);' X  G2 s9 r( d7 Q
           System.out.println ("Error message goes here"); // Replace this error message with your own          0 s" U# r" T* A! ^
        }0 ?: u! ]1 ~$ a- F
                return true;# Z6 R2 h5 n1 M# V+ k) ~% s
        }# j) {* g( C! S2 L) D9 d+ v
5 B$ G; q+ v9 `# w, ^$ M
} // end of class ProgramCompare2 q, m3 g& r% Y: ], C

, k" D9 D7 [  I/ G! J& q; v* j/ A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 s3 u+ H" M2 h//  ProgramCompareMenu.java    Provided by: DRS
$ M1 Q+ @: n8 w2 O0 I3 J. G7 t//
, Y2 H& I6 Z. r  _, _//  Calls AuthorisedUsers.java and ProgramCompare.java) `7 F7 v6 r8 }- e- P
//
, }4 W! m$ j3 u2 ^//  Driver shell for Assignment 2.
  U2 z6 d! N- a! J0 w5 F0 E//********************************************************************
+ h# X. a5 `5 {5 D  u+ O& _) s. o0 L3 r1 v/ e
class ProgramCompareMenu1 N1 K# Q/ f# O; ^; @
{' e# g& |' r6 R$ w1 C4 z
    public static void main (String[] args)9 z/ @# A$ t: w1 A( w' [* _+ S
            {
0 g9 p- x! d; V3 c) ^2 n! ]3 @/ d                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 u% z- Y" z( |; O                ProgramCompare reached1 = new ProgramCompare();
. K0 L1 V! Z; M* H2 q                AuthorisedUsers reached2 = new AuthorisedUsers();        $ K& m/ T* b9 @
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ t: P/ w+ J( i8 {- F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
2 W% y+ }8 x  K5 e2 @1 p        }
+ ^6 m; b! q5 o9 @) ~1 U; k}// end of class ProgramCompareMenu
" c& c: m" o* a2 T' A7 {, A. k+ c* Q* p
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 O* Y8 h$ Q2 w* Q9 ^  h5 F8 l
//          AuthorisedUsers.java          Provided by: DRS- m5 E- d( W1 n2 E8 Z5 T& c
//               
* o( Y5 @! |0 z+ h9 [" k% z- O//         Program shell for Assignment 2' q$ w& f( R; M5 d  a
//
: D& _9 ]" L( A/ y2 R) m9 ^4 D//         Represents facts about an AuthorisedUser( D0 H$ o2 ?# \8 c
//********************************************************************. @3 G1 Y) k! K* E2 {

. A6 G( \4 U4 W6 A' ]public class AuthorisedUsers& P; F7 y6 e) R
    {
$ m! [& D* F; n0 Y; f& v+ ]
3 q* U- h; K+ e. r" F        //------------------------------------------------------------------ V3 t0 Y; P- C2 S# s
        // Constructor
0 A: z& V5 v/ F  A        //-----------------------------------------------------------------2 S( Q% q2 `9 X, [: P9 V
2 s5 `" t0 n# v) F
        public AuthorisedUsers()" ~% `# ~* T" N8 ~/ ?- U7 G$ _1 q
                {  H# E; T8 X9 `) q2 ?( B- C
                }- {# W( G: {$ [/ E

6 I( y5 z8 g: v& D0 Q        //-----------------------------------------------------------------
' q- t  E% C/ Z- T4 v2 d7 O        // Method for testing that class has been reached. c$ x; v  o, A/ b! ^5 U
        //-----------------------------------------------------------------       
( v0 n8 ?4 R9 M4 V' r        public boolean AuthorisedUsersReached()
4 T" D# p5 Q# Q6 D                {' k2 z* o: p6 u7 b% ~
                        return true;                          q6 i) a/ N0 Y
                }8 S  E+ E5 z$ `3 K
               
% F9 P- O( y$ X, Z" r: q1 M    } // end of class AuthorisedUsers) \9 B! B8 @  G/ \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
. _- S8 V- _$ u- M* p: j  O" e, GShanghai - 2007, [1 D, c' {: ?0 X- ^; i3 N% h7 E1 r& i2 n
Assignment 2! p- u' c/ T& 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)
5 p3 c) S3 h, j$ S1. 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.0 @  L. @" Y: e! a+ g; U" M8 [1 ?
The staff must be able to:
+ w2 ^6 F$ g* y& S# F Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, v; l7 a4 n9 P3 U/ h1. 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.0 i) N% g/ r0 b' n
 The interface should provide a menu so that the staff can:- g8 @$ _& K  h3 P+ Z/ K. P
a) Enter the names of the two Java program files to be compared
& ^  W5 ], q2 J6 X# s: P. @ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 B, v' J. h8 ?- j** 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).
4 o" ?1 t+ Q1 q) G5 a$ CBSA104 Business Programming – 2007: Assignment 2
* J+ A  U+ o+ bPage 2 of 5
5 V% R" {1 M1 \b) Print out to the screen all the lines of code that are the same
7 I* R! J9 E) N" m& ?& R# h1 L/ Z# T2 R Include the name of the file and the line number of the code being printed for each of the two files2 {2 t) e. N+ O- }6 ~
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 ?5 c$ k& O( D1 f$ O) D" r/ D
 the name, username and department of the user
1 a+ f0 T+ c6 h* @! u  _+ h& x the statistics of the comparison
4 A7 }: X) \" C  T) X' J- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, @* @. G) K. k, t
 the recommendation for further checking; a& Z; y5 [2 m4 _* g
- 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& C) N7 Y' M  P
 the names of the two files compared! u3 D8 V4 T# [1 R0 C
d) Leave the program (exit)) Z9 N1 x5 k" ~/ I
The ProgramCompare class: (Total maximum 20 marks available)2 t7 T3 V( H9 n) A1 Y
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)" \+ ?/ y  n1 p
a) provide an error message if the files are not found or there is a problem opening them
9 K+ q( X4 R& e, I- S$ Zb) compare each line of code, X( [, m, }- p. E, q
c) print out the lines that are the same! y  r5 M) }* C' [$ ]5 o
d) count the number of lines compared / lines the same
9 R) J( W4 r/ g' K% nThe AuthorisedUsers class: (Total maximum 20 marks available)7 {0 k  c" Q: w9 L0 ^
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)
) P9 i( r9 W0 C. Q+ |4. Provide methods to:
! K5 o5 Y* ~# b- da) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match6 {- M- J9 J) E0 q; S8 f
b) return the name of the authorised user) R4 I7 z% a& ?7 x+ n+ Q) b1 g9 b
c) return the name of the department of the authorised user
( \0 m8 T  @( a9 W4 X+ ~& E- kIndividual Data (Maximum 20 marks available)8 Z2 H2 J# Z) G4 W# E  O' f* N
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.
0 }$ z9 x9 ~- ?9 hDocumentation (Maximum 10 marks available)
4 a" L. }: q3 F& f% N# F6. 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.
  x/ ]# \' G8 P, h. R1 n* PBSA104 Business Programming – 2007: Assignment 28 K  ?- b* E! J+ N0 l% U  m3 `
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 E. x2 i9 B( |' m$ ]+ Z不过你要翻JAVA的类库说明。你有下载没有?
; P* l* p: C, _3 |" K& I查询关于对比的函数。貌似关键字是contrast,还有compare
" p& u2 R& v3 U6 Z% Y
9 g  y* C+ M# U1 Y9 x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
  p# r( d$ P  g9 ]1 Q3 O痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! ^. b7 y* J$ W9 ]* I- A
可以下载到的 是 jdk-1_X_0-doc
' q  ~" k7 t/ i+ j) O1 @# ?
+ m) _/ n% @, C) t/ v; ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-30 12:48

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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