找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1336|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ H& q; i+ a7 v0 Z# F8 |# Y9 g4 c % W+ I4 ^7 G! c3 D4 @
回复

使用道具 举报

 楼主| 发表于 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 S1 @5 U/ Q5 T/ p) q
//  ProgramCompare.java         Provided by: DRS% x& ^6 G8 p2 \
//' N/ Q) z5 S5 k+ B
//  Program shell for Assignment 25 N/ m0 H& \0 k$ `" u6 R5 i) s
//
4 M4 D& S, E( z+ E: D//  Compares two text files line by line
) l3 l3 x6 q" t( l8 E7 `8 F+ a//*********************************************************************3 b: B# m- u4 @( J! V/ a

2 ~/ I5 a% q, t/ Z; z  e8 C* iimport java.io.*;
5 H7 ^! J% y. ~4 g: ^$ O# t2 Y) K, s) G$ i1 L) h5 K
public class ProgramCompare
; q9 ]  _/ W& o7 B& [{. X8 I' F& s+ o' Z
        //-----------------------------------------------------------------6 z/ a- q4 c7 @1 b! M/ T
        // Constructor0 N: T0 \1 J8 p8 a
        //-----------------------------------------------------------------2 ?, n0 B! S9 Z5 X: ]9 w% t
        public ProgramCompare()& u# K! v2 G% H4 B
        {
) ^0 q5 T0 k. _  ^* S4 G        }
) ^# H8 F0 g  K5 ?2 H% u( ?  C, x& Q) u4 O( E8 q( c# F; O
        //-----------------------------------------------------------------
/ ~$ V, G( x+ b% `        // Method for testing that class has been reached- d; n+ M$ V+ ?; u3 o4 ?7 g/ J# y, A
        //-----------------------------------------------------------------        4 N' w8 v4 y4 G  k, r* q8 E

! i* m4 y3 Z, l+ g        public boolean ProgramCompareReached()         0 J+ d$ c$ r" t4 [9 U$ c3 h# u
        {
9 w  \! E+ b7 K6 x# K      try + k# X" M' G0 m% k1 b
   {        
8 M: S. e: D2 y                       
% C2 ]2 b0 ]4 X  }' Z                //********************************************************************* i4 c9 h% L9 _7 T! w
                // Try-Catch Statement is used to handle exceptions - such as file not found
( C) a) K" M( y6 x) L* D                // Reading the files will need to be placed inside a Try-Catch - just like this one!* }! K( h, w+ T$ g( f
                // For more information see page 534 of the textbook! F0 A3 h$ n5 P) m6 A0 n% G0 u
                //********************************************************************
, \. a$ o1 N9 b  m                    
* U) Y+ D% P9 L( g3 Q2 \  ?        }5 K/ I7 i" x- }* j8 y
             catch (Exception ex) // Exception caught here and message displayed to the screen 2 ]/ ~0 a- O; l9 x% r- q" y8 ?
          {% b# q/ g- Z# S& T3 O  h
                    ex.printStackTrace (System.err);. K/ E9 t* o# l2 O
           System.out.println ("Error message goes here"); // Replace this error message with your own          % F+ ^) B% b( M) v
        }
9 R% @. V& a6 m! [" {3 h' c                return true;
2 F8 M1 Z3 f* m# f        }
9 @  _5 I% n, \8 i2 W
0 p& S+ K. h# ?/ f# [} // end of class ProgramCompare$ B( R! a! l5 i/ R5 }  @

# C6 p* _/ L+ `8 [: b, [3 f( k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************5 k. \, q. ~4 |0 s5 e
//  ProgramCompareMenu.java    Provided by: DRS+ }7 r6 Y2 g  e- T% C9 J6 D! n
//) a1 ^7 P" t! r: }& ?2 w
//  Calls AuthorisedUsers.java and ProgramCompare.java
- B2 g, w7 f3 ~1 [& m% p; u7 w//' L9 \5 v$ C1 G! N2 S
//  Driver shell for Assignment 2.( A5 |* n' c( u8 s' G
//********************************************************************9 x& y+ R6 A- x, G! l9 Q1 d

+ l' i3 c) m' A; X% Cclass ProgramCompareMenu: P8 \" H( d+ |3 S
{
7 ^( f3 O+ y8 g- |    public static void main (String[] args)
1 r8 \* C0 t$ y9 i% I8 ~  \) Y            {
) q) i+ n: [1 H  _' ~- [                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 N3 N6 W0 T7 A0 ^- }* W, C; h1 P
                ProgramCompare reached1 = new ProgramCompare();
1 B7 X7 p6 r7 {. \* w' C+ U1 P8 b                AuthorisedUsers reached2 = new AuthorisedUsers();       
' \3 e( n/ G  Y" @                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
' [% j! v; Q8 Z' ~) X$ q  o% x                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- E+ a+ b7 Q# o  h4 z: R3 w3 w8 M: m        }
- w) N$ N3 {2 f3 ^}// end of class ProgramCompareMenu# L7 k/ O( ~3 Z- p
, I2 \4 L8 v6 V4 a+ h; B
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; a& f: `" u% z/ |9 n, i//          AuthorisedUsers.java          Provided by: DRS6 I, M) t% g4 p( A: _. `" W
//                ( }4 T# z1 w1 ]6 X1 v
//         Program shell for Assignment 2
+ E' O$ g- _9 L: }//- r4 B2 B1 l! \% h
//         Represents facts about an AuthorisedUser
; x0 I6 D2 }: R) ^# B//********************************************************************
' x" I- x+ |4 d8 d! f% V
0 s& ^& ?- q# E) T, Lpublic class AuthorisedUsers
$ u6 S& ?1 t2 N& G1 h8 u    {
- C( E" v- Z; j& M! d! g9 @7 m& p
        //-----------------------------------------------------------------
8 |, ^7 G% ?+ e' c5 G; c        // Constructor
& }  U6 O6 d  ~( }) \1 N        //-----------------------------------------------------------------0 P) }% ~/ B( O3 b

9 P  q) g4 ]4 a0 W" ^. U* t5 P        public AuthorisedUsers()2 W6 o! J$ R; J& C
                {
& F+ `/ P6 T9 ]; G* ?5 ~                }* T& O5 Y' N/ |$ c# w& _5 R( y, s
5 T1 _7 G3 }3 [! Q
        //-----------------------------------------------------------------3 r+ V8 ], V! {# g. F7 M& X, l
        // Method for testing that class has been reached3 v8 X$ |0 D$ g& u
        //-----------------------------------------------------------------        & V6 a, b& {( G
        public boolean AuthorisedUsersReached()
  t. ]% o3 J8 I' [- `5 X" u) F                {
' n  |4 j; t% f; O. t) Z& i0 h" [7 A                        return true;                       
* N0 R6 g3 t. x) G5 q% l/ |7 k: M                }
2 H. ~" O) B# X               
0 f% l- @9 b: e: D    } // end of class AuthorisedUsers# N( H2 ^4 l% f! ?  t# D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! B5 q3 ^$ \& LShanghai - 20079 i# j6 R! e" w8 V1 @
Assignment 2, s6 S' H  t6 t, m% N. T) L2 d) U
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 s. M! j# ]7 Y2 f4 a1. 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.
" _! a6 R+ N. ]The staff must be able to:
; u9 F/ ]1 h( b8 f- p Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.8 e# e: H$ @' V: @1 b: x
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.
- J' h% x  U: b* q7 w* X8 ?2 z The interface should provide a menu so that the staff can:# O9 C. |9 t$ |, X* @' u
a) Enter the names of the two Java program files to be compared
4 U% ^2 \* ?, o) B8 T For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
3 ^( O* s, A; L" I/ E4 {9 w" R" j1 u** 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).- f2 T7 D- h1 G9 R" n0 Q
BSA104 Business Programming – 2007: Assignment 2% p7 f+ M9 J) ]; V" ?$ I
Page 2 of 5% r: M+ e  Q- P4 O5 e
b) Print out to the screen all the lines of code that are the same9 H% x. r; D% G$ K1 @
 Include the name of the file and the line number of the code being printed for each of the two files, a: \0 G8 ?: r4 n% H' Y4 d: V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 U6 g- T  ?. i* |  f$ b* { the name, username and department of the user
