找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1817|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 X; f) H9 W( }/ {7 q ! h ]7 y! O) H, 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 | 显示全部楼层
//*********************************************************************. C0 N. M  Q# q
//  ProgramCompare.java         Provided by: DRS+ O, e$ U, H& G1 p
//
/ |! u% e) X2 x6 q: U2 ~//  Program shell for Assignment 2- U) V; q& v, c" M  p
//
6 L# J9 \, L9 M- i//  Compares two text files line by line7 S$ N! f1 g1 ?* [2 U) V) ]
//*********************************************************************
6 }0 K3 r/ b) \8 i/ L0 b) H. L) z* l, U+ I) @  L4 Y2 [' X, ]
import java.io.*;
1 C3 N9 F8 y; p! U& C8 G) m- b7 z+ N% {4 y. A
public class ProgramCompare
$ ]) |0 C* B' A) i: s0 q3 s; Z- ?3 r; C{
0 m5 b* q) ^% h        //-----------------------------------------------------------------
- a$ ?0 K0 i+ A% ~        // Constructor
: Q. y( {( U$ z$ w) k( A7 f2 S        //-----------------------------------------------------------------, V4 E. w+ x! h, g! B
        public ProgramCompare()
/ z* D( w% B% j: f4 J" B        {5 g: h! @7 }$ t, `2 Q7 B
        }3 S- C3 Z! r! ]# F3 {

) r3 [- F. e+ Z+ E# H# R  L9 T9 o/ w        //-----------------------------------------------------------------
1 I, H# N+ [5 H6 e4 H8 u: s8 W3 N        // Method for testing that class has been reached
# A5 j4 O  U: f0 s; B7 O- v+ u        //-----------------------------------------------------------------       
9 @0 e* S& G6 `% S$ t$ ~2 S0 s+ r5 J5 X
        public boolean ProgramCompareReached()        
! }) O5 t9 b3 i5 K% D6 d* v        {. I( A+ B0 ?$ i5 y( j7 U. m7 m
      try ) B% h  T+ y5 L: B( q) b0 m
   {         6 ~) p1 `$ z, {! }: N. S1 v6 V0 [
                        6 b4 p& W( s. Z, g
                //********************************************************************2 T! d. K' V7 c4 c# b  `+ ~
                // Try-Catch Statement is used to handle exceptions - such as file not found " E' i; _# y9 Y8 T5 u, m8 D. Z
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
7 H9 R0 \% x% H                // For more information see page 534 of the textbook
4 h0 T) w" K6 r                //********************************************************************
& Q3 L8 [* F% ~8 Q. P9 b# _                     4 i) _$ _$ \2 R# o' |
        }
. C* Z( ~. T7 k+ Q3 X             catch (Exception ex) // Exception caught here and message displayed to the screen ) F) A# q* A( G# r) u
          {
" o* ?4 F+ ~" _# k                    ex.printStackTrace (System.err);
! l( p5 f' F* M9 V8 f           System.out.println ("Error message goes here"); // Replace this error message with your own          + O# ]0 X6 B; c- }/ g
        }3 n4 N& t0 D6 Q, v( V8 `
                return true;
( V& w; Q0 [7 g" q! ~9 s" h* \( _% C        }
9 B( @( z9 O8 t& D
+ L* a' D$ X% r& T} // end of class ProgramCompare; K, a3 V5 B+ ^* R

* M5 e4 @0 q/ A# ^3 e3 ]- I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
0 S, b8 D+ x) s! B' o; z3 ]* \8 Q//  ProgramCompareMenu.java    Provided by: DRS: Y) w5 J+ }; M3 E
//
. f5 [; L) O1 [# k: l//  Calls AuthorisedUsers.java and ProgramCompare.java
; o8 |# [) i9 p//' I  B3 f% x5 s
//  Driver shell for Assignment 2.9 z% D* S# v6 Z9 ~  d
//********************************************************************2 U$ R, }2 B" n# ?8 {# W
7 k0 w0 d. Q  I% r% r# G
class ProgramCompareMenu
( D+ t% L4 U+ B& ^& J9 X9 Z0 E$ a; X{
3 P/ W( h2 r1 G1 [8 ^    public static void main (String[] args)4 M3 L1 N* `9 U* ?# x
            {
1 h% R( y. g8 D2 g0 f6 z; S1 G                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable% D6 l& O( O0 S
                ProgramCompare reached1 = new ProgramCompare(); ! z6 Z  Y  K6 w: Z$ Z$ C
                AuthorisedUsers reached2 = new AuthorisedUsers();        3 [( h$ a% z% t$ S' O5 A
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 I( H' R9 z7 ]0 D! X% O' \( _- z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" r1 x6 ~. @. r" q8 R2 l! J; f        }4 O" K% b) w6 D
}// end of class ProgramCompareMenu. z, B6 e: K7 ]+ [' ^4 |6 i
, r+ r5 c2 A* t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" C2 c( E9 B! i5 Q+ N/ w! W! B//          AuthorisedUsers.java          Provided by: DRS) x; M0 l; S1 c, |, L& Y
//               
6 p- ]+ Y" G, f9 f! i( G) Z//         Program shell for Assignment 2
% _; F/ u1 [8 X7 g4 R2 E//  Q6 e, }" e8 `! R* k
//         Represents facts about an AuthorisedUser: [9 q: X3 B6 B( U/ I3 R( R
//********************************************************************! p, o- A$ l% |* D" w' o' S  ^# ]0 h( J
. H7 y! T1 O( D3 I! ~- u1 i% l) q
public class AuthorisedUsers% Y9 t3 [, s6 n! K5 d" K  M
    {2 e& _+ T, {3 A( R0 R

4 t" `2 [6 K5 z3 @. [6 C        //-----------------------------------------------------------------, g. ?! w; y! v5 |4 [
        // Constructor" f3 R+ T* e" U
        //-----------------------------------------------------------------( c; n6 }2 n* Q0 {: A

( m& p6 B+ c' k        public AuthorisedUsers()
! H' P. A2 u+ L6 ?" O3 S                {
' k4 k, W% M, |( U2 X                }$ G. a$ f' {3 O8 m

6 ^6 |2 `1 |3 s7 v2 R  C        //-----------------------------------------------------------------
' Y% w4 N$ k  t  s& O" @/ T        // Method for testing that class has been reached
; c. \" N3 m+ Q6 s# g" O        //-----------------------------------------------------------------       
7 \1 Z- |+ ]# F" [, F1 `$ z        public boolean AuthorisedUsersReached()
; F4 v! b% E6 H& ?                {/ t& K9 u' Z8 I; ~9 R! G4 o" D
                        return true;                        % l: i% Q- _, N/ _3 U
                }# d9 V  a2 W% Z# M4 a
                " \# e4 U# B. ~$ H( z, [) N
    } // end of class AuthorisedUsers
8 U1 H6 z) f# n7 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 Q+ S" [* @( ?4 {) C- y1 TShanghai - 2007
0 {2 [: X  F2 v- {* K# c# {! IAssignment 2/ H' S+ F/ o, t
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)
, Q- r' f/ i9 g- n0 W/ p% e1. 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.- a- P! h' e( ~1 h: K4 p, J: V
The staff must be able to:
1 k9 r! _# {9 x0 K, i; L Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ \$ v' Y1 Z: g$ ~1 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.
  g( i! u& t2 \" ` The interface should provide a menu so that the staff can:, o6 e9 t5 ^6 L* n
a) Enter the names of the two Java program files to be compared+ ~: l4 ?* e5 p3 `0 R. R
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 H0 u5 T) X4 G, y( @- y- A
** 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).
+ O$ ^* o% B6 l: w7 lBSA104 Business Programming – 2007: Assignment 2
0 [& r  P+ V" jPage 2 of 5/ m4 J3 J& u# ]+ ]& q3 M/ H7 b: Z
b) Print out to the screen all the lines of code that are the same# m( L9 R1 B1 u* u: D2 t* \
 Include the name of the file and the line number of the code being printed for each of the two files9 m+ A. f9 a2 F2 O0 |; V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 r! c! ~; ?4 h/ t) S& S) E3 t
 the name, username and department of the user% o  T& _. F  M) W+ i0 D* I
 the statistics of the comparison
7 K" J6 _" _& ^; J# M7 B- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different5 J$ K( @' I( F+ `
 the recommendation for further checking
' H% N5 K1 b# a1 |' H# b- 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' z, s+ ]3 z; z/ p3 w( Q
 the names of the two files compared1 t. z( V3 I/ K6 I# Z# T1 e& P+ a
d) Leave the program (exit)
" J0 G. @$ ^7 O3 b2 o$ JThe ProgramCompare class: (Total maximum 20 marks available)+ T" K  E  I$ `" ?0 L* B
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)- l/ `* a8 N4 r+ [" |4 a# u* N
a) provide an error message if the files are not found or there is a problem opening them4 c1 O7 c# y/ U& }6 J/ v! d# }* w$ y& J
b) compare each line of code
) g! ?+ ]' M- U  u: t  k, hc) print out the lines that are the same- B( I7 K% f1 w( ?! f" c) Y+ `: S1 d
d) count the number of lines compared / lines the same- M: {4 |6 D8 U- _0 \$ z. \
The AuthorisedUsers class: (Total maximum 20 marks available)
; z0 t  j! J. k- G3. 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)
3 }3 G4 K6 K! n& b$ m: I% h0 J4. Provide methods to:9 [1 u1 q3 j% h
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 match6 r, V# m/ `7 Y
b) return the name of the authorised user
: b. d# r% W; k# h" nc) return the name of the department of the authorised user. i" z) Z+ x' T+ _& S( X/ `4 Q4 W
Individual Data (Maximum 20 marks available)5 b3 U5 k+ T3 T1 c
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.4 N5 \# _+ G; r4 w/ V# w9 J2 x
Documentation (Maximum 10 marks available)% n) d' I# J3 n) O6 t$ ?! \5 E
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.
' S  u6 X! D& d# a' L8 M5 h  BBSA104 Business Programming – 2007: Assignment 2
; V- H% x5 c% e/ C6 b2 I: wPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  Q+ v& l; |& X$ y- T# h) Y- i
不过你要翻JAVA的类库说明。你有下载没有?" P6 c; t. l: u4 v
查询关于对比的函数。貌似关键字是contrast,还有compare/ f' l# G: @+ I. L: n, `
+ a! _! ?2 r( [, |, O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ h. L# B' w+ C3 I% Q痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。& }0 ?: \9 K* A% L: V0 l( S2 x
可以下载到的 是 jdk-1_X_0-doc
0 H6 ^- U/ |7 j- U+ W+ F9 H
3 m/ H( `4 u/ q! [- p. u+ |# q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-12 15:00

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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