找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1863|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 i% Z: a# W7 k7 I3 E , L5 h4 N& o/ }7 \) D
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************; z5 v, U9 Y* w  \. {8 O, d# y. _
//  ProgramCompare.java         Provided by: DRS- b1 r5 E, l! }$ h; G
//. B5 i9 g* u3 F2 f, B
//  Program shell for Assignment 27 m. _/ `1 U  l4 |5 |& a6 c
//8 c# _( g) U; k  A
//  Compares two text files line by line  e2 i, B& {% Y: U% P6 ]
//*********************************************************************
$ I+ f6 ^6 d* S9 i9 c. ~3 `+ Y! v/ l( O, s- q4 X/ S
import java.io.*;# S; |/ i- E7 \8 B2 e% ^8 v

& N; L( p9 }- g( kpublic class ProgramCompare
# x( ^* x! l6 y' Q# ~{
: A5 T5 n3 F4 |: e        //-----------------------------------------------------------------' h- H8 {( Y' S  u  s$ T
        // Constructor! Q! Y& N, a8 a$ V5 E
        //-----------------------------------------------------------------; r/ Q/ p7 i( K0 f# @  g4 o
        public ProgramCompare()
; `0 d* M1 G2 ~* B2 @3 B        {+ D& W+ R6 x$ f9 S4 m7 d
        }
0 ]. }+ Y$ O1 V# x* L! S; c  A# q* o* Q+ p- B5 ^9 ?4 n; w
        //-----------------------------------------------------------------) Q7 ?' l$ H8 ]9 M: d, p
        // Method for testing that class has been reached3 A9 i% `& K3 r, w) Y& Q
        //-----------------------------------------------------------------        + F/ \1 P' h" C  }

+ J; ?0 C8 t4 N( i        public boolean ProgramCompareReached()        
' h6 A6 E. {" ]# B/ I$ l* V( x        {
. Y, H# R* W) O: |      try
" w. h/ `* O( X& b. m) @" O1 W   {         6 N5 D8 m  z. o5 Y' ~- f$ R: W
                       
* y8 x5 g( [; D+ U! ]                //********************************************************************  x* t# p, c0 V) W7 M# L
                // Try-Catch Statement is used to handle exceptions - such as file not found
: p6 ^$ G, m! x0 T" h! L                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) G0 w3 w/ }" {# x" {5 C                // For more information see page 534 of the textbook
3 l/ Y- ~( O7 |5 T6 p) B  ^0 ?                //********************************************************************! j, E) {+ \- E
                    
; {9 N, d; O1 J2 J6 H% y. E( w        }; V! L( P6 G2 ~1 @
             catch (Exception ex) // Exception caught here and message displayed to the screen 7 }3 N. M  [! V& O# O  O, D; K
          {1 a! ]& }" ^2 `4 H4 p8 ~5 h' `1 u
                    ex.printStackTrace (System.err);* a0 M: o4 {# b% ]0 L$ \
           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ g3 T) V7 Z) q: N1 W% R% C        }
1 @: H# V. r  }2 l# g                return true;
) @/ K9 m8 t1 `/ F% T) T; L        }0 _9 B4 x6 b4 n# @; h, j( Y; G  M$ y

- ?$ u/ i2 }+ [: z! s} // end of class ProgramCompare
# P! G7 N, }: F2 V! a; _, U) e% ^+ o- i0 K5 ]: l) ?
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  {3 X: T; |& a" Y9 Z, {
//  ProgramCompareMenu.java    Provided by: DRS* i( {9 B4 N3 ^1 O1 ?' Q: a
//" I' E& Q/ G8 y. @1 u
//  Calls AuthorisedUsers.java and ProgramCompare.java: i7 Y! n4 ^9 n4 T; B8 J
//9 p7 H& R+ x/ d8 L$ W- [
//  Driver shell for Assignment 2.
! J9 n4 [3 {" @  `" O//********************************************************************
6 o* d2 i0 _6 S3 |! n3 _7 }- B, N' x* J( b5 Y! F
class ProgramCompareMenu
2 T5 c8 `5 Z" F% t# [- k{
1 F1 z, a! M( `    public static void main (String[] args)# V2 o5 ]( b0 M% j5 |6 m" M
            {) r# }  R! b+ g" l& g" j1 X
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
  Q& w  ^3 }( ?  D* x7 E# h2 ]9 j                ProgramCompare reached1 = new ProgramCompare();
; x% R5 _% w9 `- {; g# t9 T                AuthorisedUsers reached2 = new AuthorisedUsers();       
$ g' ?1 D+ T: ]" Z8 z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
4 e9 z- S: n: }) N# i% ]) R                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ k: Y0 @/ ?6 P, I' N& O# \; h        }
, S/ M- r8 U$ h  I}// end of class ProgramCompareMenu2 ?0 A" j6 L  p8 x

' Z' k' `, X" Z- [! s+ U% q& j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. B+ q: h1 @$ t! n//          AuthorisedUsers.java          Provided by: DRS
# G2 R- H% E# W//                * I9 p! X5 ~) t( j7 _0 A
//         Program shell for Assignment 2
4 B3 {$ r3 H# K4 w# v# ]1 {//
" P4 b5 R5 k% o//         Represents facts about an AuthorisedUser2 a1 f% z' o# `- z: Y
//********************************************************************
+ N! _, z: K- W" Q6 @& l& b8 J6 Q
. M, ?1 |: z1 ]1 E! xpublic class AuthorisedUsers
" c/ p% a) x& v* F2 \+ ?" r    {
6 W- A+ h1 A; Z. t6 {& r. K7 v, R& \: I9 n
        //-----------------------------------------------------------------% o) U9 I. ^, ^
        // Constructor8 t" M6 y) r4 v0 [7 W
        //-----------------------------------------------------------------* ?6 C: t* D6 V0 R8 {1 O' T7 D
/ s; [/ u" ^% E& }
        public AuthorisedUsers()
  A9 d( s& n" ?( e- m$ q& j                {
2 b; ~7 y+ ?1 ?7 R9 J* |- A. |                }  }* i( O9 H4 j4 d4 j
5 c8 B5 e5 E. b' ]- P
        //-----------------------------------------------------------------1 @: O8 U3 ]/ U
        // Method for testing that class has been reached6 A2 |! d# `: v
        //-----------------------------------------------------------------       
2 }. q3 m. S4 J* ~5 A        public boolean AuthorisedUsersReached()6 X7 f( L; O  f! }" l1 D, n- [
                {
/ q- ~! a0 F; h( M5 O                        return true;                       
; q5 \/ ^5 x/ ^) h& P: U' b1 D- x                }
! C& \0 O, O3 w1 t               
  s$ f$ s6 X% \: f3 f0 k    } // end of class AuthorisedUsers
; b, I6 C/ G, V4 M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
& M0 m* l; a3 a+ i. P- ZShanghai - 2007
& w- i; l  V2 T: z8 W+ JAssignment 2& G% L  E0 C9 u" F* 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)' z( `* f; B$ a. s& `( D& I6 m- h
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.: Q! Z; N4 w% D+ [, v
The staff must be able to:4 ]1 O# n% s3 Q. `8 i) h. j& r: Q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.8 n8 R& r2 f* X
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.4 L; F: _$ c1 c* e4 ]$ {5 e' U; t
 The interface should provide a menu so that the staff can:, W# D8 ]( ]! V' P  R" K8 h% R# C
a) Enter the names of the two Java program files to be compared
: ]8 ?; G* z2 ]$ w1 A7 n For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' z1 p' y6 D$ J
** 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).
* b5 x5 ?6 a' \7 n6 g) t+ \8 PBSA104 Business Programming – 2007: Assignment 2
7 t( @2 @) R' y+ s( e3 _. BPage 2 of 5
3 W6 V2 S# O+ r$ G4 yb) Print out to the screen all the lines of code that are the same3 s; p$ Y) T' Q) \) X6 i8 z- |
 Include the name of the file and the line number of the code being printed for each of the two files2 g/ e0 ^8 I+ L# a/ _4 B+ R' i
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; m# P3 I6 W; ?, S
 the name, username and department of the user
