找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1829|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " W5 U" C2 q- E1 c - X8 l3 l# K6 ~
回复

使用道具 举报

 楼主| 发表于 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' |) G' @  d* v5 {//  ProgramCompare.java         Provided by: DRS5 ]+ G, [6 u- i: F
//
, y- N6 |* X) u( \$ s% o& Q//  Program shell for Assignment 2
6 }; _8 ~$ H* g+ W//- E1 ]- f' k4 {: h# j; |; ?5 ]
//  Compares two text files line by line
$ h) A2 y# R6 f0 v//*********************************************************************" N9 [* v/ A1 K3 R0 D" B

0 e2 _, ]+ z0 k( |2 G0 wimport java.io.*;
! S: I+ Z: L3 `
) u7 O+ [5 W, s" vpublic class ProgramCompare
3 U, e0 {# R/ H5 X8 W- \{! O+ Y1 X' A6 V% ~
        //-----------------------------------------------------------------
  s) h- n3 A/ w  f  c8 |7 R        // Constructor) }  N. E2 V) {$ B' q$ I5 i8 ~
        //-----------------------------------------------------------------/ `; U* `7 @. H) m4 ?
        public ProgramCompare()
9 W& O0 t3 G1 d8 _. C0 h8 B$ O% s        {
* B% B* T2 t6 b1 r+ F' P        }( \; V) d6 f- _! w1 R9 A

1 [" V5 K: y7 f) K, _3 d6 y        //-----------------------------------------------------------------& @( G, r% e3 H6 V1 A! O* }6 Q. b
        // Method for testing that class has been reached2 x+ i; C6 V. p6 S- R
        //-----------------------------------------------------------------        " L! C4 }5 `& q& K  K

- m7 r4 R) J- A& F        public boolean ProgramCompareReached()        
) g8 f+ }, r. B6 Z( p1 P        {, K4 d3 [( M9 T7 v
      try
8 l/ F! W0 X' f5 ?0 L   {         ) W$ s, l# a3 H, X2 ^
                        * ^5 l4 H: H4 o' ^! }
                //********************************************************************
% O' R) |( x/ j3 k7 \, `                // Try-Catch Statement is used to handle exceptions - such as file not found " F0 a0 E+ x# [* I- u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
; p2 A6 s* T) s- l' a                // For more information see page 534 of the textbook
4 z* S$ p& c3 t# x                //********************************************************************% F4 Y# p0 @0 O) y. S
                    
! ]; I$ }7 j# A7 m1 X. C        }
! i4 g7 V+ N/ I6 a  Z             catch (Exception ex) // Exception caught here and message displayed to the screen
7 p( L' R2 z/ H+ b          {
+ ?  h# p7 z6 c2 g3 P( p                    ex.printStackTrace (System.err);5 u/ q# Z3 \: b+ z
           System.out.println ("Error message goes here"); // Replace this error message with your own          $ q( }; h$ X& y) x% y3 u: o* K
        }
2 n$ q$ J, T( j7 _! z9 |; o                return true;+ p9 |) r6 _. `) \
        }
+ _( T' [6 B$ o0 G5 S, t$ P5 L
% ?# `( G" W" a' D} // end of class ProgramCompare
7 p6 }' B1 _7 i/ O- f  }; Z7 t7 F2 n! F' x3 A$ D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( C. g9 @" n  A. ]//  ProgramCompareMenu.java    Provided by: DRS
9 ?1 Y& A9 y  t' z//
& h8 O% m/ x8 O8 y* A) A//  Calls AuthorisedUsers.java and ProgramCompare.java2 F2 N+ R1 r) u6 ?0 c( M
//% d3 y& T/ V3 F' y
//  Driver shell for Assignment 2.
: E0 S0 D  z" W& }$ V0 T//********************************************************************  N! |, m$ F5 i

* f& d2 O: Y- v' D1 G7 N$ pclass ProgramCompareMenu
9 N0 _/ K' o4 X. @; r4 y3 ^* T) Z. A{
$ y% V1 N% g1 K( y+ t/ K    public static void main (String[] args)
( U% s! l; o3 w( G; b  ?+ A' w            {9 h  P/ n2 k3 ?3 Q( M/ N, s- A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. r; f4 o5 t$ ~( }                ProgramCompare reached1 = new ProgramCompare();
1 w# y' Q( ]/ f                AuthorisedUsers reached2 = new AuthorisedUsers();        3 \5 H" R+ b' |! t
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- n9 H$ I# j& E5 N* y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , ^9 l; l2 Y7 B" s
        }
' z: k: t: T" q7 C( C8 y% ?}// end of class ProgramCompareMenu7 J& @8 C1 M; f
; q# j5 M0 k! {- H3 H+ `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. b- P3 ], m9 N% N5 h! D& q//          AuthorisedUsers.java          Provided by: DRS
; |- R# U0 G( h  j( J//               
( f/ ^! U8 ?1 S9 w( c//         Program shell for Assignment 2
6 z( K: ^8 D6 c+ ?5 e//4 Q7 u) i0 s0 V
//         Represents facts about an AuthorisedUser+ z0 Y( C, g4 |# x
//********************************************************************
( O2 |& C8 m7 |$ |) ]# P& Q! o
9 j% E  w2 G5 P/ n  A; epublic class AuthorisedUsers5 Y. u+ J( {  u5 D, g+ Y
    {( S7 u8 t6 K. y* e7 I# h
0 Y0 P; h  D$ ^, G3 b- W5 r
        //-----------------------------------------------------------------
7 C: V8 k: y  r- V        // Constructor
3 C" R' j  }2 r9 O6 f        //-----------------------------------------------------------------
% Y. _6 H) G6 }  ?- p5 n& I5 F5 x; _+ g
        public AuthorisedUsers()
3 a! G! q2 ?. N' X2 E                {
( u% Q- m, p" _' p) c                }
8 t4 T- ]( i7 [, C# r) q0 N; u; Y& f6 U
        //-----------------------------------------------------------------
; U% O, U$ `- V9 v. j" {$ M2 z        // Method for testing that class has been reached: d2 w# @& X9 P- B2 q- B* G
        //-----------------------------------------------------------------       
. Y0 ]2 ?% z% C% `0 _) ]        public boolean AuthorisedUsersReached()0 h. {, I2 f: Q
                {" Y* v* @2 Q  `& o* v- \
                        return true;                          b' l9 t8 C. ^% a
                }
! O: E3 N; K: e$ ]8 p7 Y$ B& W                # ~6 `- s9 ~, Y. `/ i) ?4 B2 i' M/ g  ?
    } // end of class AuthorisedUsers
5 \1 a) m6 s# K0 W4 `+ r% V: t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming* C8 u( v6 }: G4 _* N& u
Shanghai - 2007& V8 R9 ], k2 f% C/ `2 P5 k$ `6 ~
Assignment 2
7 ]/ E' a9 L; F0 P. a# ADeadline 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)
+ @8 b2 ]+ ]) C1. 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.
  s; Q7 f0 }$ l  ^# r$ z, ]The staff must be able to:
