找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1080|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" r6 Q1 F% m; B- D8 v % V7 V1 y$ U) F" h
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  i4 Z' F7 }; {  a4 h* h$ Q0 h
//  ProgramCompare.java         Provided by: DRS  s) S$ |. Y  }8 {
//) C/ \8 ~( T9 p  I
//  Program shell for Assignment 2
2 h0 d9 T' j( O# x! o2 n//* E- z4 z! m- l6 I3 w) D
//  Compares two text files line by line
  J0 z5 d7 T1 j, S7 K' |$ u4 b; h//*********************************************************************
* m& g  @1 `; T* _) D/ p( n( p0 d4 Q* J: Q" [* s
import java.io.*;
- ?5 ~# [# J5 A$ x! V( Z% J$ f, K
- {1 t) ^9 A3 Q- Bpublic class ProgramCompare
9 l& ?1 E7 i: e& j$ _{& t+ \$ W, b- M7 J5 B# N9 z* N" P
        //-----------------------------------------------------------------
$ r. r3 i( d0 p  Y: \: |& q        // Constructor
$ u" U7 K$ _0 W. |4 L+ @( G# \1 O+ v        //-----------------------------------------------------------------
7 P) v8 k# |8 M9 ~        public ProgramCompare()
: D# M& M' w5 G, y3 L$ E1 o+ C        {, V4 Y: q/ u; _, w# w
        }( D' h9 x8 l& B( @: l6 g! X
, G& R- r7 `8 ~9 C: R; W/ E
        //-----------------------------------------------------------------% y0 g! k0 W. j* F! j3 S
        // Method for testing that class has been reached% ]( `/ d/ g# P8 `1 J. \; h4 {
        //-----------------------------------------------------------------        . L3 V) i# A/ j% |$ s0 p# r: B
4 ]" r( E4 X9 v7 b
        public boolean ProgramCompareReached()         ( n. H( [& R3 l% h3 `3 E9 B
        {" c& s. G; Y0 u1 Q
      try 0 [2 T- K* q0 P' a
   {        
2 G4 U# y5 H8 E/ W) n                       
4 f7 R, ]% W" l- ^                //********************************************************************; y! s4 U) T- ^1 Q4 m) {
                // Try-Catch Statement is used to handle exceptions - such as file not found , Q7 K. {- i1 {3 H) Z
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 [3 A1 T) d% _                // For more information see page 534 of the textbook
4 `1 I4 Z! B7 U3 e; A                //********************************************************************
6 X8 g0 A% E: K$ ]# i                    
8 G# v* q2 n6 T( e4 X, s) M& C6 A        }, V1 l$ r) @5 M! B. V. U+ }
             catch (Exception ex) // Exception caught here and message displayed to the screen
' H. U2 P5 J% e! `3 s- m          {0 `. v9 q* X  d% o* @: }7 L% J
                    ex.printStackTrace (System.err);6 m% I% m( B' e* q. i" a
           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 l, j, b) B8 C5 ]        }( F/ Y  n5 I$ h' Z) f. {1 F+ {
                return true;/ `  v3 X& D5 I
        }! H8 D+ g1 N6 W

. A6 L8 v& u. K( E4 ?5 a" w} // end of class ProgramCompare' h6 |' M& _4 H# ?- t+ h' N- x/ t0 S
( G! N5 ^( A1 ]" h  u. M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 ?! W  L: ~' v( ?: x1 K4 j2 N8 \
//  ProgramCompareMenu.java    Provided by: DRS$ J4 X8 U: n) p7 l# {+ u
//2 w5 X/ j5 m+ w( K: j' g
//  Calls AuthorisedUsers.java and ProgramCompare.java
; W( K% u- n. i1 [) u//* F7 L) T# ^. ]% K3 T3 p
//  Driver shell for Assignment 2.
1 e: p1 ^; a0 v+ O7 M+ w//********************************************************************4 p" i% n0 ^9 }3 E) e
' i# F+ i/ j/ A7 F
class ProgramCompareMenu& S4 F) V% E5 O& T$ Z6 l8 s5 Y
{
: P) ^- Y7 |: i4 T2 R+ I    public static void main (String[] args)" T8 p  S8 F& V7 j
            {' g# J# O& A0 A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable6 L- s6 {: ^+ u: e
                ProgramCompare reached1 = new ProgramCompare(); ! V3 F) q' S+ x. K+ {
                AuthorisedUsers reached2 = new AuthorisedUsers();       
& ?& Q' ?! A8 V8 C                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 I8 W+ B( a% ~9 t+ y* t# P* F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 }; {; W4 K5 B: f' [' W
        }5 l* Y$ @3 a& F# c
}// end of class ProgramCompareMenu8 T0 v; c2 B. c' u+ r7 g! z  o0 z
$ ]8 m7 X. }$ Z& |
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************1 ]3 Q  B: c: }1 O. ~0 D% s
//          AuthorisedUsers.java          Provided by: DRS: _( M; G  |  Z0 V
//                4 ^0 s8 k5 \% [7 m) b
//         Program shell for Assignment 2
: N' |! e* C( }. v: d//7 E7 u: \; z  S
//         Represents facts about an AuthorisedUser
- [3 s1 d2 Q0 Z" T5 R& q//********************************************************************) {0 r% l+ p0 `, e" u6 _+ T

, r1 c/ C: Q" `3 }public class AuthorisedUsers
( ^% Y2 v$ t) a1 R' G: m  Y/ f    {
3 X- f0 W2 G( i& y' f" n. Q6 {4 N8 s) a8 i" {. k6 I# c
        //-----------------------------------------------------------------
2 ^+ g) P5 ~; E1 k7 l) k+ E: O        // Constructor- O; B1 \: c$ {4 G4 q
        //-----------------------------------------------------------------
