找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1473|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 . c6 {. ~5 C% r5 L, ^) K' Q$ h5 g! G# |% 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 | 显示全部楼层
//*********************************************************************2 U% `7 ]2 {/ V- s- U+ I4 f- c* y
//  ProgramCompare.java         Provided by: DRS
" y! g5 a2 A/ F* r/// B# W9 V& R, s- e7 \  H7 h
//  Program shell for Assignment 2, T0 R; p) M7 i6 z( R- }/ e2 w- j
//5 U" M5 W& X' F- i+ a
//  Compares two text files line by line* w/ z8 M4 z* J5 ]; t2 N# I
//*********************************************************************1 ?  M  J, d, K- z. B' U# E/ l( u
7 P1 A5 x- T5 Y* q' G: Y9 n
import java.io.*;) L4 C" B, ^4 f! X* R

- b7 A. \+ G! `) Apublic class ProgramCompare
  B/ [: b; o* G/ @{' @; I! ^, W# s9 f8 }
        //-----------------------------------------------------------------
* L8 d! {& `! o$ ^( S        // Constructor
& R! f; |: p  w9 D3 ]        //-----------------------------------------------------------------* ^$ G( P+ N: |
        public ProgramCompare()9 r; J' E1 K; `7 ~5 r! k4 p
        {& P  m0 b5 ]) W: _& t
        }
/ x9 X$ Q6 _2 v5 o& x  [( g+ y; f
        //-----------------------------------------------------------------0 y1 w1 r) K$ |; j  k% s8 }3 j
        // Method for testing that class has been reached
* e+ v9 l4 j+ j. _        //-----------------------------------------------------------------          N% f. j/ d' P4 U6 ?" m( n. U
) P/ O; ~% [! y7 m
        public boolean ProgramCompareReached()        
) v& p7 p% \; @! W3 _        {
# N) b! x; }* P3 V% r      try + @$ Q2 o) n' E) ~0 j: I
   {         * P1 n5 i* t' J) Y* X
                       
( a0 T5 _, C8 _% y                //********************************************************************. m6 I. N% r8 _$ B4 g* B( _4 v
                // Try-Catch Statement is used to handle exceptions - such as file not found
% E% X: U7 j1 o0 w, R' A                // Reading the files will need to be placed inside a Try-Catch - just like this one!! r+ }) z! Q1 [1 A, N' z) B0 a
                // For more information see page 534 of the textbook
) ~  A% K* d# j# V# L                //********************************************************************
! X5 Q' R2 h, t0 |; b$ [' V: _                       Q5 Y$ Z8 @0 G3 }6 ], |+ p
        }
# J: X8 O7 P% D8 @7 F8 u             catch (Exception ex) // Exception caught here and message displayed to the screen : |- l/ c! V) ~  m! u) n
          {
; O/ \, ?' o: ]. Z0 e                    ex.printStackTrace (System.err);
  i" `. P# s% S- @           System.out.println ("Error message goes here"); // Replace this error message with your own          6 ~3 ~# H% ?, E: E, D* e
        }% V. {- Z, ~4 n1 S& a8 `& y, ?) t
                return true;
' ^$ a& _( J0 S% L; L8 R& ~        }" d% [& M" h/ [  S3 R& C; y+ ]

! k, g0 n4 V5 v: C7 Y} // end of class ProgramCompare% }: c; ~% j% j2 Q, J
/ ~9 O7 K! u" J8 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- |% O6 q5 {' f5 P4 c
//  ProgramCompareMenu.java    Provided by: DRS4 W) l* W' C' l5 I% u
//1 A9 |- W4 ~. g/ O
//  Calls AuthorisedUsers.java and ProgramCompare.java* g4 Y( @9 e7 n3 {
//3 t" R$ |) H" c0 w1 q
//  Driver shell for Assignment 2.) {) H, q3 r! [9 p! P$ n
//********************************************************************0 I1 [0 f% N) C& n7 B

/ l9 {. O6 O! T- p$ J- Rclass ProgramCompareMenu: t3 m2 n$ J2 B5 O0 p0 W1 w9 J
{
" Q7 ?# M) S# b8 R+ w4 Y) B    public static void main (String[] args)
; s+ G& D; f" Q! b* t            {
/ t; A$ ?2 q5 F1 K4 P( p                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 e; L5 z- G7 Z7 x1 i3 K                ProgramCompare reached1 = new ProgramCompare(); - D' v3 p6 W9 g/ c+ {, e
                AuthorisedUsers reached2 = new AuthorisedUsers();       
7 b$ y* o0 \5 Y7 k( [( `                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 z: m, h& v# N/ J7 A: I. Z' T0 j2 @                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 y) h6 h5 l1 M* o        }; q) ?& @- F4 S0 P( L
}// end of class ProgramCompareMenu1 \0 z2 w; U6 Y# U
4 w% P* q! b! q% Y4 q6 A( N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  u8 x5 Z) t  i0 u2 R8 f
//          AuthorisedUsers.java          Provided by: DRS3 I. t. `8 E+ }2 I! n" s3 F' G; O
//               
/ Q8 a. g4 ~/ R1 l2 X: i//         Program shell for Assignment 22 Y6 A3 b( c/ p
//
9 g3 Y1 h3 w: Z1 W' `//         Represents facts about an AuthorisedUser
7 {& Z" I" n+ n  l3 A5 r//********************************************************************5 S) N- m4 _# e3 n8 n7 @/ u- p) g4 n
* w; Y6 ^! @) m
public class AuthorisedUsers2 \8 O- P* |) _$ Q' c. ]$ a
    {
; P0 V+ N( J( p4 y0 h3 T
: G) C) I2 |1 T: c$ U1 z1 x        //-----------------------------------------------------------------
) P: Q  q+ C4 H$ P0 I        // Constructor# Q4 i4 w# M: N) w2 O" T8 t
        //-----------------------------------------------------------------+ @. P: Q" y0 \& f! Q