; n3 j1 n3 c" I& R5 _: x  q the statistics of the comparison5 i$ d# Q# e  a6 ]* q; `( ~
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 T/ r$ d6 i& A" T. ]( W# w the recommendation for further checking1 i: f# F7 B* I  ^: 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
) N- b6 h0 g& H$ W. l5 f% C the names of the two files compared
+ a- A1 m& ~) U9 Q3 S2 A: |' A3 \, Qd) Leave the program (exit)
( M0 E8 T6 E9 w! V) d$ J/ n: rThe ProgramCompare class: (Total maximum 20 marks available)7 C) W' j  I9 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)
3 x9 c( A3 O: ]  b7 w  la) provide an error message if the files are not found or there is a problem opening them
, p" J4 t; O5 w/ ]1 yb) compare each line of code6 C$ S" B! C5 x
c) print out the lines that are the same
7 `! L0 i( @  G, fd) count the number of lines compared / lines the same
) v' P1 ^; a) j6 W; b8 u9 XThe AuthorisedUsers class: (Total maximum 20 marks available)  G9 Q7 q  b9 }: a
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), A. k# x6 Z6 k
4. Provide methods to:
- R( a7 Q! h9 Q+ T: `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. B% j* W# `7 X4 {# O
b) return the name of the authorised user! I$ g( P0 W  o, w: C5 J5 o/ @" m
c) return the name of the department of the authorised user. e( D: E: I8 u
Individual Data (Maximum 20 marks available)$ C+ j( |3 w7 f) k! z5 ~  N7 P
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.% S& C/ U( x6 V
Documentation (Maximum 10 marks available)
4 n* u) b! R7 ^- j. J6. 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 R7 C; V5 u1 u+ ^& J5 EBSA104 Business Programming – 2007: Assignment 2, I: Z0 a- M9 f
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* H4 C* m$ q9 \不过你要翻JAVA的类库说明。你有下载没有?2 p# E1 k# ~% I( S) V2 n2 q! t
查询关于对比的函数。貌似关键字是contrast,还有compare3 L0 m) s. j# r9 B# A
* ]) I+ G. R2 t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' Q$ b  L5 w+ {痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* G+ L* {: d3 f3 `/ _8 [可以下载到的 是 jdk-1_X_0-doc
$ V- \1 s9 u9 I% F8 v8 D: f5 h# x$ L- \) c! v7 U0 I: f
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-1 12:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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