找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1327|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 : O1 u7 K) e3 k) r) B7 R5 [, \
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ o; E5 _' F* N- H# T3 p//  ProgramCompare.java         Provided by: DRS
! Q% e1 Z$ R. I//
# y" w! {/ m/ a8 Q% G& w8 c: _//  Program shell for Assignment 2
; h6 W9 I& \/ G//
3 R4 H$ t2 r6 g, h1 U2 q//  Compares two text files line by line
, R) [/ i; s; h//*********************************************************************
2 l) O: J& ?& ~6 i" y, l4 q/ ~4 }$ t2 E
import java.io.*;/ E2 ^' m0 X! N- s4 z: e
+ }/ W( j5 ?. B  x
public class ProgramCompare2 P  c/ G/ c6 B4 A( t4 U( ?
{' M* R# |$ ]* s9 S! N
        //-----------------------------------------------------------------
) G* ^* D# \1 ]# i3 S/ I& D        // Constructor
! e+ X& y, P! i8 G, T8 G4 j        //-----------------------------------------------------------------
# @6 T6 P, N, ~        public ProgramCompare()0 t9 z* w8 w/ l
        {9 m1 ~- F9 @6 [& Q3 `
        }" R; e' K) f. z8 K
4 S7 S, s5 D/ |0 K; O/ M1 o
        //-----------------------------------------------------------------& [! [: {3 O5 G  I" ^
        // Method for testing that class has been reached: p: g; K% G6 v. W2 W) [; L9 Y9 u
        //-----------------------------------------------------------------       
7 p, c* D6 b; j/ |+ J# j4 Q6 A- L9 q3 w
        public boolean ProgramCompareReached()         3 A; @9 B+ D+ g. W, [0 Y4 r1 p' {: S8 i
        {
6 p+ e; I* O& Z      try 3 U6 u3 r. s) b) @# I/ F, H
   {        
2 ^1 j% k* b3 z: k0 k& n" t                        ! d8 F0 N) v) g6 a( ^
                //********************************************************************$ Y! q/ O) |! l2 C5 o
                // Try-Catch Statement is used to handle exceptions - such as file not found ; d* J- d1 C5 p* ], v
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
+ F( _1 ]9 \. r" ^                // For more information see page 534 of the textbook
9 U! e+ {0 F. W# ?4 X  w                //********************************************************************' [/ R4 R) O/ G7 G, o
                     3 s3 {9 l% \: u- Q  R7 _2 b
        }
' a9 k; H: ]/ T4 P& d0 T8 K5 l             catch (Exception ex) // Exception caught here and message displayed to the screen
( u. A$ F- A. s, D  r+ I          {( R3 `' B2 B% j: {
                    ex.printStackTrace (System.err);
% g9 Y! Q8 q9 b) U           System.out.println ("Error message goes here"); // Replace this error message with your own         
( x0 |7 y6 m1 s8 E        }
+ P5 t% _7 n0 o) U                return true;; K$ ~4 N# B! D  v7 Q) j( s, T
        }! X) j2 D7 w* A7 Y/ v1 N! y2 U* r3 ]

8 q$ [/ Z1 \7 N! o} // end of class ProgramCompare  S) U( s% W8 X/ S- j* ^  I
9 k# m% X0 L/ H2 U5 d. b( d- E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
: L0 W! Z% R" _" b* a//  ProgramCompareMenu.java    Provided by: DRS
$ o: U( ~, F8 f: F8 S$ @7 Z//
; f0 Q+ t, h& |9 k& `  q0 B//  Calls AuthorisedUsers.java and ProgramCompare.java* u( m6 X2 }1 i3 y  p
//
2 }) ]+ {$ |# K//  Driver shell for Assignment 2.
) H: }% J* w. T//********************************************************************
; S* ~0 q4 J' o% z, W- g0 V% ^+ k3 F0 ]) s0 j: |
class ProgramCompareMenu& h, ~: g% V4 [# y" P2 r
{1 ^- X" Q) s" x; s( u) u$ G+ o
    public static void main (String[] args)' h2 L$ J& S1 \! p, i4 V' T( c& I! T
            {
, O# x; f( z# k4 o                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 j# U; s. a- B
                ProgramCompare reached1 = new ProgramCompare(); , J3 O$ \2 A7 f8 F: U
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- R+ _) J# [1 [$ Z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 [4 X5 q8 n* h& M* h
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ L2 d$ [+ b. N7 K3 x- i        }' I% u; n/ u- p* `, j/ S; g7 u
}// end of class ProgramCompareMenu
7 G8 T7 p, g; j6 g. `* v3 X8 d) Q, Y  ?0 K$ m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 v! Z, g9 n' A+ x
//          AuthorisedUsers.java          Provided by: DRS
8 Y1 Z) F- [: i! l# u//                6 ?0 g' r9 Q4 c: p* [2 G
//         Program shell for Assignment 27 y4 t* D" B: u( q, x& p0 x% _
//
% Z5 S: z+ x5 }+ x1 }6 {& X//         Represents facts about an AuthorisedUser
# v* r7 `% K3 x9 d- U//********************************************************************4 Q2 Z+ y7 g: P/ G1 m

