找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1375|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ S6 k- p" h, d# [9 J( t ) h6 D- t' r! Q7 N: 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 | 显示全部楼层
//*********************************************************************
5 m  g# R1 {! r6 r6 ?9 i//  ProgramCompare.java         Provided by: DRS
- {/ ]+ k# c+ V- V; a4 q//
9 `& ~% \) ?8 I/ m9 M) O2 I" A7 c//  Program shell for Assignment 2- a- _- s6 c4 S; w. X$ k9 S: K, m/ p
//
+ `# ^  U# ?2 P7 \5 m7 g//  Compares two text files line by line
3 f( @4 U. y9 H% G//*********************************************************************
3 Q* |$ `  H4 m6 v7 P( u9 f9 `) j7 l9 f/ a9 z: i/ P
import java.io.*;
; a9 Y5 B3 j- v$ Q( I1 u! \
$ I- S, _$ h: p! C  bpublic class ProgramCompare1 q7 G! j% H) P7 [# H
{+ u5 W6 H1 W7 d  V4 _7 e
        //-----------------------------------------------------------------  b7 P8 K# `* |6 A
        // Constructor" v2 f* u1 o$ l$ e5 n6 Q
        //-----------------------------------------------------------------/ Y2 G$ \- u! G) u) l
        public ProgramCompare()
* I  E; B$ L/ \! }( z8 f" p        {' _$ I- u  g7 m
        }% u& F: \7 ~5 `1 J) L
# A' y+ Z9 U7 U6 M! b( \. u* M
        //-----------------------------------------------------------------) n  h6 R6 u  w2 o. {' q, Y
        // Method for testing that class has been reached; l8 u5 _2 m7 G5 y
        //-----------------------------------------------------------------       
5 M; Q4 y" q* o, m
) S+ v; {4 P  U        public boolean ProgramCompareReached()        
4 M& z2 W9 G4 e5 n. k5 D) o        {
3 u. i2 f$ M% ?      try 8 f- W- n- Z  g
   {         " }$ |+ o- N) _) Q7 Y8 a# D8 b3 Q
                       
8 U( Y8 S+ r. S, K9 b                //********************************************************************
9 ^9 W) d, v4 d4 @9 O                // Try-Catch Statement is used to handle exceptions - such as file not found 8 m7 E% s# c, T' t
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
* ?7 P6 w5 z* j$ ~0 K6 J7 i                // For more information see page 534 of the textbook2 R, s% t+ I; ]+ f; \6 K3 ]# @: _
                //********************************************************************* A- [' T/ S, H% X( F6 u
                    
8 F+ z, i1 y; g, K1 G3 Y        }9 f; o* r5 ?: h
             catch (Exception ex) // Exception caught here and message displayed to the screen
4 i1 r& G, J- i; I) t          {: @$ u6 {+ B' P8 m
                    ex.printStackTrace (System.err);. O* ^8 G3 h8 B; m5 r
           System.out.println ("Error message goes here"); // Replace this error message with your own         
1 K4 F  |8 y5 ^' r0 V3 y        }
2 e  z" ^6 O* T0 E' M                return true;
; K/ a- b$ _( `; v+ h        }
+ b/ l, J' g. w9 g
5 q8 d9 g0 r: ?} // end of class ProgramCompare) i# w  B/ x/ [( n" V/ V6 {" D
2 i( {" k$ k. ~1 r7 v+ {) }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
6 |: a7 _% [& i) _2 \6 p# d//  ProgramCompareMenu.java    Provided by: DRS
& P" v6 n5 Y* E) D+ s' U7 ?//
7 D9 Q# i6 t4 b7 L  q$ P//  Calls AuthorisedUsers.java and ProgramCompare.java# C8 [; V) z; y6 R8 G: @
//
" V( _1 W4 i' C//  Driver shell for Assignment 2.
* h% Q- l  C# R0 `1 P//********************************************************************% p/ A2 Q* G3 R, x

/ y* T$ w& Q7 p8 E) kclass ProgramCompareMenu
! g# n9 T9 }  [{
+ p; D9 d4 N/ c# t    public static void main (String[] args)
( k) R% `6 k! H+ T' O! H            {# g! Q. K5 U0 I  f; v, W
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- [1 Q* K3 V" w0 L- v& I
                ProgramCompare reached1 = new ProgramCompare();
3 j3 i0 [0 F. X% K) U: ^                AuthorisedUsers reached2 = new AuthorisedUsers();        : S* j: M7 y2 B
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 C# \7 F7 e! u# o- F6 t* c
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& w: H/ F0 X+ }' P$ l8 X6 \3 |        }8 X2 g0 N) k! D
}// end of class ProgramCompareMenu7 Z: `6 q5 A* Q# [. ?. ~
* T5 W& V+ D/ @0 T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 x- h8 p% q: f* K3 v$ t
//          AuthorisedUsers.java          Provided by: DRS
# y2 s2 p4 ?5 Z//               
, ~9 O! ^) t0 ]2 i  r4 y5 _6 L//         Program shell for Assignment 2( D5 s3 [* a" R9 i3 b- G
//
% ^/ ~# }" z! Z5 v: Z/ P//         Represents facts about an AuthorisedUser3 |+ Z3 s9 `  K4 ?
//********************************************************************) G6 p$ u) }( t- O
4 O2 J. c7 t' j! N8 ?7 z2 Z* E- I
public class AuthorisedUsers  B2 g' V, a& y
    {" V2 F" L7 ^7 `0 J$ v

9 i  I2 \8 D( z0 v        //-----------------------------------------------------------------& V  c/ t1 {; q9 v* `
        // Constructor4 O( \  e% B0 w$ r$ u# ~/ ^
        //-----------------------------------------------------------------2 G, d. E, n$ D* s6 {

' Q* v5 _1 K* g" O4 [/ l3 Q        public AuthorisedUsers()* C7 f& H1 o) a1 n( e3 c" [6 g
                {' g* e: r, i7 S* L* C
                }
. X6 u. w0 P0 w( s+ i( y  @! ^! q% h# k- ^# c) |7 g- O. D* P
        //-----------------------------------------------------------------
  [* w: X- P- [3 a5 E# `5 w        // Method for testing that class has been reached
( p+ ~% k+ y: t' w: H7 a        //-----------------------------------------------------------------       
0 H; ?; ?1 I& Z3 |$ q. \        public boolean AuthorisedUsersReached()
  ?7 i: P4 ~5 W! [5 L: I1 C                {; K8 [; j/ I  |& R+ n
                        return true;                       
+ \. x" k# d( V                }8 ^, M1 d! Z1 o9 T" x8 `2 O) a$ _
                0 \$ h1 |1 h) p5 c9 [
    } // end of class AuthorisedUsers
( C1 D: l1 q6 g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" K! F1 _; @. p( D6 u' V
Shanghai - 20070 p0 r# V" x6 H6 e! W0 I( g5 g
Assignment 2
8 \/ s+ C# ?6 ~3 }0 W4 r8 xDeadline 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)
+ N* x8 W' B- g$ V5 n1. 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.
! h; D# {/ e% E2 A7 d4 @8 ?! g* C2 mThe staff must be able to:
+ I+ ^8 o2 C3 f/ l7 {- M) _ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 T* ], Y+ d3 b# O, p+ b: F& h! J1. 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.
, [+ h! C2 Q$ D: { The interface should provide a menu so that the staff can:. W% P: Y1 h& W% q+ ^/ Q# v
a) Enter the names of the two Java program files to be compared
, a" Q! U3 X9 f: k6 b- E For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 o9 A- O7 a8 \4 V, ~
** 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).: v' e( f; d8 _( p$ }
BSA104 Business Programming – 2007: Assignment 2
* g$ o) v' c3 D* k' E2 }Page 2 of 51 x# R5 \1 ?; r: X3 s7 y
b) Print out to the screen all the lines of code that are the same: ]  n1 j' k2 s* i
 Include the name of the file and the line number of the code being printed for each of the two files
3 f  k8 x) X6 kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 w* t- I! t+ _, V2 Q" C  X
 the name, username and department of the user" u. j. o+ G2 v, s% z6 k% F4 |
 the statistics of the comparison
" o/ P5 \' X% X  s& T2 U- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 o$ n8 }6 o- e4 {3 O. E4 j
 the recommendation for further checking
( v  T3 ], i9 r. t) r8 T% ^- 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
9 v8 C  [; V& M7 k/ y the names of the two files compared
4 C( S  i" _0 y+ K+ _# bd) Leave the program (exit)* ^( I: O  D4 v/ j+ Z
The ProgramCompare class: (Total maximum 20 marks available)6 h, d* U$ e. v1 j/ L
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)& l, c; f  [# ]0 L7 w
a) provide an error message if the files are not found or there is a problem opening them$ A$ n8 j' {* `
b) compare each line of code; Y% }6 U; W5 @; ~& R
c) print out the lines that are the same6 L! v4 q6 ~% Z
d) count the number of lines compared / lines the same7 _; l* n4 Q& ?4 j/ v+ E# x
The AuthorisedUsers class: (Total maximum 20 marks available). M0 \1 G: r) \' h. o4 i& [
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)0 {% K4 K* o& H, ~7 e
4. Provide methods to:
2 J8 e) L* }  w/ }2 q3 ka) 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 ~  j4 P1 x; O) B/ u( z6 e
b) return the name of the authorised user
$ y, C4 S7 Z: D0 i# t# Xc) return the name of the department of the authorised user7 n! C& Z/ K0 ^- E7 J5 m+ V
Individual Data (Maximum 20 marks available)
+ S- g3 u1 |: L+ 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.
0 i6 M/ G: w3 A7 tDocumentation (Maximum 10 marks available)# j6 D( _) S$ ?! }8 E; ]
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.
2 W5 x$ \$ D) i7 iBSA104 Business Programming – 2007: Assignment 21 @$ ?' }9 f. ^6 D* P- m
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 D, Q" x# h! `4 d不过你要翻JAVA的类库说明。你有下载没有?8 U! F8 I. f* S, u8 J! E" y9 `
查询关于对比的函数。貌似关键字是contrast,还有compare
: g1 a6 ^/ Q+ @1 D$ G2 E/ f, \  @0 B( g( v% i' @
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' n6 S, n& I9 O" m* v! v* Q+ K
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 ^! s+ i/ T1 w9 k8 _1 G, c6 ~9 g# n可以下载到的 是 jdk-1_X_0-doc# e5 O( h( X2 `/ ~( u
! ~: `: z8 p9 X/ ~8 k9 B( r0 m
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-11 07:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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