找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1800|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 G6 K( g( m* I ' \! S8 H& a: Q F P# B
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& f# g" g2 S: b; |' i//  ProgramCompare.java         Provided by: DRS
, q4 Z3 ]* W* @& [& o/// R0 A; y5 s2 H3 ~! U. K
//  Program shell for Assignment 2
- q/ Z7 z- D& n( K1 E* H//% R* g2 ^' m& M% q
//  Compares two text files line by line
9 s5 [9 L9 w" F# I//*********************************************************************
: d: M- z& K, @2 }
2 d7 G* p1 z  \/ q. l. Iimport java.io.*;
% @! m* E0 _2 C8 T! {5 N
* l/ G. v# c- m  q/ g  y& r5 C1 spublic class ProgramCompare+ ^  ?$ ?7 D0 i$ s- q
{: f0 Y9 u' t+ K1 A
        //-----------------------------------------------------------------
+ ]+ T# w( L1 ^5 {8 ?/ y        // Constructor
4 }1 d+ l" V$ |8 s/ m: X6 ]        //-----------------------------------------------------------------7 E( X( X) _+ u0 ]' N6 L
        public ProgramCompare(), z/ N# o  L: T9 y1 Z+ g9 h/ g
        {. O: m- |# S* J5 j! o* r* P
        }3 ]' i, ]& R; p. _
9 w- @9 k* Q# Y0 [) G
        //-----------------------------------------------------------------
/ w; s: V! }9 [  m& W6 H        // Method for testing that class has been reached
. u9 U+ G9 }' b- c4 q        //-----------------------------------------------------------------        ' R/ C( O& U7 |1 k! B, j2 x
5 ^' U+ G, X3 F2 y2 k4 F
        public boolean ProgramCompareReached()        
/ T9 k- P7 W, Y' P1 y8 w        {5 I! ^- `% H0 O" q
      try 5 V+ G2 b7 a7 u4 K; U
   {         6 g( T' x- O5 U  ?$ f2 @" A
                       
* M- ]9 z. H1 ]0 E( f4 w                //********************************************************************
: F- l0 H, ]9 C) G$ ^9 v" p4 ^                // Try-Catch Statement is used to handle exceptions - such as file not found
4 T- L, R- ^2 o. n# v7 z/ L                // Reading the files will need to be placed inside a Try-Catch - just like this one!
! k. e, r8 F- U' P% |3 u8 i                // For more information see page 534 of the textbook& i$ J+ l; O( ]& [
                //********************************************************************
5 E8 I) @/ `0 O+ T( a  T) d                    
9 |' e: ?: u! a8 Q& R        }# R1 P' d# b: I. X: N0 h( B
             catch (Exception ex) // Exception caught here and message displayed to the screen
5 s9 E0 h1 b3 z5 L          {
* y+ q: a- A, H6 |& ~4 r                    ex.printStackTrace (System.err);
# o! T! a" Z7 Y5 a# o5 ~& Q           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 E: j& E) X2 h" |3 U6 ?% X- z# t        }
( s* o5 A3 _7 H                return true;# Q) r: |) F0 D
        }
$ v' A9 A9 A. o* R
5 {1 }+ f  l: U% z# F2 q} // end of class ProgramCompare& I. |, S9 u+ N$ ^; {

; R4 z/ C: l0 h, F  C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" X2 |: W# j4 U* l, i# ?" v; g6 [. ?7 v
//  ProgramCompareMenu.java    Provided by: DRS
, X* P: a$ a0 b. Y6 H5 \- E//3 s+ }2 W" W( X% A# l
//  Calls AuthorisedUsers.java and ProgramCompare.java
% S  O8 U  @0 G) b+ [  [4 G//; g0 H7 `/ j+ x* B
//  Driver shell for Assignment 2." a, m  _4 q* k5 C3 [/ C
//********************************************************************
0 z0 W% _7 d/ ^+ m! t1 ?7 ]+ U  Y. G
( h8 m# j4 t8 h8 T, Q+ R" xclass ProgramCompareMenu
# S( R  V4 V" M4 h5 G, E4 k{
- N* v% c# h" {! H# h+ W) d    public static void main (String[] args)
# s( d) `4 H; G2 ]3 v2 M4 H            {% s& ~# Z  z+ R, H* q
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 i  _) H  p" i1 e) C6 C, x5 ]1 |                ProgramCompare reached1 = new ProgramCompare(); / }  f' H, i% ~) x9 Y
                AuthorisedUsers reached2 = new AuthorisedUsers();        & D9 V/ J- a. _7 B: s; D
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' {: h/ `4 r" W  z5 g7 Z) y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        6 {# D' W  g$ [; p  P. n, a
        }
% \: B. N' l- C/ T* L}// end of class ProgramCompareMenu
! A' K% f; c, t$ t( `5 J" j5 |/ H4 j1 ^" J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. X8 o1 k  F* w//          AuthorisedUsers.java          Provided by: DRS6 F7 L) Y; s7 A+ f! J$ d5 k9 ^
//                " x) t! W# {# q* Z1 @* j
//         Program shell for Assignment 2* g/ K' X! ]5 b/ k2 V/ t) }% `4 e
//8 @* g' k5 L& e- \) }/ Q
//         Represents facts about an AuthorisedUser
! a+ D: q2 f7 t# [& P8 V# G6 `//********************************************************************& _6 P& r" o& H. x& B' v

