找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1320|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急/ Z( D- ?# V: z+ @; p& _6 I+ G& ? * A8 r- G0 C/ s
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 ?- H* o; M1 q
//  ProgramCompare.java         Provided by: DRS& x, u# m7 f  }4 k7 }5 r( e
//5 f% t& U- z, W- V
//  Program shell for Assignment 2) Y' |, \6 r* V! |9 p  b* B
//8 r  ~# v% Z4 p2 L
//  Compares two text files line by line3 M* S7 {9 O7 ~" L
//*********************************************************************
! m8 z# N" J5 ?  v- A. ?" }+ G0 i8 _; v7 k
import java.io.*;
4 k( A' J( r0 ?. K( K1 j7 ^" b% ]/ d5 w6 R
public class ProgramCompare
0 ^" {- w- K; g( U: L0 V) X8 K. g{
* \% H' v$ C8 H* U; h        //-----------------------------------------------------------------
' H; I1 L* V4 t2 d# n2 [! o" |        // Constructor
: R4 L) F6 p! _# ]& m7 z7 T        //-----------------------------------------------------------------
$ C" C% C: v1 |* g        public ProgramCompare()
/ }3 R( q/ d) F5 a( v" i' ?        {
* U+ k7 E+ M0 H, u        }
$ p" X, r4 R/ i$ P7 K4 F5 U0 N
/ j" s% q5 }' w* I- m, H9 }( b        //-----------------------------------------------------------------9 \; ?" }( Z' k
        // Method for testing that class has been reached
  V' G1 b# [) z, t' y; m* y        //-----------------------------------------------------------------       
1 u. l' w9 {9 @" k1 L* `! w* |
1 C3 T3 Z) e# `5 Q+ i* `        public boolean ProgramCompareReached()         ) {4 Z3 t& x  }1 s2 S1 g7 f
        {0 A, g" n: [! E0 a% Y* ?
      try
( Y% r6 C4 o7 }3 p' X   {        
! t. E) _; s+ ?                        + x: Z. w' o/ M6 }6 @* U
                //********************************************************************9 _4 P0 e- t- d+ V; H
                // Try-Catch Statement is used to handle exceptions - such as file not found * k" S5 w* j; t+ p* K5 N  n
                // Reading the files will need to be placed inside a Try-Catch - just like this one!( c- v7 r5 N3 A3 Y+ N' v. \2 e) e
                // For more information see page 534 of the textbook
" p8 K$ L/ X# |9 z                //********************************************************************9 x; ^+ m# J6 V" r/ v
                    