! W& v* U7 o9 C2 O        public AuthorisedUsers()
6 w1 |$ P3 P% C7 {( l$ \9 |- n                {
2 _4 m' z4 {: q$ I$ p5 _                }) i# [& ^2 P- e9 w: g  r$ `. U

/ K" [+ x' g4 t0 X. a        //-----------------------------------------------------------------
$ K7 w! h5 q( T4 U        // Method for testing that class has been reached
. S) @$ C7 _/ l- R6 E  ?; f+ r        //-----------------------------------------------------------------       
4 e+ t9 F0 t+ G: w        public boolean AuthorisedUsersReached()6 |5 h* J* Q2 I$ C' s1 v  z0 y
                {
3 v0 V8 \' x2 q3 `& @. _                        return true;                       
7 \% H; G* T6 r0 x! ^  n                }
7 U1 S4 Z+ V+ g7 D4 A8 _/ `( }                $ t4 D* a4 M5 e2 X
    } // end of class AuthorisedUsers/ U6 q% J; V$ P3 V+ D3 p
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming; Y+ ]. r9 r; {. K8 \% g
Shanghai - 2007
# M! g6 a( |' V/ OAssignment 2
& j/ B( S  [3 ^" uDeadline 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); S+ y8 K! Z+ v9 i8 g( r+ N  y
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 x. v( H4 T" T7 ~* Q
The staff must be able to:
$ p+ r$ x* T0 l6 k9 K3 }. P Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.: j, l2 U& X4 T. @! F
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.
% T+ k* g  r% T# y# h The interface should provide a menu so that the staff can:
$ L- e" d7 T; }! V- |a) Enter the names of the two Java program files to be compared
0 u0 D, J9 `% r For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 y4 V. p) U& D2 G% {: i** 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).
) G, S! R0 b* m6 @/ ^BSA104 Business Programming – 2007: Assignment 2
; L4 w7 X, R; A& R7 Q' {Page 2 of 5
- Y: ^, |# T" X: A" y9 \b) Print out to the screen all the lines of code that are the same
1 `2 ?. M; D; ^4 U Include the name of the file and the line number of the code being printed for each of the two files
7 Q$ [7 _0 K$ |( }c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 c) m7 A4 e  U, ] the name, username and department of the user  s% t( G* S; T6 t! E0 i
 the statistics of the comparison
" }0 a" F" t" `. k9 o8 A- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different- I: z% _+ u, q
 the recommendation for further checking* M0 Z( m) L- r( n/ g% Z
- 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% s: X; t& ~- C
 the names of the two files compared
9 T- d& E4 I& Z6 x  [2 [% Dd) Leave the program (exit)
. J5 M* U+ ^% ]The ProgramCompare class: (Total maximum 20 marks available)
9 d% a9 `: S: Z/ }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)( S  d. m8 Z- `! ?  D7 U- D
a) provide an error message if the files are not found or there is a problem opening them
& @9 s) S4 N" m" W3 Y4 [b) compare each line of code
7 C: p" O1 C" Y7 {, V8 c! B9 Rc) print out the lines that are the same+ @# R+ b; Z0 C1 C
d) count the number of lines compared / lines the same* S0 ~% O7 e- Z0 v5 w
The AuthorisedUsers class: (Total maximum 20 marks available)2 z9 ^; Y- Y" }$ \# E* }
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)
( k- N2 A( M/ h9 V! x$ a% F! u' v4. Provide methods to:' J1 K8 b9 m3 X* Y# y$ V
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
9 d5 P* }0 ~, u6 mb) return the name of the authorised user
9 W7 i8 p7 R6 rc) return the name of the department of the authorised user$ m' P: f3 d) X& ~& B
Individual Data (Maximum 20 marks available)
6 D* N* i& n: 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 a5 f( k- N0 `+ ?" ]! t$ n
Documentation (Maximum 10 marks available)
5 ?1 U8 X/ a! u% P- u! }  B6. 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 d6 G% P) x% E5 s8 BBSA104 Business Programming – 2007: Assignment 2
$ e4 e9 h: X# N2 d, U$ cPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* F. E8 {/ {5 S* Z不过你要翻JAVA的类库说明。你有下载没有?+ w0 H) E3 Y! u" x# h
查询关于对比的函数。貌似关键字是contrast,还有compare( t; k" ^9 ]8 S8 j$ B0 G
& @4 O  L& m* W! a
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 k% T3 {, q- `2 j' ~1 u痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  W+ |3 W% q5 x; v6 F可以下载到的 是 jdk-1_X_0-doc
; ^- F6 X+ O" V% D( X: t& ?% N: C- \! v, n- g% E! m
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-22 09:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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