找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1631|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 `5 p1 w. a2 h: F - D b. @2 W! P1 e# ~
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 g: k, b" ^8 `//  ProgramCompare.java         Provided by: DRS
  l: Y0 X% x3 T2 o& h: k: X* J//5 N% S$ ]- m; m3 c3 z5 h& i5 E
//  Program shell for Assignment 2
) `, y4 x! @! q$ j4 B//
7 v' o& `) _! U, `4 ^- _//  Compares two text files line by line
8 o9 m3 {1 Y6 {//*********************************************************************
9 c7 I/ u& {" O  o6 e" V, y) R: z
import java.io.*;6 N5 n- x& A& C0 U; a1 V- g! H, Z

2 t' \# o5 @' z7 npublic class ProgramCompare
: T1 d& {8 n2 y/ i0 [3 o0 w) P{
7 C2 @) a' i5 N" y3 A        //-----------------------------------------------------------------
: q% M3 R% c' t3 g6 \        // Constructor
8 [2 l0 w* h) Z3 @  B$ e        //-----------------------------------------------------------------
) q; c% }: L& e0 B3 u1 s        public ProgramCompare(); R, o$ _) V( Q( L1 r% g2 s
        {
3 j' e! t1 a1 ~        }
5 I* W1 _5 e4 Q7 d9 A1 X
, b8 k7 j! b7 z- p. V& |" N        //-----------------------------------------------------------------
! j9 @- m5 T0 i9 k1 _        // Method for testing that class has been reached! q& F0 ~! P# |6 q0 O7 V
        //-----------------------------------------------------------------       
! [. M  M: K: l& M* {+ l$ n0 R8 m6 I* I( C% J* U
        public boolean ProgramCompareReached()        
1 H3 ]6 S3 Y/ U/ O) c        {
- ~( X5 G7 m* a; w      try
7 x$ Q% {6 n4 N. ~   {         ' F  I2 \) ?, E3 A4 o
                       
6 e& ~0 p9 e* H6 X, f                //********************************************************************
/ o5 v4 |9 R' O9 E                // Try-Catch Statement is used to handle exceptions - such as file not found 2 E6 H  f9 [' z6 [
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
1 n$ g6 \; j, @: y! L- \* ]7 J9 G                // For more information see page 534 of the textbook( [  P& U6 `+ T! d
                //********************************************************************
" L+ u  @! P. I' J, H+ y5 c1 y  k                     * i7 z3 O2 d2 E9 i' W0 y
        }* ?6 M/ W: G# s
             catch (Exception ex) // Exception caught here and message displayed to the screen " b' l, M% c% f1 @( T
          {
: S( `6 t; Z( y( I. p  Y) g- M                    ex.printStackTrace (System.err);
: m* y. n# O& _$ N9 s           System.out.println ("Error message goes here"); // Replace this error message with your own         
6 z- j# d  s/ A5 K2 a        }. m; K! U' A- w9 c: M$ r! a! z
                return true;
7 ]6 g% a: E% y( w        }: {6 \& z$ S1 [' a1 d
+ ^" g" \: S4 Y) I0 E3 `1 I$ s& E5 H
} // end of class ProgramCompare
: V2 H; g0 C! p; N  l
& s. b8 d- @: i. A% p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************% U4 X- {. }, {' B1 j& f
//  ProgramCompareMenu.java    Provided by: DRS$ E9 E$ d$ ^- A  q* |  Z' b
//
  f% L7 x6 u" m7 ^# M7 v//  Calls AuthorisedUsers.java and ProgramCompare.java
' n* L1 g, W& F, w//2 U2 y; k- ]4 Z$ `) u  ?
//  Driver shell for Assignment 2.( R+ B" V, x# @9 k5 _+ c
//********************************************************************
7 w6 V) Y5 V' B7 {6 i, y9 m6 F8 _/ \. d! E; c/ g
class ProgramCompareMenu; {  y' j) d. z- R8 n
{
: w9 g# D' K$ A% ]" s6 @    public static void main (String[] args)
. a- y* \: @1 {2 \' E- R            {
/ D  a# g* F4 E/ u5 U) G                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; q& ^  k- J( q0 Z+ a                ProgramCompare reached1 = new ProgramCompare();
7 z; n8 n* ]9 G1 d4 y                AuthorisedUsers reached2 = new AuthorisedUsers();       
& ?: |% d) R$ x6 i6 j9 o4 m$ h                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
1 Q( B+ b) X  J% R                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 Y% b! d6 }. l- C2 E        }1 x1 C  L/ N) k6 R; Q
}// end of class ProgramCompareMenu
1 ^1 O. v! B  U0 B' k8 u) X$ [0 L6 i+ m# f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************% s  j& I5 D9 u' _' g+ t( r, I: u- a
//          AuthorisedUsers.java          Provided by: DRS
8 N% K- k/ ^$ I+ ]4 N: \//               
, p* r0 V9 q# p//         Program shell for Assignment 2* _  N& ]! B: L5 T" O
//- a8 V$ J; I* m$ ]1 S
//         Represents facts about an AuthorisedUser$ A+ A( F5 S( B  p4 D6 t  ?
//********************************************************************+ h2 o* O9 i! ]1 }: u0 r

