找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1053|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 % C( o& | s+ e; b1 m7 E# l4 `( x9 C" T6 Z8 h* b
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
  L, V. o! m; l//  ProgramCompare.java         Provided by: DRS) `6 y" j  C' h! b) M1 h  {& u
//
0 _* s: D) M' R, q2 F& V1 n! D9 [//  Program shell for Assignment 2( _+ d8 M$ L7 w3 L9 n8 o4 e. E/ l
//
: H0 L) `; |2 n4 ^//  Compares two text files line by line
; E# `3 D+ n& p//*********************************************************************3 I. N3 T9 c. u
0 _& i# E( x- B4 T9 m, M, ]! h
import java.io.*;
  e# q# `/ X8 t* J( w) c4 y2 o8 ^2 R
public class ProgramCompare4 f$ y8 N$ k$ |( Z) {
{
) q9 A; {/ Z/ e& O" K        //-----------------------------------------------------------------% n( L5 s1 S$ P( \4 Z( P  x% i
        // Constructor' E, a) y4 p7 C. K! ?
        //-----------------------------------------------------------------: o, |" n) {1 ?% y
        public ProgramCompare()
: k* U) i- w: N$ B        {
/ `4 V" d: Y% H! a8 s        }1 F2 w: z* D0 z4 n- u  t" c4 t

  _; z4 U8 c. J! d/ p6 X2 a        //-----------------------------------------------------------------) ]0 A7 `1 _: t# T9 @( X
        // Method for testing that class has been reached$ u, |7 C9 y1 N- _1 _$ d' p
        //-----------------------------------------------------------------        ) _6 M$ U3 }6 Q

% t. o8 m, ?2 V6 I        public boolean ProgramCompareReached()        
0 q; t' H3 R3 I, w& @        {
' o4 H! M% D3 C9 o5 i8 X      try ; q6 L3 F; o. E! N5 {
   {        
6 X$ ~$ }3 u: M                       
8 r- ^3 i4 d* ~3 R5 ?                //********************************************************************  K6 a. i, ~) y: P
                // Try-Catch Statement is used to handle exceptions - such as file not found & u. _2 a8 G5 @  k( X6 Q5 M
                // Reading the files will need to be placed inside a Try-Catch - just like this one!, i; M) d2 W, g$ P# {
                // For more information see page 534 of the textbook6 z+ W! b+ ^' I. y1 F! r
                //********************************************************************, Y1 \2 b' p% Z+ n& R
                     8 G3 h" g, Z6 V
        }
0 J0 @2 I9 Y5 \0 T) c4 A! \             catch (Exception ex) // Exception caught here and message displayed to the screen
0 x, v3 ^4 U6 _( n' G1 D- ~+ Z          {+ Y; r) @6 u7 @; T5 V7 U0 {
                    ex.printStackTrace (System.err);
6 i/ t& i& ?( @           System.out.println ("Error message goes here"); // Replace this error message with your own          $ O' Z# L4 ^  M1 C- V" k
        }5 s; n( f! c6 b' I
                return true;
8 I% C0 ^7 X. V+ j! j        }: h, i. q) y) D% u# z
* B/ S  f4 b6 q% _
} // end of class ProgramCompare
1 s4 j: H9 z* v$ d! x) @" I0 q/ g0 N/ |; s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! K; f) u& g2 ~' S4 i
//  ProgramCompareMenu.java    Provided by: DRS
( }% t. m! K+ b0 ~! t//! c" K6 F( e- ]! U5 w5 p, x& @
//  Calls AuthorisedUsers.java and ProgramCompare.java: o0 R' [! Q+ |# L8 }# u$ u* ?$ z" L" }
//
# R3 r* \( {' x$ P9 j+ U$ Q5 I//  Driver shell for Assignment 2.
( w. X; |5 \" `9 T//********************************************************************
( @$ \8 c; D) ^( S
; y. j' F* l$ ]6 Tclass ProgramCompareMenu
; Y; [1 a. I3 R+ r{' g8 _& A  Q# B  V/ P, R2 v# V4 N
    public static void main (String[] args)
8 E! O3 W0 N1 S" n8 Q3 R1 d            {
( j8 T7 V. k& {$ M                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* O! c  [8 c( @: O8 [  V9 Z! n                ProgramCompare reached1 = new ProgramCompare(); & e/ k" p, P# W* E1 Z
                AuthorisedUsers reached2 = new AuthorisedUsers();        # B% D6 f  `" W& ~" L4 \& ~
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 ]4 d( r  ]% l/ [' {( c                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 b- f' }0 i+ c, {& m2 \% ]        }
5 e2 a' F/ s6 z# {( k" ?}// end of class ProgramCompareMenu* O- Q: Z6 @# q+ n4 ^
  o; }2 Z+ B; p8 D' N* I* Q% I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ ^2 O+ P% \7 S- b$ x3 M
//          AuthorisedUsers.java          Provided by: DRS0 c  x- S* R8 ~( E
//                ; R) B: D! z) F- W$ r) C
//         Program shell for Assignment 2
8 I) v- n$ p% n. Z* P) y! f& h//+ R8 ~& S/ N3 h6 y* ^
//         Represents facts about an AuthorisedUser
) K6 U0 s/ }' E8 \; i6 Y$ R) |//********************************************************************( S  |4 ~6 }; k% P

+ r1 E2 X+ J: s& Xpublic class AuthorisedUsers- W% @$ o" s' o1 ]5 N
    {
- o4 m5 K7 p  l  W. X4 S6 ?+ Q
  t  z; s+ V7 t) l3 {: [& ~8 ]: Y        //-----------------------------------------------------------------
, |# _2 y( c2 T        // Constructor1 t: r0 R' q7 I$ s
        //-----------------------------------------------------------------
$ T. _0 }9 C/ h8 U% T9 E) V5 U# i- u
        public AuthorisedUsers()3 X( P5 n1 q$ Q# N
                {
$ ?0 {8 m6 V6 G                }
8 |/ A- V7 T7 A8 `6 K6 l" W2 U7 D: y2 {5 h4 T) |/ r
        //-----------------------------------------------------------------  o7 j" h4 z% [5 ?/ m
        // Method for testing that class has been reached
1 U7 n) X+ Y! ?        //-----------------------------------------------------------------       
& ]4 f8 \) y, k- y& q" J' h        public boolean AuthorisedUsersReached()' m+ T7 V3 y& P. _9 o: r) Z
                {# j. q9 G, V4 ^
                        return true;                        / D1 S; g3 U/ Q% n$ l
                }/ {8 X6 P* @( o% A
                % _, z9 P3 K; X  f0 m  h+ L
    } // end of class AuthorisedUsers4 q& V7 Z( }+ D* o+ N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
$ j# D6 g& B: t& J( AShanghai - 2007
: f0 R, k2 q' q. Z' ^. v- AAssignment 2
- ~7 s8 S# v6 p/ e8 i2 H6 M/ H  `9 G+ UDeadline 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 X; _( e0 _3 m1. 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 A/ e7 Z0 H5 Q! G" I  ?/ c! a) T0 B: eThe staff must be able to:
: Z# l$ F' U& V1 m% k. V Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.: l- |9 g7 h0 h! a' p
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 z# g+ i5 Q9 k9 I9 A: ]: E The interface should provide a menu so that the staff can:
2 G0 Q. w2 G- G" ~; _a) Enter the names of the two Java program files to be compared4 c3 ^) G4 f( v" E8 i  i8 E5 b
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( {7 f* c+ \; C' M9 j" t* P0 E
** 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).
' f; I" f0 |' K$ U( e7 sBSA104 Business Programming – 2007: Assignment 2
& H; M4 e' y$ d* ^& s" Z4 VPage 2 of 57 k7 O* A% r7 ?: @; v4 B/ H2 g
b) Print out to the screen all the lines of code that are the same4 ~& Z" c1 v% o& m
 Include the name of the file and the line number of the code being printed for each of the two files6 @3 _$ Y0 r  Q" v, D4 `* `. ~9 B
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! q  w# M0 `( n the name, username and department of the user6 ?7 }' o0 g% m8 ]4 i
 the statistics of the comparison% @" w/ p' l/ L
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
0 ^. |  T7 x4 {7 y  l' @" `. ^5 b& f the recommendation for further checking8 T( Y! D# B& J2 A
- 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 closely1 e2 p' f0 U. d3 d9 ~/ [: U
 the names of the two files compared. O7 {+ x, j/ ~( s% S/ R
d) Leave the program (exit)
& Q- N3 o+ L; x% ZThe ProgramCompare class: (Total maximum 20 marks available)1 j( J* S( M3 Q* ^
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)0 M, h5 Q9 }* h0 V
a) provide an error message if the files are not found or there is a problem opening them
1 Q3 m& n+ [6 L3 Y' ab) compare each line of code
  z& i0 Q0 p. u  Jc) print out the lines that are the same- U2 z, ^* ~3 q
d) count the number of lines compared / lines the same  j# p7 R6 @; _
The AuthorisedUsers class: (Total maximum 20 marks available)% R* f# l% \/ C0 {6 R8 J9 L5 N. 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)
5 W4 [! W. E% D2 j7 X4. Provide methods to:
* M  K. e$ J2 [& h5 Ma) 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
& D: r% c9 S4 g1 Y+ ?; Q7 e$ ib) return the name of the authorised user
7 a( D( K0 Z8 q2 U* j, H9 V9 Gc) return the name of the department of the authorised user
6 z0 g+ [5 A% ^Individual Data (Maximum 20 marks available)1 Q! W7 b3 e% Z6 U8 l
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.  i8 ]0 E5 I* L! L" s5 P+ F, U
Documentation (Maximum 10 marks available)+ o& [' a9 s3 O' I; X- h0 S
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.  m1 s5 }( l+ \
BSA104 Business Programming – 2007: Assignment 2
( V1 B! G( S1 B) S0 T9 hPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ h, ^; H- L* Z' _* \
不过你要翻JAVA的类库说明。你有下载没有?- V3 \, U- Z9 X3 a/ p
查询关于对比的函数。貌似关键字是contrast,还有compare
. H; ]0 Q5 t" ^; o2 H
1 d& Y5 \% S9 q( u" g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" N" A6 [, J, [5 R2 ~; F3 ^7 N" F1 t
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。6 q5 x( a0 U; I, t' `5 b5 Z
可以下载到的 是 jdk-1_X_0-doc
$ a9 y/ v5 u: E% X6 W) ^  o' _( T/ ]: X) L' O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-15 12:48

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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