找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1073|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 A& I3 \! s9 T7 F) V& s * n; v1 q! T) u' v0 \- r1 M7 K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
9 W; j* }( o- H  m% U//  ProgramCompare.java         Provided by: DRS
; r! e0 ?4 g& Z( Q4 ^+ k) ?//1 k, I# U6 z5 Z+ I& t( c- J! f
//  Program shell for Assignment 2% _- H# ]# Z' M' f8 g/ m: |5 R
//
% F( U5 l3 g# ^; b5 a//  Compares two text files line by line
+ B1 ~1 R" h* j% {; C& \//*********************************************************************
- J4 V3 \7 F$ h' O) r( i% [8 p6 [
9 n1 F0 h2 }2 Y4 r) {import java.io.*;, ]% I& a9 R: i6 ]6 l" a

, c# V% X7 a* vpublic class ProgramCompare
" f' k6 [" f! M6 K' `  E{' Y: b% A, C1 v5 x3 Z  v$ a
        //-----------------------------------------------------------------) i& @  k4 d6 g+ A) \: G8 Y7 H
        // Constructor! ], u1 \6 }9 C% O
        //-----------------------------------------------------------------
2 V6 Y/ P" Y& R+ z- c        public ProgramCompare()
1 h7 ~2 u5 ]5 ]( q9 u# e. u: B        {
) A7 [3 }7 }- P: M        }2 M* _9 |7 j3 }- c1 E! r; ]

/ \$ j3 v) O% E/ `1 I        //-----------------------------------------------------------------  z* [( L7 c$ p) d" @4 ^
        // Method for testing that class has been reached+ c/ ?- N/ G5 q( K& G' r2 J" G
        //-----------------------------------------------------------------       
+ R8 v2 z0 n/ |  Z5 W4 V7 w9 t' ^+ R* \5 T; n, u- C" _$ h' ~# t
        public boolean ProgramCompareReached()         ( C, B& g, {5 v
        {0 t& F# W6 u2 V5 t  V
      try
+ ?9 t3 `% K6 N7 ?  q* O) z   {         + m8 r3 `+ z5 l; B! {
                       
9 q# R) F2 d( ~$ _                //********************************************************************
. H/ r! S, ~% u$ [- Y/ Q3 z" q0 b                // Try-Catch Statement is used to handle exceptions - such as file not found
6 Y7 i3 O" t- D, ]                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 l$ l2 k2 l% e                // For more information see page 534 of the textbook4 u# z  d* I& }" d1 D' f: B# Q1 A6 ~
                //********************************************************************
: z/ e( F3 ?* _" r# q7 b                     " r! O# y3 r: e& `
        }  J% N+ J  K7 S6 O4 T7 _
             catch (Exception ex) // Exception caught here and message displayed to the screen # X& u* F" E% K9 n* E
          {
( ^% `% L# O5 Q                    ex.printStackTrace (System.err);) Q+ x/ H9 [! n' W
           System.out.println ("Error message goes here"); // Replace this error message with your own         
  b, a+ g3 d4 b# |% D        }
- g1 A, i4 V% `' b" S                return true;7 `+ k  n  i* X
        }
( j# [3 [( p9 q: ?/ q, B) _/ |# U0 e/ i' ?. d* v6 P5 w, y
} // end of class ProgramCompare- }) Q" b; O: w' `
% `) a# ^$ e- H6 _. B! R% F4 v
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 {/ @7 K3 g7 P# l//  ProgramCompareMenu.java    Provided by: DRS2 {0 L& b" [$ }0 V3 R& Q, |, a) j2 M
//
/ j+ _; s1 |2 y* }. l* n//  Calls AuthorisedUsers.java and ProgramCompare.java% [- r$ o$ Z  j7 X
//% E" p; L7 I3 @. Q9 j6 Q
//  Driver shell for Assignment 2.
  t( q( a. g# h* Y; ]& M* P: |! `//********************************************************************9 i) C! U0 `, Q+ M0 D* }
  k, z5 b& j4 V9 z5 U+ g
class ProgramCompareMenu
3 i2 q+ D0 k9 y) h. p3 c1 I9 @{
: [9 `& a' x5 d1 y) G% u    public static void main (String[] args)
# A$ |- b6 J' _9 d  R9 v            {
' _' X. C2 D; }+ G2 I                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
3 B, Q% q# ^0 v% E8 X5 b5 [% _" w+ e                ProgramCompare reached1 = new ProgramCompare(); 1 O; T, J* {% p4 v
                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 V. c* m5 U( ^- F0 O& X* O: U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ F4 ?/ C% }" v( V3 y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 @; l' S  t/ H" v- |1 y        }
" U8 x% v, ^) c2 \& H}// end of class ProgramCompareMenu
8 V7 e7 b' u& F9 g* m' p+ _% o, f0 l4 m" E; R, y6 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 e+ c0 K1 ?4 s1 z) k0 v2 n//          AuthorisedUsers.java          Provided by: DRS
( e/ v' l# H2 ?' {//                % _$ X2 \1 o: d/ _6 b
//         Program shell for Assignment 2# p2 Y0 N* g0 q% h- k+ v( k
//
, }7 Y0 J! f8 m& {) o6 O//         Represents facts about an AuthorisedUser
; F1 }, W, @& W( m7 p: _4 i& K; K//********************************************************************
- j' f/ ^5 _9 Z2 D2 c
+ V  _  P3 v' }; G5 L2 J5 K. {public class AuthorisedUsers% y% ?) M; }3 a
    {
, I( p( r, S$ i; t8 R- i& r
' |- O; t: O1 Z        //-----------------------------------------------------------------
5 d& S, X) B1 I4 c' e" K6 _        // Constructor
, {$ V9 x2 k+ W1 S( g' `        //-----------------------------------------------------------------
1 A' \8 c: K$ y" M8 |! ^  [; F. \2 ^7 |- o6 f9 I. i! f; m
        public AuthorisedUsers()
/ n* o/ r7 u" [) z% ?- n5 P# ?                {9 [  ?$ W" q# c; Q- x# \
                }
9 D; ?+ x5 f" K
3 N; G! F+ [. H0 d- t        //-----------------------------------------------------------------0 F5 V% [. ]( X: k2 h
        // Method for testing that class has been reached
' Y! n! |* B. L        //-----------------------------------------------------------------        & b7 c6 Y$ Q9 |7 z+ R+ s# T
        public boolean AuthorisedUsersReached()4 o9 [4 Z; I6 a+ F9 B% p$ W
                {
3 G- `( b: f' T8 c& E, n! B; @                        return true;                       
% w8 u* B0 J( S' \; l+ w& l4 z                }
- m+ N+ t5 f- h. o$ k/ n& V) r, q                ( r& h  E$ d2 Q. Z7 x
    } // end of class AuthorisedUsers
4 e$ D, J" v" U! A  K  L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# z$ N7 K' |! I+ }  O3 d( YShanghai - 2007
. z  S" A( j; gAssignment 2( O2 C) _3 {8 M9 e$ ~+ G
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), [1 g) Z. h6 f: o% A% Q
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.7 c# h7 [+ n' b1 L: r
The staff must be able to:
* Q6 Q4 t8 F2 ?) x+ l Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
- z  w/ d! `0 Q1 T2 M1. 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.
8 A. D# h# K' x The interface should provide a menu so that the staff can:  f) `8 ^$ p# C' T' t* ?3 q8 T
a) Enter the names of the two Java program files to be compared: f, x1 f+ r  ~7 W
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.5 N: ^+ w" e* e0 H. Z0 W) s
** 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).
( d+ p" B  w. W6 p3 e8 YBSA104 Business Programming – 2007: Assignment 2
/ {% V0 s/ d/ @; I. qPage 2 of 5
% a# t! V( C( j+ O1 L, Z5 Nb) Print out to the screen all the lines of code that are the same
% I* C) }: n7 i" d Include the name of the file and the line number of the code being printed for each of the two files; \' z& B9 Q$ _! I* e1 l) Q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) e  j! M0 u: R- k: @
 the name, username and department of the user+ o; ]  e- _* ^. [6 |
 the statistics of the comparison
, }8 a. M8 S; g! |6 E- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ g: x! C& p: E1 w! ~) C2 Z, q! V
 the recommendation for further checking! Y7 v3 }8 C4 \
