找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1260|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急/ m8 x/ W% c# }: X 1 C, q1 U* c* A" I' t1 u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
) w% e/ |1 o' ]! D% j$ o//  ProgramCompare.java         Provided by: DRS  T) W5 j% r9 N8 c# L; D
//# g( g$ \3 T9 n& y  w
//  Program shell for Assignment 2
1 [" R; W5 \  I: Y//
; N& x& h, y, i; P, q- F//  Compares two text files line by line4 r, ^. }# \5 |
//*********************************************************************  _0 Z" g8 c" S; N' a. P
- M' c. @7 C. {0 P- Y
import java.io.*;3 O- v5 F9 c* _& o
6 s: W9 @6 J7 Y5 @9 s) @
public class ProgramCompare
, D' _' c7 V8 k8 k{1 ?% C. a  ~3 g! I0 O+ V
        //-----------------------------------------------------------------: o8 Q' a# X7 T# y7 H9 C/ P7 r; r2 j9 e3 L
        // Constructor
" S5 }; ^$ c( B: G. \+ i. G8 t' Y% I+ y        //-----------------------------------------------------------------8 o0 l7 k  X) O0 f- R
        public ProgramCompare()
( v2 R9 U- k7 |! B1 A! @        {
3 g% Y2 P4 U1 x, b  f        }4 X9 ]3 O  X9 ^$ }
8 C8 O7 o; i6 w+ E  |* L1 l
        //-----------------------------------------------------------------