' q& g, G6 U2 j! s* L Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# l7 r/ ]7 ~4 w" g; t1 j# h5 |
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.
! N9 i9 @- ~* k' w) w! @9 |6 a The interface should provide a menu so that the staff can:
9 a2 S. t% B1 i& ja) Enter the names of the two Java program files to be compared
, `& ^! S) C: t6 q' L For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! |/ {& y0 \: v2 J7 k
** 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).
! f" n" P- M: E3 dBSA104 Business Programming – 2007: Assignment 2* p  P" z- \$ _2 m6 C% y, E) H
Page 2 of 5& W$ I5 U( }# Q6 [. [
b) Print out to the screen all the lines of code that are the same
8 J) ~- R0 O9 x/ ]0 a8 h Include the name of the file and the line number of the code being printed for each of the two files  |/ s, x! W4 O% C% l
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared: v8 s$ Z  Q7 D6 r5 Q( w
 the name, username and department of the user+ Y# Q! r* G- ~" u( F
 the statistics of the comparison0 V4 e9 }8 a! `- x) E+ [- U" q2 y
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different. j$ ?9 F( Q" z2 ]
 the recommendation for further checking
( i# z: ]4 z+ N; E7 K0 D- 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
, ]4 x  T- C9 |4 M4 a the names of the two files compared
' w3 r5 i* O) K2 u5 d! v. Kd) Leave the program (exit)
0 O: Z1 X0 w; G5 X$ }5 qThe ProgramCompare class: (Total maximum 20 marks available)5 k* f& l$ ?8 [& `8 N/ M2 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)
$ Q  `* D* W/ m) d- B  O8 aa) provide an error message if the files are not found or there is a problem opening them
4 ]0 Q7 C0 l  o9 O7 h) K+ M1 {+ J, zb) compare each line of code' i# d6 A% ~/ Y$ ~8 I
c) print out the lines that are the same3 ^! \! R7 W( u& ?
d) count the number of lines compared / lines the same2 u  M& |/ \& d# f+ @9 ]3 S/ ?
The AuthorisedUsers class: (Total maximum 20 marks available)4 g+ H7 ^; f, T) Z
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)
7 T) g0 A0 h1 B" d# j4. Provide methods to:- L4 H( E7 Y7 |# C, O* l6 g
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
* _# e6 u0 Y$ y5 [b) return the name of the authorised user
  F4 B2 n3 h6 n8 z% vc) return the name of the department of the authorised user
9 K" ^; w! H4 C/ u0 LIndividual Data (Maximum 20 marks available)/ }0 T: g) t) h) e
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." W9 O. p' j1 W
Documentation (Maximum 10 marks available)
, [4 n) @% Z2 J% \  H7 u( b$ m6. 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.
' f) k6 e# \+ M- C! t1 NBSA104 Business Programming – 2007: Assignment 2! g+ z( C+ y4 x! c% [0 F7 K
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  z( ^+ p3 }' Q
不过你要翻JAVA的类库说明。你有下载没有?
% }% n1 s# i  D! R/ H; R7 O, q1 ~查询关于对比的函数。貌似关键字是contrast,还有compare
8 ~3 H. |* W7 |8 F. g* {3 p
% R3 i! [4 V: d/ B& `4 j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" X# b1 z3 |4 i( i9 g" Y
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。# i; v7 e4 t" g' f
可以下载到的 是 jdk-1_X_0-doc: k+ W- \7 v0 r
& y9 ~9 }) h9 [4 [  y* R7 u# Y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-15 18:47

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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