% N7 d; P, G+ g  Y+ d4 opublic class AuthorisedUsers
( ^3 l0 t+ q7 U0 s! q! F. G    {8 V) Q1 P0 s# w, k' Y) t: H
2 j. H% w# N6 `$ w' O* i
        //-----------------------------------------------------------------% a! Z, i* K/ ~, W! v& i( k
        // Constructor
8 c' n" G6 ]6 Y) ~# [3 X- Y$ u        //-----------------------------------------------------------------
' X3 H. Q+ E0 C% ^9 q
- ?* I  a' H2 O* W        public AuthorisedUsers()& |: y% t( T, d+ C6 A/ G# g; \
                {
2 B  \4 J4 |9 G- Y! K' a* Z                }
$ ]* w: ?( n* b, {' K7 K9 g4 z8 M" Q) o
        //-----------------------------------------------------------------) n  {5 g7 A# w1 n# c5 F
        // Method for testing that class has been reached3 P) I( n* B/ ]8 w& N
        //-----------------------------------------------------------------        / p. z  s0 g2 _1 W! v
        public boolean AuthorisedUsersReached()9 }( u) A/ h3 V
                {0 J: V% C) P# w$ |
                        return true;                        ' g, ^" y4 Z, \
                }1 j- a  U* A4 u6 B8 ]
                3 w) k+ B6 p8 v
    } // end of class AuthorisedUsers
: h$ `6 P6 |$ U. Y1 p5 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 g0 r5 K! N2 k1 BShanghai - 2007
, x8 R' j! ^7 I( F3 e: X& W' T) vAssignment 2
+ J: Z3 M9 F" J' ^$ e2 ?) v" W* tDeadline 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)
" H# G8 B+ M/ M9 }; K8 @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.
: R. d" }; L" @" w! wThe staff must be able to:
) [( n/ b) [$ v9 I+ u& f0 R1 f Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 [  P5 _1 b7 _$ ]1 ]9 b4 D1. 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.) M1 I3 |! M. B( ~, _
 The interface should provide a menu so that the staff can:7 |% l! w- b9 f! I7 V0 s
a) Enter the names of the two Java program files to be compared
! X: m6 b2 A8 } For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' b/ t* g+ ?, ~** 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).8 k+ ~! N( ~) P( ^" \
BSA104 Business Programming – 2007: Assignment 2! A# L1 D$ D0 ^# f" W% b8 ^3 O
Page 2 of 5
8 L5 o8 H; [& A8 j$ J: xb) Print out to the screen all the lines of code that are the same, X) p9 O$ e  C0 s/ S
 Include the name of the file and the line number of the code being printed for each of the two files
) `- J7 \+ T6 @  ~& ?c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
/ q' E8 B- }. M: t5 [( a3 i the name, username and department of the user
% G5 Y; z4 }+ P  |6 B the statistics of the comparison6 s* O$ F: h4 a6 e# ~
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) N  `6 }4 q) u+ p1 u
 the recommendation for further checking
9 `% \4 e9 _2 u% a  {- 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
2 C7 M- L6 @8 \+ D9 G: ? the names of the two files compared
  X6 f% b0 |! f- y9 o) yd) Leave the program (exit)1 Q, x) C! o& T. o
The ProgramCompare class: (Total maximum 20 marks available)
5 R) t6 v) `6 x- t! v, o. {9 _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)% f$ f  g  ~8 _7 y* m- b0 A
a) provide an error message if the files are not found or there is a problem opening them
8 D/ `  u& r; p8 V- ^  Zb) compare each line of code3 ~7 m& Z& K4 o* B  r
c) print out the lines that are the same; \1 p; l0 P0 O9 {2 e
d) count the number of lines compared / lines the same! A/ N) X; n3 N( }, E* v+ N* Z5 s6 g. ?
The AuthorisedUsers class: (Total maximum 20 marks available)/ |7 h/ \1 ], I9 a6 ~& ?! s
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)4 Z) O6 z' t7 t5 {
4. Provide methods to:
2 b  G/ Y9 R+ p9 w( V( o. ^1 Z3 {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& u) H2 G9 ]! {3 q9 t( n
b) return the name of the authorised user
- f( q  h& Q- `0 P: ]4 b% Gc) return the name of the department of the authorised user' e# K( p1 p2 V# C
Individual Data (Maximum 20 marks available)
+ n4 T) }* {  s) E5. 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.& ~; C5 P# W' {- f9 _
Documentation (Maximum 10 marks available)5 F% q/ J2 L( h; u; o4 h( s, B6 q
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.
8 J# B8 F( Q+ u  b8 Q! N" \( {BSA104 Business Programming – 2007: Assignment 2
$ l/ D2 A4 t* d- ]5 k9 ]Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 a# t) ~3 A3 D. q  P( w1 J
不过你要翻JAVA的类库说明。你有下载没有?, o2 f" Y; J6 i  Y. H0 V6 k
查询关于对比的函数。貌似关键字是contrast,还有compare
1 c6 W7 R  j. R5 R! X5 {$ O$ \/ o6 v  B3 C
* B- I/ r9 w6 o/ F[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* J" X& O/ h  o4 H, m痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。6 c: _/ j' \! Z' ^0 _# q, y
可以下载到的 是 jdk-1_X_0-doc
7 A  S9 `1 `4 k$ ?
$ t+ ?& m- G+ v6 g, R. P4 Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-30 06:46

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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