! }4 |; t* J" h( n2 apublic class AuthorisedUsers
: ]) N. U( {1 I: y6 K8 y    {
. S3 @: n( {9 T6 ]$ A
0 v" |! ?7 Y, G/ L5 U9 h# F! B        //-----------------------------------------------------------------
% W" G9 |' v. C3 Q" u! G        // Constructor
; S2 ~& K" u2 P        //-----------------------------------------------------------------
' M6 l- j5 H3 A- T5 b' a8 n! N/ O2 }  F; V6 ~
        public AuthorisedUsers(): |4 J$ H/ e8 m4 p
                {
, v. j+ u, d! A% H9 h: M" b                }
! R1 t. L& i/ d; E, N  |- o1 ^7 X5 d+ a
        //-----------------------------------------------------------------
! F+ r2 T9 ~. z! ]* x* w        // Method for testing that class has been reached$ r2 D+ d1 H$ ^/ g" R
        //-----------------------------------------------------------------       
; A" C8 `: h) I! k  y9 t        public boolean AuthorisedUsersReached()
( C5 k8 z, s4 f; j                {8 b7 F% b8 I0 i' f2 O2 ~6 a: [; `
                        return true;                       
, e: {% M) T2 |- [0 z                }
+ U* `  O) p6 m, z& d5 u, h/ b                5 y, B% {: A& ~0 J, ~2 k
    } // end of class AuthorisedUsers0 o; T6 m* f  T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming6 G3 \; \- @$ I1 J" A" j
Shanghai - 2007
2 m( W  C$ F, }4 e% M: qAssignment 28 D- A# u4 L$ g3 ?. 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)! I( i: D) m- Q! n2 {  @1 V
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.
7 c6 O& i" N/ {! C2 j+ _The staff must be able to:7 c( o! G& ?( @" Z" y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* u6 X8 M5 A, d& W1. 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.
( @6 f) {& I) ~7 M! O: e The interface should provide a menu so that the staff can:# E( H3 n. J# v! J& t
a) Enter the names of the two Java program files to be compared% {' l8 j* P  e9 V! ^1 L
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( u/ Y/ a8 ?  m' T$ t$ N
** 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- j2 P; M2 B/ P, KBSA104 Business Programming – 2007: Assignment 28 k, b1 ~# ~& q  A7 H3 ]2 d
Page 2 of 5
. ~) E: v. G# c; E. eb) Print out to the screen all the lines of code that are the same
+ \; L1 ]0 Y5 X Include the name of the file and the line number of the code being printed for each of the two files
. D8 ~5 w/ Q5 q# _. J* i* _c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 z7 l9 X6 z+ m- X+ A
 the name, username and department of the user( Z1 Y" J- x8 [2 A
 the statistics of the comparison- i% [: P# y' N1 N7 {
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 P7 ~+ J3 ?# _' t& l( R; I9 J# n
 the recommendation for further checking
" D5 M0 |7 a1 D& S  k9 H. j3 r- 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* y  o; p, X+ p! A9 r
 the names of the two files compared9 z3 }$ F& C* r
d) Leave the program (exit)
5 Q( [# p0 a! F% [9 J" F  r- w: m* eThe ProgramCompare class: (Total maximum 20 marks available)4 V- b) b+ m* n* C  U1 Z
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)
8 ]# U; a, ^/ H) k* ua) provide an error message if the files are not found or there is a problem opening them9 [, `5 Z+ [% U2 ?5 ?( I5 b
b) compare each line of code
* ~4 O& \- q* k* v) ?: Bc) print out the lines that are the same
7 O" ^' J. F$ ?6 Q/ yd) count the number of lines compared / lines the same
6 S* O; U( E" e: V5 D$ f8 h+ dThe AuthorisedUsers class: (Total maximum 20 marks available)) {/ A6 ?5 A# n+ W9 {+ p# ?* @% B
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)
8 c& }1 D% K$ F/ B5 r( I4. Provide methods to:
5 u* S  a6 }: ^" k: U6 g( Pa) 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
. ?! U4 S$ p- p1 N! z0 ]b) return the name of the authorised user
9 K5 y2 p1 p  b  O, b- D5 Fc) return the name of the department of the authorised user
9 J  U. Z3 U: m% n& {' k9 V3 k$ A1 jIndividual Data (Maximum 20 marks available)5 c$ _/ Z0 W3 r3 @# f
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.
4 [! X+ O4 s9 r6 XDocumentation (Maximum 10 marks available)8 u  T! s% a, _4 w5 s% k& o3 H
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.. G8 L  j0 E2 }: d
BSA104 Business Programming – 2007: Assignment 2
+ ?( J: }% S' H# pPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. |# g9 F# S) Q0 E不过你要翻JAVA的类库说明。你有下载没有?4 o  g- J3 f- _. `6 Q# a; p
查询关于对比的函数。貌似关键字是contrast,还有compare# }% }- b- M7 D2 D4 o! s+ E

: M  |* _" A4 U8 H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -. L6 t; M$ T$ @; B
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。* U6 f# D1 m$ e8 R  A& f
可以下载到的 是 jdk-1_X_0-doc( w. Q  w* A9 D7 P
$ k9 D2 _1 l$ l2 P: b) {* D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-4 17:39

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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