3 v( k9 L) |; D' @6 S' f; Q3 q
: b* o* A5 c* M; J" [/ w% V( m        public AuthorisedUsers()/ L& P8 D. |0 b* E+ g" K
                {& i0 ]1 H; b3 ?  h% O6 |  Z
                }: Q* V% N; F$ R; B
6 p" R2 f0 |. _- b5 x* S; o$ w
        //-----------------------------------------------------------------* P, A! h: U% g4 d" Y1 L/ Y
        // Method for testing that class has been reached
8 r% ~$ W( u7 y" Z3 B, o( ]        //-----------------------------------------------------------------       
% N2 ]5 u  w7 B. i* S# `% B& a# D        public boolean AuthorisedUsersReached()) W. z, S/ L* [2 k( j5 C) A
                {
4 C. x5 l  q. ]                        return true;                        3 h7 _& J5 a$ A2 A* \# h! G
                }) M+ c2 \- k4 ]" `
               
6 e& C( _  B) y4 Y. h# d3 F    } // end of class AuthorisedUsers
- R) c9 ]5 ?# y1 A& l4 Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
  e% X- I0 `/ g  hShanghai - 2007
4 k9 E; c9 O. R* f5 X4 `Assignment 2( G! Q3 v( \) R/ j9 k, h8 {
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)
5 c# J, @6 m6 k# W, ?. R6 j- W4 y1. 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.$ u+ m6 a1 ^+ D% @4 m
The staff must be able to:4 D& H- [/ J* M1 U+ ~# ~
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ j6 d# [7 Z" i1 Z! b
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 k7 v! `' v: V' n$ u& s- B5 w. I The interface should provide a menu so that the staff can:3 N7 L) o" |& K2 S" J6 d+ C
a) Enter the names of the two Java program files to be compared
4 E1 w, c' h6 G' w2 b' H For this assignment, it will be assumed that the two Java program files are in the same folder as your program.2 t/ q' R; ]8 l! f* U
** 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).
- M( L) v) F* @' ]) d( I2 U' EBSA104 Business Programming – 2007: Assignment 2
; L3 [0 ?1 n  U6 a6 uPage 2 of 5# J4 n: V1 p9 z* V8 p4 P; Z
b) Print out to the screen all the lines of code that are the same
3 q9 n( C5 |7 R; O5 S3 ?( {, F( e Include the name of the file and the line number of the code being printed for each of the two files
) ]% F5 w; J* F1 jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# _; e' T# W4 H the name, username and department of the user
/ d$ A/ P/ u: X3 [* [+ d the statistics of the comparison$ y0 j3 ]4 y+ ?9 j5 Q/ N7 X
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different( C# a9 n1 M; M! j
 the recommendation for further checking) y8 F, D: o: S
- 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, z) M5 o& h! p1 e/ H: W) @
 the names of the two files compared$ e4 n5 z  a( `. J  J+ h/ W1 h
d) Leave the program (exit)
& R- R: t$ l: |0 ]1 T$ QThe ProgramCompare class: (Total maximum 20 marks available)
0 _1 v1 E) `2 t7 G2. 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)- k" h0 }; [) b+ ]+ B5 ]9 y
a) provide an error message if the files are not found or there is a problem opening them
, t9 r6 o7 h3 C* ~7 ^" mb) compare each line of code
. L4 ^1 x* U1 t+ _8 h  G7 nc) print out the lines that are the same0 H/ V1 d2 K1 o1 b$ T6 V9 I2 U
d) count the number of lines compared / lines the same
; ?  }1 L/ |' TThe AuthorisedUsers class: (Total maximum 20 marks available)
( T- `2 k# R  }  a. ~1 q6 f3. 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)
/ l  }8 G! X- U, _/ A+ z4. Provide methods to:
- [9 C. T: D& a2 Z9 @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
, R% s6 @( P! x# c6 ]! Z' Db) return the name of the authorised user7 f$ o2 e3 V/ X) ~2 l
c) return the name of the department of the authorised user# A1 l5 p9 v$ f7 p9 \9 g; m
Individual Data (Maximum 20 marks available)8 P, t$ |/ }4 Y9 {5 ~7 _
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.
/ p' K0 M" V7 F' P" mDocumentation (Maximum 10 marks available)
+ Y# G# [+ s( P  [5 f& d9 i7 o/ e6. 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.- a, e# d. |7 s" i0 B! C. L. X
BSA104 Business Programming – 2007: Assignment 2  I, v+ f( n' |4 o+ R
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了1 f* D/ K, p6 _( y" A  L& B* v7 S
不过你要翻JAVA的类库说明。你有下载没有?
4 C2 E/ M# Q' ~: L' u" g( u0 u' a: X4 S查询关于对比的函数。貌似关键字是contrast,还有compare8 V* \$ r* l8 f8 e6 y, e5 Y* E. u5 Z

: Z( |! O$ v2 _- f# M[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 a* b+ f3 ?' v# F痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& f' {6 Q9 ~1 i! ~  F可以下载到的 是 jdk-1_X_0-doc
* K" z5 x( u: H# _- _% e5 S- @6 F; E5 G* y2 {8 q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-28 16:49

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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