找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1480|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 a# V% [) w2 \) f& O3 O3 Q/ g, p* v0 G' }0 ?( \) n% y( i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
# q/ K2 b* D9 U" i# {$ f//  ProgramCompare.java         Provided by: DRS" s) y) a3 a% N: E$ N
//
2 a, r' `: T  P+ A5 ?, Z% o//  Program shell for Assignment 2
$ [8 ]+ s$ u5 d//! S3 ~' G, k& S6 B
//  Compares two text files line by line5 E) u1 d4 H9 Y. `/ G
//*********************************************************************
: ^! j3 _  U$ X" E; E: d) E( V. D  r2 H
import java.io.*;
* x) |  k* g& z- X: @0 X$ B& Z) \( W# o# v
public class ProgramCompare
  ^. I& ]. \) Q! m5 X{  y  T6 h8 [3 V+ V- [2 R
        //-----------------------------------------------------------------2 _/ T( n0 F0 S! Y
        // Constructor
! j, j0 k3 L& J3 M/ O4 }3 q        //-----------------------------------------------------------------5 {4 y; u8 Y6 I7 I- f/ ?
        public ProgramCompare()
: j# ?6 A; B4 W) W1 i! E        {
+ k9 Z" a$ j7 w. ^# L        }
! h! ?  _( d, w5 d  q3 r6 n
' t! Z! C; W. z2 Q/ W% [4 J* o        //-----------------------------------------------------------------& o2 U3 P5 _" Z' F5 B; B0 K7 _
        // Method for testing that class has been reached1 Q0 P2 Y/ i" \- M
        //-----------------------------------------------------------------        9 v# P6 G7 w$ D2 p/ r5 A

! n: Q, u0 s$ @# `4 Y        public boolean ProgramCompareReached()         5 m2 m) {! w4 f5 S( Y: k
        {. ]+ q& R8 y7 {; T
      try
3 {' B' _) O3 K5 `/ J% d. `   {        
* A( h0 O* J& }# t' [                        1 w9 i* R) I1 \9 R/ D' A3 c: L: u& U  {' v
                //********************************************************************( k: r5 [/ E6 q+ G
                // Try-Catch Statement is used to handle exceptions - such as file not found 0 @3 h1 _9 r- E9 L
                // Reading the files will need to be placed inside a Try-Catch - just like this one!% u' W7 C% v7 ]
                // For more information see page 534 of the textbook
, I- h- Z  c% \$ z" p: j* U                //********************************************************************
* S  c7 j( I. R) U                     ; N, ?) z9 ^, E( u. Q1 K
        }
- V8 Q  K" p/ n: o. W# _             catch (Exception ex) // Exception caught here and message displayed to the screen
7 H# ~0 ^( J! I% U          {
* N( X0 s- f$ ?; w, g                    ex.printStackTrace (System.err);
: }1 o2 `5 Y% P           System.out.println ("Error message goes here"); // Replace this error message with your own          6 m# f! }& O, I) T
        }
8 A# {" o  N: N                return true;
% P8 ^9 Y( P) G, W        }
2 t- M! c7 T9 q& o& e1 ]7 d, m0 Y+ H/ B3 {" p1 [  ?8 C* C* j7 e
} // end of class ProgramCompare
# U# X' t* k$ T- T/ F; j0 N4 z& J0 ~7 w. I0 B. s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ S" U8 S; g& p% f/ y//  ProgramCompareMenu.java    Provided by: DRS( c/ b; J& Z4 H! c& E! |7 s& o
//) }, r! s( a0 O  C+ v/ j6 f
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 _3 ?# \3 D2 Z8 p//9 ?! P) D# N) D0 G
//  Driver shell for Assignment 2.
4 H' e! O0 K5 x- p1 c0 N//********************************************************************( }1 i% q; e& v+ l1 H- m

8 i6 u6 c! [+ l: G2 O' |9 V2 Kclass ProgramCompareMenu
9 Q1 A4 V, U9 R0 k1 x$ T* k{7 p$ x/ z# e6 c7 M5 m
    public static void main (String[] args)5 R! a( O: N) l. u; T) s
            {
6 b5 @+ U# W" [% N7 J                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
( w2 g! f6 ^% Z" L" c7 u                ProgramCompare reached1 = new ProgramCompare();
3 s1 I& v+ X' N4 \* u5 ?                AuthorisedUsers reached2 = new AuthorisedUsers();       
" L' q9 R9 X0 r                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. S/ J% s) R. V; s0 q9 J5 y, I                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        % l7 W3 x9 N( Z! u
        }; k! X9 t( {8 M; J0 X
}// end of class ProgramCompareMenu$ g9 O) O1 V6 x

6 t  f% k$ d9 H+ U2 D& C8 H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
* l' s  N0 G/ p  `, w2 l' Q//          AuthorisedUsers.java          Provided by: DRS
4 t$ g0 E$ E$ M+ E- v6 k. Y4 C/ x//               
, h1 E0 L" g- y9 j4 W& |//         Program shell for Assignment 2
) A- B2 k" B2 X2 k- @//! C% `& C- l1 K. }
//         Represents facts about an AuthorisedUser
4 {) B( N7 o1 ~3 C: N//********************************************************************
. W% ~3 r; U1 }- g
0 \: D$ s& W7 V" qpublic class AuthorisedUsers
7 u. e+ f% L9 l/ |6 o9 V    {. b2 h5 C# X. T3 b  y, U( h/ u1 s

$ B# ~/ l9 ?5 f0 F8 u' q) }# j        //-----------------------------------------------------------------3 O  j3 `7 O& G4 W3 s$ E+ ?
        // Constructor
: k: f) D4 ^3 n" h        //-----------------------------------------------------------------4 T8 g- t* J! x

1 N% W1 c1 o& V% N        public AuthorisedUsers()) Y- ]& B1 f: S- X
                {3 A& G3 ~- y  p8 U* v5 s+ v3 a9 v
                }1 N/ p2 S9 }- K7 a  ^, Z3 T