' Z1 n" [: }1 G" d- K' X& E8 L the statistics of the comparison. r, G, R* m. k  e) N
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 t8 P6 c! q+ I8 l the recommendation for further checking
3 o- ?% @, `( n4 ]- 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
5 l0 W/ B, V$ l' c the names of the two files compared4 }  P8 n  E+ I- X
d) Leave the program (exit)
& a" h. i* a# }' @; ~+ ?8 V( A9 cThe ProgramCompare class: (Total maximum 20 marks available)% s; T* v1 Q, o# i6 Y0 o
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)
6 i' B& W2 |1 ^8 ~a) provide an error message if the files are not found or there is a problem opening them
$ _6 H, d# ?% w0 tb) compare each line of code
' k9 A  Y3 ^2 D# hc) print out the lines that are the same
% H& C& n7 t/ d8 \4 p4 i  ?d) count the number of lines compared / lines the same  X7 I$ \5 a$ v) ]! n9 ^
The AuthorisedUsers class: (Total maximum 20 marks available)
8 {0 f  \$ P- g# d; o1 E  U! ?, x3. 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)
& u% S$ }/ F+ K: z8 @" m4. Provide methods to:; w1 a/ ]8 [' J& x& Q0 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 match6 w. @5 T0 ~, x
b) return the name of the authorised user7 j- A6 T0 M& R  b3 \& t7 E
c) return the name of the department of the authorised user, x: s7 [0 Q6 u
Individual Data (Maximum 20 marks available)
9 A+ M- N( ~( o% Y/ p5. 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 Z- j7 h+ r/ p' v+ D/ M1 E8 n9 m
Documentation (Maximum 10 marks available)# u% i' X; f# i7 u/ H
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.
0 l2 e* w6 h( E: P4 FBSA104 Business Programming – 2007: Assignment 2: d" q/ Z- [  T
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# h. n- K) `; @" B$ K8 Y  p
不过你要翻JAVA的类库说明。你有下载没有?' e, d; u7 N: A3 w8 L( Q1 Y
查询关于对比的函数。貌似关键字是contrast,还有compare
! [; F' ?; A: G& ]
: H  u* o* t8 ^0 b" Q4 n2 K4 m; S; ^# N6 G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -. H  g; x" J) O1 d( ~4 h3 S
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 r9 w; `1 t& w4 z可以下载到的 是 jdk-1_X_0-doc8 c; a5 o* r$ }* R( {1 \
9 z. H. Q: A& I; d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-29 10:44

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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