找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1340|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急. z; `+ }' b5 |, {2 K# X4 G$ d 5 t; [: G) A3 d8 q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************1 p, N" L- K& t# i$ W4 u
//  ProgramCompare.java         Provided by: DRS; F! ~2 S$ y& s# j* W2 d
//
3 \/ |2 j( s% l9 P//  Program shell for Assignment 2
3 W( }7 ~2 v, y5 C2 F* Y+ B7 F) \//* r9 X" h9 ^0 p7 X5 ^( N
//  Compares two text files line by line  k" m' N: T; C9 S
//*********************************************************************# z6 Q3 _, v7 |, K% `
, `3 Q+ Z1 N. d0 N* h8 {* F/ ~
import java.io.*;# \& q; f, v8 e1 t+ p+ g0 r
7 \7 [8 V* ~- C' S% i- w9 M& b
public class ProgramCompare
; S! z- c3 N  @; d{
) p) V$ U9 l$ p2 [) i        //-----------------------------------------------------------------
1 W  Z! s9 Z# p6 P  v- K7 ]        // Constructor
2 G7 n* `0 P4 i7 A  X( `  @        //-----------------------------------------------------------------+ F* X' o5 G1 [, i; `% T; w
        public ProgramCompare()! p9 P; _+ H) h; R% ^' i, k" C
        {3 _/ u" x# ?8 X* s
        }" J2 _# D1 [8 n
' o7 C' Y/ W' O  r# G' D
        //-----------------------------------------------------------------9 Q) d+ a& B4 H' P& {
        // Method for testing that class has been reached2 y7 K6 z/ U5 B7 L! [
        //-----------------------------------------------------------------       
" `4 J) F: o0 j3 k8 b8 u
- I& q- Y/ G# U& n8 L% _        public boolean ProgramCompareReached()        
$ J& }6 o, e- B        {  v& W% h3 ^, x
      try
3 {9 i# [3 q. w- ~9 a+ n   {        
2 ~) N3 K3 Z' S3 N9 l                        - D) b0 [5 E& V8 W0 ?, c
                //********************************************************************0 ~- I, I1 {6 [& F# U# _
                // Try-Catch Statement is used to handle exceptions - such as file not found - F2 R4 b5 H! k8 a
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. o# [! F9 n7 D% }9 e8 q- }/ J# F                // For more information see page 534 of the textbook
7 D7 W( I) [- N: o                //********************************************************************
5 {' G, O' V3 L9 G$ A, P                    
/ X3 U8 B4 x3 G+ Z9 D        }% U; C" X2 G) O8 D' S
             catch (Exception ex) // Exception caught here and message displayed to the screen
  H' u/ }8 D+ v( f) f          {9 K. H7 U  J3 `7 U0 e" ^- T
                    ex.printStackTrace (System.err);# W% n8 ~9 I" Z! n9 V& c3 O+ h
           System.out.println ("Error message goes here"); // Replace this error message with your own          6 V# `1 [$ j4 S7 w4 Q8 Q/ E9 k9 O( R. ]
        }% q& D9 U4 Q5 c1 M) R: N4 y
                return true;
( z) w2 v' s( u; d        }2 R6 M5 Y- D# [, x7 |  \

$ U6 y& t1 j3 W) ~$ a} // end of class ProgramCompare; A3 v0 ^8 x" H

; H1 K" S0 J6 Z( V" }; f2 _; ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ t  i. U4 y5 u; {4 j# L# v
//  ProgramCompareMenu.java    Provided by: DRS+ @% V1 @0 ^: i' i; r
//
. a! m5 f9 r% x! y) S$ \//  Calls AuthorisedUsers.java and ProgramCompare.java
# _7 p: G. C, q/ G//
8 o3 B" q! x% R5 z//  Driver shell for Assignment 2.
4 e: \$ r: S3 d7 y2 t$ v6 M//********************************************************************* }" C* l/ q, D7 D3 D) f
- y6 l! d# @; n% [
class ProgramCompareMenu! P" ]6 h1 A* l
{$ L: B) O6 D6 V- }+ ?% Z2 R# r' ^
    public static void main (String[] args)
9 R& {3 W* k1 ^! K7 @            {
/ y6 K7 ?+ l- u6 V; w                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 e2 ^% \: S8 Q! Z( M) v
                ProgramCompare reached1 = new ProgramCompare(); ' |  B' V: b! p! D1 M, p
                AuthorisedUsers reached2 = new AuthorisedUsers();       
! T* r; }3 k2 W% E. r' L: ]                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 {9 H( |/ R, i) R
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. m/ V: N/ y% ]4 B1 w" X+ [$ f0 u        }+ w9 W; A& U. \, r2 p0 L% j* K# `- k
}// end of class ProgramCompareMenu9 ?2 _7 P5 t- W0 R$ c. q