, e9 H* _& o- _* H5 l2 Z9 d
        //-----------------------------------------------------------------  F7 t8 J. G/ U4 M& Z
        // Method for testing that class has been reached
/ C! a1 S. j, R% f% _- w3 }/ a, E4 j" C        //-----------------------------------------------------------------        " ?  y: [$ k" H. p) M
        public boolean AuthorisedUsersReached(): _' o2 J+ b" V
                {
1 R, J  G' ^5 s  y, y                        return true;                        ! A3 T, J" w; A7 c0 I; D; k
                }' H6 p: J- M8 k- w+ C
               
' b  F8 E2 w3 O  [* R2 j    } // end of class AuthorisedUsers
9 I  e" M' d0 c3 U4 y3 p% ?' F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 {1 R+ g/ Y  \- |1 q9 S: Y  Z4 DShanghai - 2007# U- N! K/ {  a4 x/ F6 Z
Assignment 26 g  f- Q9 H( U3 L0 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)! W, F8 D2 R3 w2 G- U7 t
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.5 h# {/ ~: x8 Z4 c( h5 r4 H
The staff must be able to:. b6 V* Z1 {/ l& e# J0 {2 E3 q2 j+ w
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  {4 h* U: [+ Z6 T1. 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.6 d* N' }1 w' F% T
 The interface should provide a menu so that the staff can:
8 W; |  r# C9 @2 y+ ~+ V: wa) Enter the names of the two Java program files to be compared9 H4 y2 t9 h0 l; k# j
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% a# n0 w- Y0 N$ a. A9 L
** 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).
3 M0 t6 |7 a9 nBSA104 Business Programming – 2007: Assignment 2
/ _2 s% ]3 o! N- h0 d9 pPage 2 of 5% M5 ^5 o* ~5 u! h* s1 @% U' R
b) Print out to the screen all the lines of code that are the same
) w& h* C- {( t- T' g6 a; `, } Include the name of the file and the line number of the code being printed for each of the two files" x" {+ \; z; b- S
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ G5 u0 H  K' M& n# v5 S& U
 the name, username and department of the user
) E3 h3 N0 A; r$ {7 } the statistics of the comparison3 I( J. F" o) v+ Z+ k$ p/ d
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different- g5 {% b3 k9 g) o. |! K
 the recommendation for further checking  l" X( Q) _& t% w
- 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
! g) J* O6 w; f- a. L; r2 B. {  H the names of the two files compared6 e9 D2 L) L5 J& x
d) Leave the program (exit)
: e% Q0 M0 N  x5 v! m1 [9 N3 q6 kThe ProgramCompare class: (Total maximum 20 marks available). e. t" ~( v" W& U% }0 w6 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)
) T. O3 G8 `0 M& Pa) provide an error message if the files are not found or there is a problem opening them5 M: [0 h& C' w0 e; B
b) compare each line of code& a3 P8 [- G6 w" t
c) print out the lines that are the same
8 e8 J9 }3 C: Z' F$ F8 K* k9 \d) count the number of lines compared / lines the same
. N2 q" }; N* |& s$ n1 W' LThe AuthorisedUsers class: (Total maximum 20 marks available)
2 G9 h! k$ U* d5 E* y8 C3 m7 H3. 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)2 X3 T# }. t+ S! S& q( ]
4. Provide methods to:. }" P$ O/ l  l
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 match# Y* v7 Q) e5 u+ i
b) return the name of the authorised user7 S5 s* ^& w& m/ V
c) return the name of the department of the authorised user0 Y, m" \9 |* }3 g1 y6 T
Individual Data (Maximum 20 marks available)9 l2 S, P- D7 R& k+ H# `% \
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.
7 S" h0 }% V) r  W; m" I/ ?Documentation (Maximum 10 marks available)! t3 G$ S% U+ }2 Z/ X% j
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./ b4 N  ]" U: e, c: R7 w7 c
BSA104 Business Programming – 2007: Assignment 2! _6 C/ T4 N6 @6 Q7 d9 z- o5 Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
  F4 T: ~. ~7 g* o不过你要翻JAVA的类库说明。你有下载没有?1 t9 \* M$ e/ P% I# c
查询关于对比的函数。貌似关键字是contrast,还有compare
% y3 U9 {$ r, g/ Q1 i# K5 i3 d, J  q, o# k. f! ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# ~9 y# G4 h$ ]; ]9 \痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。  ?3 g* S. W3 P5 C8 d
可以下载到的 是 jdk-1_X_0-doc
9 v5 u+ @/ a6 @+ `
! @" c3 k3 o) z' k7 v& r: N' U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-23 23:33

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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