. ^1 t+ l- j4 x- j. t. u( Wpublic class AuthorisedUsers! g+ G' Y% X! C& x  R9 K
    {
% d* V& m" K% N" z" q! V! i
+ N, |9 \: s" n        //-----------------------------------------------------------------! i) `) t' g, c" E+ s7 C  M) i3 i
        // Constructor& F( e3 B: o/ K5 L
        //-----------------------------------------------------------------( w, q5 G" [9 K

0 J7 n8 {2 s6 x3 [; F, t3 l/ k% P        public AuthorisedUsers()1 P, T  i8 e9 A1 z
                {
/ N, U! a8 d% s. [9 b& y                }
: i! g( Q# u( n& e" }* I7 B- s2 W, w" {
        //-----------------------------------------------------------------% d6 V  `2 \- s+ G- K: m' [* t
        // Method for testing that class has been reached7 ~& {3 ~6 D5 e! s
        //-----------------------------------------------------------------        ' \+ N! T+ d' b: e5 r' ^. [7 B
        public boolean AuthorisedUsersReached()! d  Y( Z9 M, E
                {
0 k; L/ ?. L9 _/ {2 p! K! v                        return true;                        ; [5 L7 y# h2 [' J
                }
; i& E( g  p' R+ Q                4 Q) h0 y# Q' s. T' u. s- f6 M! M) g! j
    } // end of class AuthorisedUsers7 z/ M. _7 f' [) h+ j  [2 o9 k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 B7 @+ k; X' }& d& ~* b6 ~Shanghai - 2007
) B4 W. b: `6 U  g. W  H# v) SAssignment 29 }# y3 ^! C5 p6 K4 h0 a8 o
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)3 r7 i) L- y: ]2 p) K7 f( v( h
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.# A8 ], J7 w! x9 g* j
The staff must be able to:+ y+ a9 K$ r$ I/ a7 ~- c% x
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
) X. d; l3 |/ @! _& r& \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.2 [, ^# q$ I4 v  F
 The interface should provide a menu so that the staff can:' Q0 ]' P2 t" H! U8 A/ F
a) Enter the names of the two Java program files to be compared  b6 H: n( j9 `
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 v; x; W) w$ C** 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).
( t  s# I1 X+ C) `. z( K8 d% U4 FBSA104 Business Programming – 2007: Assignment 2. F1 l( D3 S4 \( P' V
Page 2 of 5
  {5 H4 r  g2 ?$ U7 [6 \% ]b) Print out to the screen all the lines of code that are the same
1 c/ N: D3 H; i2 W6 U Include the name of the file and the line number of the code being printed for each of the two files$ F; E( Y" f6 V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared* ]# f. p( t! d! e  f
 the name, username and department of the user' j2 s9 m  h& J+ Y4 s$ @
 the statistics of the comparison5 A  O" o' f. M* H/ g% a
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 S  e, Z8 L) a( E+ ?/ Z* Q the recommendation for further checking9 L1 c! b$ r3 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
; J  F) h) x/ n% M; { the names of the two files compared" u. o" E, t7 Q3 e/ Q
d) Leave the program (exit)& E" N$ [. @  |0 f  S4 E
The ProgramCompare class: (Total maximum 20 marks available): E. L2 C) s# X4 \" y/ I' F
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)
* o/ e% v. A+ X; i) ~a) provide an error message if the files are not found or there is a problem opening them  ^* s( ~) o( d5 }$ `
b) compare each line of code
% b, z! K; G( ?. G3 h! f6 u/ Xc) print out the lines that are the same8 y2 c5 O: O5 g! W! a
d) count the number of lines compared / lines the same
% Z7 z4 o; c2 U! h- h3 l+ GThe AuthorisedUsers class: (Total maximum 20 marks available)
2 @6 ~* e8 n% X& S3. 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)' E4 o! E) x) ~) Y
4. Provide methods to:
! `9 _, w4 V- B# V+ s) n/ n% Ua) 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
5 n* q8 d) M8 U+ ~( l5 Z2 Eb) return the name of the authorised user
7 m* r9 }" b7 k/ r5 ^! p+ d3 Sc) return the name of the department of the authorised user' a/ s9 w! j9 T& r; ^
Individual Data (Maximum 20 marks available)
, m6 l$ P# C5 y; J, \* G$ Y5. 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.
5 T' U8 a  C9 {5 k; zDocumentation (Maximum 10 marks available)
; B' O, ~6 H1 j, c6 F3 y6. 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.! ?5 D1 {3 a) u; K6 w# _
BSA104 Business Programming – 2007: Assignment 26 I( g( n! f" D  I: C- }% n% g+ h6 M
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
; j5 U- j( L- V$ F6 G不过你要翻JAVA的类库说明。你有下载没有?
8 T. v$ A, |' O; {& p查询关于对比的函数。貌似关键字是contrast,还有compare6 G( {% l# Q3 g0 f! E8 E
' N( o% m- t; ]- D/ Y1 Z0 k
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -( }" V6 ]( M0 c/ S& o; l8 ~1 u/ j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 e" a1 x6 P: Z- O( d可以下载到的 是 jdk-1_X_0-doc) a- o6 N1 G4 T' A
5 B6 O# J/ H9 J, q2 ~/ f" b
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-16 11:54

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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