- 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
* [3 [7 |/ N% x! q the names of the two files compared
9 N1 b) U! R0 A+ }, d- M8 M, u; b7 `d) Leave the program (exit)
3 z7 p' _% X- ^6 eThe ProgramCompare class: (Total maximum 20 marks available)
/ a7 M- R- h- ?; E  f/ V- t9 _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)0 ~9 E9 o4 X' M# L
a) provide an error message if the files are not found or there is a problem opening them
; O8 h& s8 _& V2 h3 n# H5 Ab) compare each line of code
6 D9 r; J' Q9 t/ qc) print out the lines that are the same. g5 e+ d; x9 D9 p' S
d) count the number of lines compared / lines the same% S0 r5 c$ B3 ^( y! l
The AuthorisedUsers class: (Total maximum 20 marks available)
8 Y' `- }- o+ B1 P3. 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)6 B6 \- U( x* C! g9 h  h7 I+ p+ q5 u
4. Provide methods to:
2 r7 _2 {. f3 Y. B9 @- ra) 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
; c4 @7 J' D' b  h& Eb) return the name of the authorised user
8 P* E" v3 }* N3 V# N% R9 Pc) return the name of the department of the authorised user: R- E" M$ J& W4 A' |, {7 ?
Individual Data (Maximum 20 marks available)
# Z" k7 f0 L5 [0 T. e. a- r+ D5. 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" n& {+ b) L, P  ODocumentation (Maximum 10 marks available)
$ t& V3 }8 e0 M* P6. 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.
3 E9 b# d$ |4 I$ q7 b; yBSA104 Business Programming – 2007: Assignment 2
0 q+ ]7 [+ [& E- t- Q7 ^" sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& Y  ^* T5 {1 S' P4 W, l1 F, `不过你要翻JAVA的类库说明。你有下载没有?" e) y# D7 o5 c" A" }( A: n) K
查询关于对比的函数。貌似关键字是contrast,还有compare
* K8 t4 A5 x" W5 Q' k9 @7 O, N8 E  c& C  @
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; E9 t3 t$ D+ z! Y. {/ ~& ?0 C痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" D7 m' j" a; B, ]) M3 j" F可以下载到的 是 jdk-1_X_0-doc5 b) i+ g/ V$ ~- ?" B/ y
& L2 u; `1 c: A. V( _1 B
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-25 22:16

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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