% ?! W) d7 B  m# w5 A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" t3 Y4 V3 R& G
//          AuthorisedUsers.java          Provided by: DRS
& m/ z: X* W2 l* i//                8 H4 f$ l5 |( t4 U
//         Program shell for Assignment 2/ R! U' _1 }4 L8 u
//
7 L  t" g8 G* v/ |//         Represents facts about an AuthorisedUser
7 M. X: u. [. @4 v* {//********************************************************************
. U2 |( s6 y6 m
- }& u6 N% t6 U1 Npublic class AuthorisedUsers
: z, s2 h6 n. l+ \( \: g- r: q    {
; E' z6 r; Y: J: }) u  @8 C6 S( |
: U# T3 N! I5 ?        //-----------------------------------------------------------------7 y, W2 ^  ]* @& t+ ~
        // Constructor% U9 \/ O  n" J1 N+ r3 d8 [# x
        //-----------------------------------------------------------------+ @" Z, @8 E& A# ^, `

' ]4 I1 U8 T) x2 W/ n- N2 [        public AuthorisedUsers()( ~6 t5 g; K( j3 ]* g1 W+ K
                {
5 G" }3 P! H, w6 u+ ~& m  ?1 D0 [2 _. a                }
, {2 D& L' O3 C( r- b5 w% k4 c# y+ {  k/ z/ n! ^
        //-----------------------------------------------------------------
4 B- K8 L: B9 O; N        // Method for testing that class has been reached8 A  r" ]: k9 w; B/ H
        //-----------------------------------------------------------------        1 N# Y9 y- |8 {# x8 O& o7 V  {
        public boolean AuthorisedUsersReached()3 F+ D1 [' j8 k* h( c
                {
0 n9 C: J$ j. X5 m                        return true;                       
, v2 L* m* `6 ~+ y4 c                }: r# F. o8 _5 U  I
                3 l/ }5 s0 `7 N/ p% m
    } // end of class AuthorisedUsers( X, x( s0 R; v$ a6 S
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 P, ]8 }* c7 B" |1 k
Shanghai - 20073 `% J' z2 r" P: ^+ p9 n
Assignment 2
' Y& q0 y/ d3 J- a+ ZDeadline 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)
$ V) {2 P% {) m+ t1. 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.
* j' X  Y9 j: pThe staff must be able to:. q3 A' R* r% j' L/ I# }
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! H0 n) @- l% P. c1. 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.
$ Y( D4 a4 h4 j$ r5 C* R( v The interface should provide a menu so that the staff can:+ b; e4 u, d: k" B
a) Enter the names of the two Java program files to be compared- M; o/ r9 B; X
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program./ r9 s( a" D/ S6 r9 \* a* m) m6 ^
** 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).
+ u7 ]% p: K7 e4 V6 vBSA104 Business Programming – 2007: Assignment 29 i; D+ F* w7 w
Page 2 of 5% M. S1 i# n/ p8 U
b) Print out to the screen all the lines of code that are the same5 c" a  g$ }+ G- L
 Include the name of the file and the line number of the code being printed for each of the two files
- S* z" G- ~# k$ J2 i% Vc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 N) [2 E" J  g' K6 g! _ the name, username and department of the user
# O: O" ]/ I  f, [5 X+ J" L9 ` the statistics of the comparison+ F0 R/ Q* R, s& l6 F% A' k
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different3 k2 h8 U1 v! A9 D4 I6 l' O
 the recommendation for further checking) t0 x6 m' F2 u. _* N& Y- V
- 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$ n2 k; i4 `& F) Z; P
 the names of the two files compared; Y' u2 s8 d4 k9 \! G7 d# N2 j
d) Leave the program (exit)7 s# O/ \8 B: n
The ProgramCompare class: (Total maximum 20 marks available)
4 v$ ?5 U) ~, k9 i2. 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), R. W1 X. D9 Y' L: u0 y
a) provide an error message if the files are not found or there is a problem opening them+ t3 Z3 F4 C4 {# l9 ~# N
b) compare each line of code
& K: [) H+ p, e5 t; lc) print out the lines that are the same* {* Y* ~) W4 K
d) count the number of lines compared / lines the same9 y, h/ k4 x8 v) t( g  q' P
The AuthorisedUsers class: (Total maximum 20 marks available)/ ^, T) g# ?, c
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)
8 t2 d3 a$ y6 _/ X$ V5 U& h3 A4. Provide methods to:) {# @8 S" P, o' m- t( F' W8 b
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
4 |, }1 g& ]/ ]3 w7 W  ^# Xb) return the name of the authorised user
0 ^9 f$ P/ k8 _, n2 ?1 c5 Oc) return the name of the department of the authorised user
5 W  m0 x' M% OIndividual Data (Maximum 20 marks available)
, `( t  J- W8 B5. 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.: a. ^* C+ |" w# ?  S9 x
Documentation (Maximum 10 marks available)" i2 \& @# f2 b  y
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.
/ K" W. n5 K  S7 v( EBSA104 Business Programming – 2007: Assignment 2
: z& d. Q3 A( f; C2 g: [Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 u* q4 ?; @" h6 E, B  M
不过你要翻JAVA的类库说明。你有下载没有?
' ?4 ^/ I) J2 f查询关于对比的函数。貌似关键字是contrast,还有compare; f9 L/ [6 }+ U+ l$ f; O
+ f4 Q) b& P8 k4 z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& `1 L. L& u9 g- E' G1 B0 `
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
9 U- b$ w6 z. Z2 d3 t- R可以下载到的 是 jdk-1_X_0-doc
  V( c4 ^( a3 t4 D
" a  }9 R" W. E  ]$ p' U, h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-2 16:04

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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