找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1096|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / q9 e, c) ^- g' q4 U ! Y3 ?( o; m& z# t$ 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 | 显示全部楼层
//*********************************************************************1 u3 k2 K( C6 |/ `: Z1 U% p! h
//  ProgramCompare.java         Provided by: DRS
9 j7 A& W. O- H; E; A( P( Z//1 q, R* ?- D" p$ Z: V
//  Program shell for Assignment 2* B2 O1 G( g4 J, d2 L0 ]4 o
//; E1 Z/ n4 X6 O
//  Compares two text files line by line
# s) D( B$ T/ x) o5 |7 D  p% G//*********************************************************************' {, x$ L, R" Z. {* M. P! q
9 L0 _2 F5 e( |! C- |- r. o
import java.io.*;& r6 |3 R) k7 ?7 \

6 R* x% l* Q1 T# M9 hpublic class ProgramCompare/ r- d( h  P4 Z/ l
{
$ {/ [& O: Q3 M5 w        //-----------------------------------------------------------------
& }# l; A) P5 K7 t        // Constructor( L( w/ \: A& w/ M4 [, D
        //-----------------------------------------------------------------
% g: @) k) i' @, z        public ProgramCompare()/ R( B, k; h8 c; k: s( ^4 J7 v+ K9 t
        {4 v/ e: l, O7 c7 I# U5 C4 o
        }, s& ?( c1 K1 x& M1 n% q6 C

8 h! ]9 q0 m1 ^, O( w        //-----------------------------------------------------------------
4 _0 a2 ?. L3 P) j        // Method for testing that class has been reached( C' J, d. e# M
        //-----------------------------------------------------------------       
: [4 h9 J" _& C; a& r& ^- \' `) h/ O3 x' g- w. I) F
        public boolean ProgramCompareReached()        
1 Z) p) G3 w( D0 |. T        {
5 d) m1 U2 `7 @9 u8 A1 [2 i      try * R8 `6 s( k1 J
   {        
5 z  i, f. s, w                        * U' o+ w* I4 Z. X+ D& V$ `* W
                //********************************************************************
2 ~1 R7 s: J( ^( t/ \. n) Y                // Try-Catch Statement is used to handle exceptions - such as file not found
: z7 S- K. {2 k5 O* S9 ^                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 \7 [- B/ n0 `! X; _5 K                // For more information see page 534 of the textbook9 i' v7 ]& f9 E& i* K. e' c
                //********************************************************************' n5 t# R; \9 j  q6 l+ d
                     % p5 z- q+ f: i  _
        }
4 i* K$ H' \% m3 H             catch (Exception ex) // Exception caught here and message displayed to the screen
, `5 [$ R1 _( \/ i          {
6 Q6 t8 }& |! D' ?                    ex.printStackTrace (System.err);
/ Q4 ^# t4 O7 w  v( P9 P           System.out.println ("Error message goes here"); // Replace this error message with your own          " N! P7 p# u# v4 Z
        }
3 b( i2 }9 J& I- K( N1 b% k* M                return true;
  `" F( ^' h% C% u) @8 }) P        }  o+ ]+ m% G& F$ w  M8 m

; T. x% S& y, F& F4 m} // end of class ProgramCompare
% d: Y# A) L4 M
7 E- T0 }5 I% P  i+ @9 T. R3 \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" s- d% }5 k4 r) u  z2 D3 p0 j" M//  ProgramCompareMenu.java    Provided by: DRS" v3 A# ]' n* @; D3 g. \: I0 r
//7 C  j% R( F# t- w. f7 e
//  Calls AuthorisedUsers.java and ProgramCompare.java
) {' T3 |0 ~5 F: d; S//9 ?4 v$ `- G2 H
//  Driver shell for Assignment 2.6 x+ j* b5 [: B7 W" ]" p- s
//********************************************************************
5 @6 z, }2 N0 x1 \' P& K6 V: ?  v8 i& O! W4 P
class ProgramCompareMenu: m6 C5 J& ^' A) }( I
{
* j. a" w5 L1 c# }) s    public static void main (String[] args)) W& \& N/ ~+ e! A  _: n
            {
% ~" J$ Y' g8 K3 f' {                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 \7 }8 a9 h) M                ProgramCompare reached1 = new ProgramCompare();
. O3 J% J9 M9 P                AuthorisedUsers reached2 = new AuthorisedUsers();        5 u" D! w( t# \  [0 i
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" k% X! ]# P, a/ c( a                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 O# k5 @! v( V, u2 R. i# J
        }
1 q) z( j5 Z# I}// end of class ProgramCompareMenu
+ U" _1 p' N7 t% E0 J) ~% C, o2 W5 L9 V( u3 L  W7 d2 |  C8 n! P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
* V( H* v1 O3 q$ l4 t& T+ z8 h//          AuthorisedUsers.java          Provided by: DRS, v' N2 p1 F1 P, s2 B/ o: t( ^& G: ]
//                . A$ Q3 Z0 p) L1 l$ q
//         Program shell for Assignment 2- ], y  j" c" G
//
2 F2 X. ^% ^; h3 t//         Represents facts about an AuthorisedUser
# _2 k1 I. J( H) ]. |, G4 |. P6 l//********************************************************************
( E5 p8 k( Z( P2 M2 H7 j4 J* d$ I; q' I5 H' W
public class AuthorisedUsers
) m9 c4 V- g8 W' U2 @. u    {# A" }: X! u  E/ u- {
2 H" I6 }" \- R( w" W$ S- W( ~( d
        //-----------------------------------------------------------------, K  u4 }1 j& u/ m
        // Constructor
- D4 A' L  M, Y8 @$ o        //-----------------------------------------------------------------7 A/ t+ d" D* r! o7 |% H4 w* Q3 s
5 K, a6 s% L( J5 q  Z
        public AuthorisedUsers()$ {1 v/ {0 o: T8 z# M
                {
7 U  v* t' g$ w& i                }
$ v" T1 ]* o. t2 F
: ]/ M" n9 e; ]  e% D" E  W. k        //-----------------------------------------------------------------
# j2 Z" x+ o5 R2 i' l        // Method for testing that class has been reached
: q* A; Y7 G, t- o        //-----------------------------------------------------------------        $ Z+ i% E: M: ~; l" M- \! `
        public boolean AuthorisedUsersReached()
0 r7 Y- i. G, P7 Y- B% h1 Z                {0 m8 L7 A: I# d7 K! v, W% G
                        return true;                       
& l5 j8 a7 ?  s# z1 {8 l                }% y- X8 j4 Q3 h3 P" M. L
               
* A0 j4 g; J3 |- x# S, D/ a, I/ Q  C    } // end of class AuthorisedUsers
5 m, J$ F: H# n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) h9 G  q1 ?$ C4 i
Shanghai - 2007
  q0 B) r) R9 }5 Y& }Assignment 22 o" X8 L. R! a  q" {
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)
. c9 y  L' N" i6 h& c) S3 W1. 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.
$ z. |# _& y& f! @0 T2 _6 ~9 @The staff must be able to:
* A5 b# G( C, m Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.$ C  c7 n; W+ T
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.
5 v# v# a" ?- c3 @6 @2 e- i The interface should provide a menu so that the staff can:
3 r3 P' _' q+ N. |. s7 j" na) Enter the names of the two Java program files to be compared! ]  {1 s; l- f
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: R' W% x5 C. a' y% P& ], I1 o7 ~
** 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).
- ^( Y3 u( g5 @$ gBSA104 Business Programming – 2007: Assignment 25 |' ~2 T$ d8 T+ D( M& Y4 Z& Y+ e
Page 2 of 5' b# R3 k& m3 `1 U
b) Print out to the screen all the lines of code that are the same
1 W" e- H; h, h  i( h; k Include the name of the file and the line number of the code being printed for each of the two files
5 X& E7 I0 R* J6 ?8 Gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 t' _7 k6 k3 \; z$ q! C" N$ a4 ^ the name, username and department of the user
# T. I1 W. p- L; l6 f the statistics of the comparison
5 }- P( p' x1 H$ y- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, R. k0 y* a$ X9 B the recommendation for further checking% [1 `4 R6 o6 k0 z* _9 ^7 ^1 c
- 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 closely8 Y7 g/ E9 d7 y9 L4 [
 the names of the two files compared$ m- h: ?9 |7 a3 a! g) P0 n: S1 y' W
d) Leave the program (exit): T5 ^" t0 \- X* i' Z
The ProgramCompare class: (Total maximum 20 marks available)3 R2 F5 Y: T& A3 ~4 W
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)1 D% l4 M4 [9 L: l
a) provide an error message if the files are not found or there is a problem opening them
! D1 t) G3 z7 M9 Cb) compare each line of code7 g( A- I1 S) {+ H+ s5 C
c) print out the lines that are the same# K7 Y4 ~# C" P# J; h8 [
d) count the number of lines compared / lines the same/ s( ~* H# e  J$ P
The AuthorisedUsers class: (Total maximum 20 marks available). _  b$ n. M; N# |+ n- c1 \
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)
# ?5 i& R8 L1 z/ |' l; ~4. Provide methods to:
6 E9 a6 S3 U  G& ]% Xa) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match8 J( x) Q; g  c
b) return the name of the authorised user
# C* Q' \0 |! }- qc) return the name of the department of the authorised user9 U9 A0 k! D0 M6 a
Individual Data (Maximum 20 marks available)
* a" P. {6 g, Y* Q% d9 u2 G4 w. 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.4 e. ]  Z1 q: K. u! t
Documentation (Maximum 10 marks available)4 W. B0 m' N" f- A1 M( {7 t1 {# w
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.7 ~" n. n2 a! a2 A/ k/ m
BSA104 Business Programming – 2007: Assignment 2
# r3 I+ R) C8 L6 m% _( tPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了( p. Z! ~$ S/ n1 j
不过你要翻JAVA的类库说明。你有下载没有?- @8 o" h/ ^9 o7 y! O# j) C
查询关于对比的函数。貌似关键字是contrast,还有compare# \. L% I1 Q9 U, y

3 d! v2 D$ O. M% `% o" L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
% c, d; @7 [& l/ D6 S痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: z: C* K% V+ |2 A可以下载到的 是 jdk-1_X_0-doc& b4 D( \' i4 P3 B, u; o/ P7 p

; e& t: G! C4 i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-5 22:47

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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