找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1460|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ; @* ?7 @* c& |. J) Q F- Q( x+ z- v# F8 `$ Z& ?0 q) 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 | 显示全部楼层
//*********************************************************************6 s: {+ B9 r2 F# H0 J$ D
//  ProgramCompare.java         Provided by: DRS
2 ]; q) @, _, ^//- i# k$ J( D" X+ c/ j$ T8 p0 e
//  Program shell for Assignment 2
, L# r% A) p( W7 ?, ?2 ~//
3 y3 f$ h2 z3 e4 x  ^//  Compares two text files line by line
6 a: n; J7 I0 r( h//*********************************************************************1 E! [1 s2 q: _. k, N- z
# v2 W* U# Z% j- J
import java.io.*;
+ |* c7 ]: ]- n5 K9 v+ N8 D, l
% u1 T' F! g$ o& D" r2 ypublic class ProgramCompare' |, w4 n. U" r% S4 k
{5 f9 c0 @% ~; n
        //-----------------------------------------------------------------5 p+ J# `! |; K3 Z) d* k* m6 J
        // Constructor; R/ U) l  a3 P. s; O
        //-----------------------------------------------------------------
* l/ R/ X. h3 d: l3 [! D7 }, B  ]% s        public ProgramCompare(). u4 Q: x5 q9 q* {
        {
2 M. \: K6 z' K, `/ A        }0 ]$ q' L) s0 j  T: o

0 P3 H" g% `# o' r        //-----------------------------------------------------------------4 H2 j; J5 @$ @( a" G6 N3 I4 [1 p2 n
        // Method for testing that class has been reached
% ]4 }& ~+ V" \" |+ _; w& V        //-----------------------------------------------------------------       
& t' }. q$ ]# y& ?7 S4 a
. N0 y- v2 @  N' K2 `7 Q        public boolean ProgramCompareReached()        
0 s0 b5 E/ I; e        {. Z; Y0 H( d- Z5 j
      try
. f$ k7 x+ V, v6 r1 H: L4 `   {        
4 K4 b" c6 a- f, z: E: M                        - O4 z- ]4 J; @
                //********************************************************************% Y& a& @( q+ p$ [8 l' M6 i
                // Try-Catch Statement is used to handle exceptions - such as file not found 7 ]4 S' g$ [0 w4 @: I3 m
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
' ~; K8 M" M! K+ S8 h) I: m3 n                // For more information see page 534 of the textbook
& g, E$ z9 x. \0 h                //********************************************************************; {6 H! m, B0 E- L+ p3 d- W( l. F
                     & }- Q+ X# K& V3 }$ A* g
        }
5 U0 l' ?/ B1 @/ d/ h: l3 Y             catch (Exception ex) // Exception caught here and message displayed to the screen * b% K) ~4 t) V% a; M
          {9 ?% K; f7 H$ Q2 O9 d) e, R
                    ex.printStackTrace (System.err);6 s4 o9 Z* [& i* G
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- r: ^& b- I; ?        }
, ?6 _# Q7 w2 m  l9 ]                return true;  y! B1 d  W1 }8 L# [
        }- a$ H2 A! r4 u: B
3 C8 x8 a; ?" ^3 n
} // end of class ProgramCompare
' s5 X, U, O# }: J$ I8 \; I. E) O0 e, V
8 b5 A4 z4 o! C$ i$ `- G; w% J! b//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 a2 `. j' v0 d8 u% c* A9 O//  ProgramCompareMenu.java    Provided by: DRS2 G0 S6 f5 z- K' b& H5 u2 u' g' s$ D
//& H$ P7 ]# B5 L" n" ^% d3 S/ X
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 t: L4 S( y3 `. W//  d1 L- ~( p4 R8 w5 n- X9 h& ^
//  Driver shell for Assignment 2.
8 v# b- D% t2 j4 }. m1 P/ q//********************************************************************
& u/ o3 s6 U1 }: r2 ]# z& S7 h3 O  C
/ Y# U3 R/ @+ J. Kclass ProgramCompareMenu0 H) H1 I* u& n* ?6 ]4 B( H7 i
{
9 }1 h# n' g9 O6 g- Z7 T    public static void main (String[] args)5 m8 o' Q/ A# d) x7 F2 p3 k+ X
            {6 i1 R2 \. v: R- b' ~
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" l- D7 g2 g7 t; _  x+ G                ProgramCompare reached1 = new ProgramCompare();
7 x& O2 I) ~1 e! B/ ?                AuthorisedUsers reached2 = new AuthorisedUsers();        7 c% a' C3 n; x5 w. h" G! @1 x7 X
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  G" x9 \. g, u) v" z0 k5 \8 L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 L+ F# ^9 j  `7 R) Y& K( J        }
* [) M0 I4 H2 O0 e; `}// end of class ProgramCompareMenu2 T. I& _1 e$ P$ {# i, A

+ a/ z( ~6 @1 S# o7 L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************0 E# p5 P8 A' I9 G+ p
//          AuthorisedUsers.java          Provided by: DRS" n0 I. N) `8 d7 I$ j* N; _% k% [
//                0 O2 W# k- s6 `" h
//         Program shell for Assignment 28 ?. q& X, z# \1 H1 t2 c2 v  Y
//1 g& t( ?% N5 X8 t8 g5 l) k0 [& O; t
//         Represents facts about an AuthorisedUser- U: s' I& [# C
//********************************************************************
3 l, T: j; V8 \9 k' t* i* }; A" j) @. s0 O5 N
public class AuthorisedUsers
# {: P! k( N$ m    {
8 N2 }( e8 E- N2 K
( q" Z% i& w6 w# G5 A3 ]        //-----------------------------------------------------------------* _5 S, X( B/ s  I0 |$ H
        // Constructor" Z# f$ f4 R( @  V. D9 R9 X
        //-----------------------------------------------------------------$ p* C7 {. \/ c: n+ c

' h1 _4 x" i5 `+ _" }4 e) M        public AuthorisedUsers()
  u, j% y6 D. B1 z) X) h7 H                {
- f) `2 u; }' M0 h/ l/ n                }6 C+ C8 V9 Q7 U# F9 e0 b2 F' s

% E0 D: q: V; T% r* X& T        //-----------------------------------------------------------------" J  Q% e. P& {
        // Method for testing that class has been reached
; \. |6 l- s; Y" u: p3 {        //-----------------------------------------------------------------       
! i, J5 I8 B) A8 A) W        public boolean AuthorisedUsersReached()
, D; T2 f0 z8 Q5 C! [; s                {
* X) j& q. N6 |. S* u                        return true;                       
/ x5 v& {* s( J8 B( D                }' s% y, [. T# R, Q
               
, l4 g. p4 ?8 t, {' O    } // end of class AuthorisedUsers
: p! a2 e4 N- T$ J, m6 D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# @( r; b" {$ M) x5 g, KShanghai - 2007. @1 Y+ x/ i4 {# M( N" V9 V
Assignment 2
* g# u4 j/ k" v  Z( eDeadline 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' @6 d' |8 \) Y& Q$ [
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.
/ }8 d* l) b( I$ s! m0 r; A3 cThe staff must be able to:
; q* T( V7 I( A Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 S% `8 X3 s3 O
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.  N; Z: x8 r. N2 B
 The interface should provide a menu so that the staff can:# V5 u8 N) f0 D, p% r4 Q* L; I
a) Enter the names of the two Java program files to be compared4 U, r! a5 ?1 N4 k
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- S; E& w% `- Q; `5 S8 O) n& 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).1 [  C" J. X, w) H! C0 d
BSA104 Business Programming – 2007: Assignment 27 s2 x/ C5 g9 Q& G4 U
Page 2 of 51 ?: R3 O0 }  ^# M; K/ ?- P
b) Print out to the screen all the lines of code that are the same
# I5 Y8 _, A2 Q: Z8 N Include the name of the file and the line number of the code being printed for each of the two files2 @8 p) [* ^# f/ e/ ]( T
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared- h* U, g* [$ X1 _$ b: V4 ]
 the name, username and department of the user/ c* l( d& \, _
 the statistics of the comparison
* [1 |3 V5 |0 F! s" A- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" s0 a- t9 `& [- O the recommendation for further checking
0 z/ \* C+ y( d% W( v% ?3 g- 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
/ F! u4 a4 i& j6 H1 e the names of the two files compared
- ]- o" b9 g- Y* ?) R+ M* Id) Leave the program (exit)0 w4 N" j9 o7 V+ E; k7 A
The ProgramCompare class: (Total maximum 20 marks available)
" g5 g0 V2 O$ j( b0 `; N2. 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 ?2 x" H# Q, X1 c6 c2 |1 I: ~4 \+ Xa) provide an error message if the files are not found or there is a problem opening them
- e1 T% u  K3 D* r3 {! A- {b) compare each line of code" P/ I4 U7 C( j2 a
c) print out the lines that are the same
/ Q2 f* t2 }& o9 ~) k9 Pd) count the number of lines compared / lines the same% d+ m" h' C# }
The AuthorisedUsers class: (Total maximum 20 marks available)
+ M) T' Z, W+ `4 e3. 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)
% I5 f* e& [  j; y! K* f$ v3 m' s7 W4. Provide methods to:
9 O9 y* _( _# y: |7 f) o/ g3 S% d( _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& I2 m) P* Z: B1 J
b) return the name of the authorised user
% H3 n. z; H$ a( Sc) return the name of the department of the authorised user
5 s  e* i+ ^$ U. @0 k% u! k4 WIndividual Data (Maximum 20 marks available)* ^  ~0 f, x; z( C, i2 W
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.
( a. [3 m9 }" W9 N+ B; kDocumentation (Maximum 10 marks available). c1 S: |! J, t% v
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.+ H+ P. ^# _- v, |% @1 V
BSA104 Business Programming – 2007: Assignment 2! M% y; A- M8 h3 c5 i- B
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  y$ V+ X3 k/ d# Z" n
不过你要翻JAVA的类库说明。你有下载没有?
  {6 X# E! I. z) G- {0 E/ N4 y# ?查询关于对比的函数。貌似关键字是contrast,还有compare
  v7 g8 o$ @; Z  ^/ ?) L+ x2 T/ m5 g4 _2 M8 W. S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- W# @) Z' [7 U3 h1 h痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 ^+ k* n9 R( p6 [1 h可以下载到的 是 jdk-1_X_0-doc% W! \% u$ f6 `1 Y. ?

. K( l1 o8 |3 }# j! L' y4 o[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-16 08:58

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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