找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1552|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( G0 h8 Z T3 ]* F0 Q1 F. E1 {1 p9 o) `. R8 L. ?4 h J
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************5 U6 b+ R& C+ `3 P( y7 |/ X
//  ProgramCompare.java         Provided by: DRS
( J  _1 B4 ^8 r0 i0 G9 M  d% m$ q//
$ v/ {6 }, O% Z9 e& F: M! N//  Program shell for Assignment 2: ^1 l3 c$ U9 O# F  h
//* X7 t' ?7 f: y( i
//  Compares two text files line by line
/ C% X, a  u- O0 d//*********************************************************************  k& u" B" s  j5 ?8 G7 D  k2 ~, n$ Q
, ?+ @! S3 A# ?' N& x  Y
import java.io.*;8 i* f/ G& B3 `8 Z

% U) ~' T% j: u" kpublic class ProgramCompare
/ h& g$ z* }. }{
; \# H4 j4 }$ {4 m2 p& A- D8 Y. y1 L        //-----------------------------------------------------------------  X$ e: X1 @/ z5 \
        // Constructor" l- f$ E0 n! S6 ^' D& k
        //-----------------------------------------------------------------( o4 Z8 {  Y5 l9 P5 u( `
        public ProgramCompare()
% [: _  a  R9 n: d6 F        {' f. A) e+ L% |, p6 P& }3 \/ V2 S
        }9 {7 a. ?) V5 G
4 m9 ~% w- v& p; z" o; G$ h
        //-----------------------------------------------------------------( v/ t8 m# ^5 R: R
        // Method for testing that class has been reached
1 m; v: `6 v* D3 k+ O5 y' v. L        //-----------------------------------------------------------------        3 c0 D& W, I2 w5 p2 n% p* T7 `
6 i/ \8 s2 ^3 w* O( M6 w
        public boolean ProgramCompareReached()         $ _/ ?" C; h2 x$ @1 h* m" z
        {0 y, M8 H9 R. G- z6 q: S5 j+ v
      try & E9 @, T8 c9 }! I
   {         ( {' R2 q2 y; R1 M
                        ; W/ ^' U7 k1 j" i# K& I$ ?$ h2 p4 X
                //********************************************************************# k4 \7 B, s, Y, N
                // Try-Catch Statement is used to handle exceptions - such as file not found 1 |* S0 V6 h8 o; Z0 h
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
& B/ U: ?, |# b+ Z/ w4 y% }                // For more information see page 534 of the textbook
* U6 j' L9 I8 i0 M4 {                //********************************************************************2 r- _" t! l9 N$ D
                    
) z# j5 C! {$ x4 L        }
9 g2 [/ f8 ]; _6 E             catch (Exception ex) // Exception caught here and message displayed to the screen
. |+ z) Q+ D  I' H: ~' [$ D& B          {
; t6 ~7 b) f( G% u                    ex.printStackTrace (System.err);
3 H( q! _# |$ q) p7 q  p           System.out.println ("Error message goes here"); // Replace this error message with your own         
' `8 p  G; Z1 c  i0 N$ [( U7 ?        }
& o6 `& C0 Q* ^1 P) Z* G                return true;
! v% J% G' [4 c/ p; D; s+ P        }
! K% I) K. `# r" R0 R
5 |- h4 R3 ~1 _2 u  [5 h! Q} // end of class ProgramCompare
* ]2 P: b) W1 ~4 F
6 r" v1 Q( x9 [# v, F+ Q/ u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. w' P9 _: P, D) e) r2 Y
//  ProgramCompareMenu.java    Provided by: DRS
+ i" o4 q) X  P) z//
) b/ t) m( ?) K//  Calls AuthorisedUsers.java and ProgramCompare.java
4 r/ d* F7 w9 x' y. \% s; i) v//
8 T- H1 O, \/ w0 o//  Driver shell for Assignment 2.
, z  ~! c2 G. `//********************************************************************
9 p" ]3 C5 f6 |7 ^
3 F% |. P  S0 \7 [class ProgramCompareMenu+ M4 Q; ?" s0 V  h. I, E6 ]' O$ w
{+ I, B! r; P$ m
    public static void main (String[] args)
& s2 [% u" o+ i4 \" Q( t* _) c6 F            {1 \! e+ ^- k6 w' L8 z
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: z5 P* v" J5 p. e+ K+ e6 ?0 g
                ProgramCompare reached1 = new ProgramCompare();
/ n% T# e  x) v, }' |                AuthorisedUsers reached2 = new AuthorisedUsers();        1 c8 C4 F7 F: K3 s$ Q
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 R- r6 m! a, p5 |% z( v. O
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 D# }9 Z, D  S  {/ v) k7 \        }
& B% h' d* ^# e1 w3 f2 h4 L}// end of class ProgramCompareMenu
. z9 A. V" Y( V3 |; M. k6 A
& Y/ s7 R- ?- @' ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" P! Y/ M- h2 t# \, A//          AuthorisedUsers.java          Provided by: DRS
6 y5 f! o) S) J+ n9 `2 G  e& u//               
9 w; h9 a4 ~: z& o% z% W$ [) u//         Program shell for Assignment 2
$ \  d% F5 A! W, Y//. X: W( t( \  ?6 s
//         Represents facts about an AuthorisedUser  H  M4 b5 y: p& T& {
//********************************************************************
+ L; P: o, Y2 c7 U) k' Y! s- A! Y% a% P# D- h: v" {3 n( W- G- w
public class AuthorisedUsers% R8 v+ T  `2 d0 D$ U' ?4 \; H
    {
- R: g2 z* Z0 n1 v& c6 V# y6 ^7 k7 v6 }2 d+ F/ d
        //-----------------------------------------------------------------/ {" t" K% S8 L2 L
        // Constructor
9 W* K4 r( o- d+ O1 i        //-----------------------------------------------------------------7 V' B* ^& w  m) L* Z* p  B! f
" s1 i  A6 \- G8 e
        public AuthorisedUsers()3 I. a5 d" b4 ~$ b! H4 p
                {1 }' N; _! z0 ]& r5 O
                }6 I4 ^0 I3 R3 N! ^# ]

( F: {* a1 u8 s3 L        //-----------------------------------------------------------------
7 a- A) w* P& \0 i- H/ v9 g        // Method for testing that class has been reached
3 [3 H* z" {1 ]- c0 T' r/ C3 z7 l        //-----------------------------------------------------------------       
- z# g3 W; m. p. k' n# C        public boolean AuthorisedUsersReached()( I, f/ ^) }, W3 u9 Q7 \
                {
8 w+ }& S. j: J" a# {                        return true;                        5 y( a8 r. F' U9 E! [- x  g
                }9 v, R1 J) z. X
               
4 Y. g0 n) E4 }8 p2 u    } // end of class AuthorisedUsers
) y1 x" z; u" O( H: P/ U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
2 \( s% k- v$ u- M! Q3 W+ qShanghai - 2007
" K" a- |+ D' ^. gAssignment 2% k$ U: W+ B4 Z
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)7 U8 n3 M3 R) Q7 q/ B
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.0 J& p$ I4 Z+ B& p
The staff must be able to:/ J: |9 O; w! g3 m+ O
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 }/ Z# q3 l$ w) m; n
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.
+ Q8 c6 E- V$ A: e4 w6 c The interface should provide a menu so that the staff can:
; S; l5 ^; _" aa) Enter the names of the two Java program files to be compared* B# f! ^" ?5 L: B- f* u# E. k
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 V6 n- D" y' O  `5 O& Y+ y
** 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).
. {. K8 q; G* f& v! M/ xBSA104 Business Programming – 2007: Assignment 21 k2 ~0 b& v/ C% a# c
Page 2 of 5
7 x& V- _1 d5 }b) Print out to the screen all the lines of code that are the same1 x+ r: n, T4 g5 h* m* ~# p" X
 Include the name of the file and the line number of the code being printed for each of the two files+ Q$ l+ e) ~. f3 Y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared: R# A6 X) o& m+ T+ A) |
 the name, username and department of the user0 F$ Y) a% ^1 q9 B: `
 the statistics of the comparison8 K+ |7 T/ l0 ?$ V' Z1 x
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
: {  d1 [. h, u/ |( L the recommendation for further checking
. ?+ W1 J9 g+ e7 c- 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" r, u2 K" t! G$ B
 the names of the two files compared. K& b) w1 }: I$ K- z
d) Leave the program (exit)$ p3 T. o5 v. o+ M
The ProgramCompare class: (Total maximum 20 marks available)
! k. Y  z% a8 Y9 `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)
- o% v) ^' `5 f- Oa) provide an error message if the files are not found or there is a problem opening them8 R) j! n/ R6 _$ B
b) compare each line of code
! v) P# O6 L+ Bc) print out the lines that are the same
! h8 d# R9 Y( r% {; Xd) count the number of lines compared / lines the same6 S$ R9 g3 g4 m. T+ A1 C) g
The AuthorisedUsers class: (Total maximum 20 marks available)/ b5 y# c$ K- F: Y9 N$ V" u
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), N! r+ f4 s: c: }  q$ Z9 q# y! d
4. Provide methods to:* b* L0 K4 N) h+ ?8 e
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  Z( ~3 h8 {9 ]b) return the name of the authorised user* z6 m  i* A6 p2 ~1 _; W+ E* [, t
c) return the name of the department of the authorised user/ n3 l: _7 w- N4 X0 G- {- M3 r% L/ l
Individual Data (Maximum 20 marks available)
6 q) k7 J  m0 |0 G5 M- n5. 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.
: ~3 w+ q5 B* c; I8 [: ?$ JDocumentation (Maximum 10 marks available)
5 \& a% t- d+ U2 v6. 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.
9 q7 I! q, D! H: l; {5 OBSA104 Business Programming – 2007: Assignment 2
9 Z; `0 f/ ]. N3 Q8 \Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- z( V; M& g$ z) h不过你要翻JAVA的类库说明。你有下载没有?
6 Q5 w) @2 ]: A查询关于对比的函数。貌似关键字是contrast,还有compare
, H% G$ `( {6 r+ ?+ r" ]% x! B, G* p5 g* A
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" C: T$ k4 \# v' o; ^+ }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" R$ h; R, `% D* g9 d3 |2 z' Z可以下载到的 是 jdk-1_X_0-doc
( B2 u9 k3 k+ C1 K
) L! |# T) P' S! I' d[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-20 06:44

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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