( ]& K! {1 Z; v2 K7 X, P$ H, {2 ^        // Method for testing that class has been reached0 C$ ]5 [6 \3 O& W! ~, T
        //-----------------------------------------------------------------        ; F( e9 \; r  X9 q! ~/ n% G7 M

; C0 D$ Y5 J( `% {+ u/ ~        public boolean ProgramCompareReached()        
: a; G3 ?/ S( B; x$ H( @        {
7 r# Z0 g4 N- H6 Z% D& D6 M      try
6 x3 y9 @5 P( z2 ~: ^" r, G6 K   {         ' c  r+ }# r0 t# r
                        # A0 [% o5 o' z9 \' o
                //********************************************************************- O1 @3 R# _0 C* P1 Z" A% n( ~& C
                // Try-Catch Statement is used to handle exceptions - such as file not found
7 ~$ t. \# q: c- `                // Reading the files will need to be placed inside a Try-Catch - just like this one!
: s- f; X% h: Y+ k/ o1 F1 h                // For more information see page 534 of the textbook" D" v4 Z+ P4 X& @$ S
                //********************************************************************" S7 m4 U) |, v% i; j5 Y$ E6 |
                     ; d) C- n4 ]0 w2 `. b9 H
        }
! P4 l+ b# T' O( \3 k* h             catch (Exception ex) // Exception caught here and message displayed to the screen 7 G9 s9 \4 ]3 f& Z0 s8 u7 F6 B
          {, E: [' L; G# e5 ^8 H
                    ex.printStackTrace (System.err);
/ j3 a. p% S9 F) r  |           System.out.println ("Error message goes here"); // Replace this error message with your own          - k& {4 q5 b6 @% x7 b5 }6 U0 M
        }* ?4 J8 |" @$ G% j5 u
                return true;
5 E$ N  i% s. K8 n8 Q- C5 }" p        }, ?2 R" o0 n2 J% P7 k) m% A: u" H
' T4 p3 J/ K: U+ C+ @3 @
} // end of class ProgramCompare5 J: D& W& {* j# W  a* q
. j, k' I( G" Z. v$ g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' ^2 f3 u% B* d5 {//  ProgramCompareMenu.java    Provided by: DRS
& a9 Y2 d% I4 d' [8 K$ B  j//+ ]$ Q; ~0 K1 P0 P; W8 {: P, r
//  Calls AuthorisedUsers.java and ProgramCompare.java& {" u% _% [% ]* X6 W9 i- M
//' E  u. x! F3 }% [' f! e
//  Driver shell for Assignment 2.
. t7 I% i7 ~: u  z//********************************************************************! T' v9 J7 `5 g) p3 [
$ }3 @/ U7 ~: T$ r* Y/ S4 o1 p
class ProgramCompareMenu, K1 q& ?1 @) e  V
{
1 r  x, `7 Y$ r# }    public static void main (String[] args)
# j1 ^* k2 y1 f5 x7 d            {
7 g4 L) L( T% Y; P  A0 w, j                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 t; i6 l) \, r9 L$ I2 G+ l                ProgramCompare reached1 = new ProgramCompare();
% t9 H# {# Z; L+ ~) {4 b7 ~. f                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 n' ?+ c+ \$ m4 |  D1 U" |                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 h, G$ m+ `0 u, L6 Z( r                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        6 h0 C2 W8 p# r' b9 `/ s! ?
        }
+ f5 V: ]% E7 [}// end of class ProgramCompareMenu
4 E3 U% e" [' p3 R) j9 P
+ o$ C6 ?( G, f5 i  `- i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' W7 [; i) b4 U8 H$ V; D% ]0 b//          AuthorisedUsers.java          Provided by: DRS
7 A4 O8 D% E; U) t! T1 X//               
7 y2 h7 H7 t; f- G, g//         Program shell for Assignment 2! v9 t5 Z& e' d$ q/ M( v6 s
//  e0 b# _  @7 j( @& @
//         Represents facts about an AuthorisedUser% `  H* P& Z" i! S. g+ W
//********************************************************************/ M+ T, |2 |: w2 K
4 @& x1 o5 I: G! U4 E. w0 e
public class AuthorisedUsers' S7 @# W; \* T9 N. k
    {
/ B/ n" y9 x- A5 w1 W9 u: e# `2 b
        //-----------------------------------------------------------------9 F; j+ h! c3 y5 ^4 g% f- E) [
        // Constructor( i) c# v/ e! l/ _2 l8 q4 r
        //-----------------------------------------------------------------
& K9 P+ _+ i# Q5 K
$ h1 c8 H8 P3 T) j1 I5 `        public AuthorisedUsers(): `4 ]5 ~. g+ g0 l0 {- i# ]: u8 S
                {" E- Z1 Y8 z# \% J6 }% _
                }- W. s: S4 X2 J4 `5 ?' C
+ o# y2 T) g/ ]6 R5 G
        //-----------------------------------------------------------------# U5 b- \+ z# j
        // Method for testing that class has been reached
- d! F, K; m) V        //-----------------------------------------------------------------        0 b" |, x- ?( x6 B2 N
        public boolean AuthorisedUsersReached(): u+ C& S+ X4 Y/ u6 _
                {
* ]4 I. a5 T  S                        return true;                        ' w! F6 d) e- K6 j: R$ x
                }
9 N# z, r; V; ]: z5 L7 q                ! K, \: z5 ]: ~+ q
    } // end of class AuthorisedUsers. b& Q; r3 M4 \* y7 _, q% J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
2 }' E' C! I$ U/ {! G& E1 O* Q' ZShanghai - 2007
8 M! I$ d+ Y+ A8 \+ ^Assignment 2: }: P& h9 W0 W& j2 k$ J" I
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)
& r( p$ Y! k: H$ k1. 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.
2 V" F: O; Y" b$ u* Z( ^The staff must be able to:
, J! i3 j) c. W% G! b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 F1 {# {9 z1 q3 Q( R2 @. Q  a1 z2 C1. 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.
. W" e* V9 D- Y% r' ^' e9 s The interface should provide a menu so that the staff can:+ `% }/ `% z& c9 S) m6 Q0 {. p
a) Enter the names of the two Java program files to be compared! g5 a  S. k3 ^, w! L/ x1 V
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 _0 U( R) W. M# a, 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).( R$ {( q- v3 P9 F; Q: ?: U4 X% D
BSA104 Business Programming – 2007: Assignment 27 I% J! `( @5 n
Page 2 of 5  O! c6 J$ I6 \1 ~5 P0 C; O
b) Print out to the screen all the lines of code that are the same
. I: U4 H. C& `5 k) C- J Include the name of the file and the line number of the code being printed for each of the two files- l' o2 n$ p! f: r
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" T8 Y$ c0 H5 g, u2 B# @2 R5 I the name, username and department of the user
4 l7 }0 w+ k) b( Y( g4 ]0 g the statistics of the comparison* E2 a5 c' F+ z8 d2 W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 R0 S& l. F# K' w8 t! X the recommendation for further checking
0 H  ]3 u4 G0 U/ J- 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 A3 s* s2 }8 L2 C+ Q' \& F1 G the names of the two files compared
1 j$ l" n) U. a1 od) Leave the program (exit)# Z! v4 p4 x0 y. y' `+ L" q
The ProgramCompare class: (Total maximum 20 marks available)( D' T# ^" n( w) U
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)
! ]# ?3 q% t, I# Q1 xa) provide an error message if the files are not found or there is a problem opening them; H" h9 _" f- E1 Z- l  b% K" i
b) compare each line of code
" n& t/ Z: ~& U6 R2 s  w5 Nc) print out the lines that are the same
% }1 z7 X# E5 md) count the number of lines compared / lines the same" z4 O  E4 o' j0 D
The AuthorisedUsers class: (Total maximum 20 marks available)
5 T: M/ N/ _  p( v* [' ]+ V  j3. 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)
8 `2 ?0 e9 c% v0 _) t0 s" {4. Provide methods to:! r$ ?* j4 m- n2 F
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. x3 D$ n* N4 G! T
b) return the name of the authorised user- d' u& Y, Q9 W8 \. e! @) l+ l
c) return the name of the department of the authorised user
! ?) Y: U. N  n/ `, xIndividual Data (Maximum 20 marks available)
- K% A, {' C& 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.9 G- M" @: x+ I0 V
Documentation (Maximum 10 marks available)3 c6 V  h9 F. S2 k' W4 j/ ]
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.( e6 B: r1 T; B1 |" O9 o" ~
BSA104 Business Programming – 2007: Assignment 27 Y$ v" O/ M! ]7 N. m3 H
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ N5 L* t  q4 P  H# L+ J0 O2 P不过你要翻JAVA的类库说明。你有下载没有?1 N, D& b# ^$ c* u0 z# Z: v' Y
查询关于对比的函数。貌似关键字是contrast,还有compare2 H. Q5 J$ x" Q( K! G( d0 s
1 K# I, V0 g6 v2 V4 W  K0 K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& R: t) b8 _8 A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。* B% k3 }4 {, V6 A. t( [! N
可以下载到的 是 jdk-1_X_0-doc6 |: r& D0 E8 o
& F, {# U% `( P: H0 e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-9 18:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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