0 f! z# a/ X( V1 u* Z        }& @6 m8 M( n1 g1 u$ O5 z
             catch (Exception ex) // Exception caught here and message displayed to the screen " ]4 O2 M* i7 z8 y$ ~
          {
  e* M2 E5 r6 N8 U, ?5 {  k                    ex.printStackTrace (System.err);
* ]& p* F4 _1 Y           System.out.println ("Error message goes here"); // Replace this error message with your own         
# m7 }' |% M: F$ g  S9 [        }" A, `" j! r8 z/ U
                return true;4 `: ^+ N1 t8 \$ l
        }
" @- K0 u! n1 {  `4 x0 \" O& V# k. m1 a4 l8 V- o3 Y6 Q1 v2 Z
} // end of class ProgramCompare5 P0 W" l: B$ a& f& L
( ~) N5 l- T( d( a6 y/ s1 g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! \% x- p; T. k9 r6 {- K$ n
//  ProgramCompareMenu.java    Provided by: DRS
6 G$ j+ q+ L% Z2 d//
: t' v; N; w3 z" _2 l0 ~; m# b//  Calls AuthorisedUsers.java and ProgramCompare.java
# Z; s" }3 F+ n7 M+ R( \1 q//" E8 h# `- k. G* E% w( X2 N/ r' i$ M
//  Driver shell for Assignment 2.
. u; B$ @' M9 k$ E$ S//********************************************************************0 {  e) A( ^$ C# I+ p, z3 E
, q5 b* j  T" W8 E$ _  W- t
class ProgramCompareMenu
& N9 x. d$ h$ N9 l{
  x7 y5 {' ?/ L) S5 K5 D# J    public static void main (String[] args)
- w# U' m, a, g1 ]. N% J" v7 w& E            {
) @- B! V7 f% o* g6 V1 t                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 |7 E) v+ |- Y( n                ProgramCompare reached1 = new ProgramCompare(); ! _) \1 g' Z5 \# z' i) R
                AuthorisedUsers reached2 = new AuthorisedUsers();       
& H4 x& ^+ C9 k4 V  _/ \( r                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 Q( [. }* F) _$ w5 j
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; E7 A6 y1 c7 j& \. Q+ l" q1 ^( |1 D        }! p) t* T8 x1 a1 g
}// end of class ProgramCompareMenu
8 A; S3 Q4 p% J" C
/ X9 Y9 B9 I! a4 a! V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 s8 s. t: B; }
//          AuthorisedUsers.java          Provided by: DRS$ I' U" S: z4 i& C
//                  f6 q' @8 f) N/ I  P0 @
//         Program shell for Assignment 2
- i) M) O, v1 {7 p2 L/ J$ I//
8 `' ?- h% K, V; j/ U! n//         Represents facts about an AuthorisedUser: J- n3 d& m" Z
//********************************************************************4 F1 Z" B; z7 p5 q9 \1 d  m& z

/ J3 L1 s3 ^! C) E- epublic class AuthorisedUsers
1 e4 ^5 z- |  Y3 i3 O    {
9 ^4 J8 z7 W6 _. s* c
9 ^/ P; y& m; a2 ]        //-----------------------------------------------------------------( Q2 O& s8 V" v6 c. V. R
        // Constructor/ X: D% H( ~, t% |+ b! d0 X1 X
        //-----------------------------------------------------------------
2 @- ^+ l& d! R+ }  @1 d! X* p* C7 o7 F% S* V5 p$ \
        public AuthorisedUsers()
& }# w' t: Q; N) w8 u                {8 F! _! `" `$ o4 O/ Y" {' g& t
                }
6 Z9 D( f' l+ j1 w  t% t) k  `( V5 W. T* z
        //-----------------------------------------------------------------  Y& x7 p) O  J' ]9 t/ X
        // Method for testing that class has been reached
* u( n1 i  s9 f' F3 \4 f. i        //-----------------------------------------------------------------        7 T6 H4 G8 u( k2 W
        public boolean AuthorisedUsersReached()
& ]8 k5 w2 t: j! z0 ]2 }                {: `$ K/ P6 ?1 k2 e/ {0 G1 f
                        return true;                       
% @5 j& j) {: ]" P                }. U- z3 L* f& x% J" L% K" F9 L- W
               
* L+ R7 w% d- \    } // end of class AuthorisedUsers
, \: K3 V) C2 q6 \+ I5 t2 N% m0 d//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 a! A* o$ o( A
Shanghai - 2007$ V, z. R+ O2 l2 q. Q. d
Assignment 2
' ^) ^; a; K# D& y  i) }% k- u7 sDeadline 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)! c6 a- o& r. t) g
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.
- l, [0 l6 y# e( U: |The staff must be able to:9 M+ ^8 i  V/ j1 O8 f8 `3 o
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 Q' i3 i0 \; c' ~: _1 w4 G1. 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( _5 T4 Z/ `! U8 v The interface should provide a menu so that the staff can:5 N% j& _! M. z+ J
a) Enter the names of the two Java program files to be compared
3 `9 h2 m/ }, U5 c For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 x. I/ d) R! h' M& d
** 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& p( d/ n8 i( [* p5 _BSA104 Business Programming – 2007: Assignment 2
4 w% `" {8 ^) `Page 2 of 5
0 L& Q* {6 i) J# p1 s( j% O. X: Ib) Print out to the screen all the lines of code that are the same
% F8 I% Q* W3 i) ?$ j# ]: x Include the name of the file and the line number of the code being printed for each of the two files
! W+ Z% W$ K5 A+ qc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared' \4 i* n* Y2 ^7 b) X' W) D
 the name, username and department of the user; X1 d3 Y+ r! P; ?
 the statistics of the comparison" N0 x' ?- U& v/ A/ O
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different( V# k" v, |1 j! @' @$ \7 ~
 the recommendation for further checking
. z8 c# s' f6 R( t6 }- 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" Q- u: m: ?3 ~" ?) y
 the names of the two files compared8 ]6 {2 ^8 x( V4 A( i/ q2 B
d) Leave the program (exit)
7 o8 p0 y9 D% j# t( qThe ProgramCompare class: (Total maximum 20 marks available)
" d7 h8 \9 z6 M& V2. 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)% i  a# y/ R  P: s
a) provide an error message if the files are not found or there is a problem opening them
  ?( k4 K, {! o. {% Gb) compare each line of code
( u: [% {9 {$ W1 Nc) print out the lines that are the same" ^  g* l- O0 M" O' [; M6 y8 E
d) count the number of lines compared / lines the same* h' I) c" F2 e9 o( p) C* @1 k' K
The AuthorisedUsers class: (Total maximum 20 marks available)5 s. d& |0 E* J8 M
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)# v5 d+ m$ F  |8 t
4. Provide methods to:
0 M' X! |% Q. f! i# x3 ^! Za) 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
- @# S- `. q" S, _3 d; o( A! @) t7 Rb) return the name of the authorised user8 \1 }! {9 L* V7 q% b+ Q
c) return the name of the department of the authorised user
7 \7 ]4 s0 r" N+ gIndividual Data (Maximum 20 marks available): S0 K' @# U: h( X% y, q' @) R
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.
/ Q/ Z" J, Y/ D1 mDocumentation (Maximum 10 marks available)
6 D- d4 y7 w! R( ?+ f  i6. 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$ m, A) }( U" A0 ?, D
BSA104 Business Programming – 2007: Assignment 2
7 u- \7 n7 d! ^8 l4 R9 XPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 z- u9 m/ i: h/ c: x- b+ y( Z不过你要翻JAVA的类库说明。你有下载没有?+ m& N: u; z' {% T
查询关于对比的函数。貌似关键字是contrast,还有compare
  j! [  {, j8 y9 N% o: h. T
/ w- v- j- I6 e0 |9 T[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# n6 }6 w" l; _/ f$ [  R( F* v痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ r$ x# H4 T9 T) N- d# v! t
可以下载到的 是 jdk-1_X_0-doc
* f8 A6 m( H% U+ n  a$ O! @
5 W* }% e* D5 a& t$ f% @( k[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-28 10:26

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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