找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1418|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' Y) l9 O0 {4 R) S 7 q/ b( }3 T$ Z3 S# ?: \0 n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************- o9 K# U$ W2 g( }; e
//  ProgramCompare.java         Provided by: DRS
0 z1 @8 B, _6 l; d5 k//" D6 C$ H# W! r0 c4 M8 b
//  Program shell for Assignment 2
4 t/ Q$ V, m, t1 v//6 ~# r, c$ ]6 Y; [- i/ H
//  Compares two text files line by line
  b& A* ]) a  o- \, I# {//*********************************************************************" U1 g* B; j0 R* H4 G' N
$ R$ l) i, n) p- M
import java.io.*;
8 ?2 {+ [& C9 x% P" c
) w% V/ `5 i$ F: G7 |; I' Zpublic class ProgramCompare8 A! X# Q* g* y2 r
{
4 u* L% Z  Z, P$ G        //-----------------------------------------------------------------
1 P- e7 ^  Y5 ~3 _        // Constructor3 J7 o9 l! g) ^2 W0 T0 N  d/ O
        //-----------------------------------------------------------------
) w+ f0 U( ]+ _  d        public ProgramCompare()8 ~- m  ]1 h: ^
        {) [9 I/ W9 d+ c+ F" H
        }
$ @: M2 X- l* d% D  N  Q' R) }$ k7 e0 t5 P
        //-----------------------------------------------------------------
5 L* y8 z$ x6 Z9 z" i0 X        // Method for testing that class has been reached5 @% x: `+ j6 c% y
        //-----------------------------------------------------------------       
1 O" Q, U0 f/ D0 N
  f5 q+ _. y0 h/ Z1 p        public boolean ProgramCompareReached()         , j2 E4 @: S& c/ L+ [; p! y( B
        {
2 [: D: X8 K3 q      try
! ?* h! @4 z9 n. U9 Y9 Z- z   {        
; P+ U& @0 r$ A                       
( l1 Y$ Z: l) k+ v0 h4 f                //********************************************************************
) p$ v: `/ ]4 o                // Try-Catch Statement is used to handle exceptions - such as file not found * a: {9 {! ~* @- P7 k7 ]1 |1 b, L4 c
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- P. W4 N* `: x+ _% j/ J: y
                // For more information see page 534 of the textbook' Q8 F" R- p3 R: e3 C, ~8 A- a
                //********************************************************************
+ P* ^, \8 W: e/ z. y                     " E, L/ ^1 L6 Z$ x  z9 C
        }
* @2 j" D6 Z# b& v6 g- b+ `- `             catch (Exception ex) // Exception caught here and message displayed to the screen 5 q$ d& c7 J5 M6 ?
          {
) W& r3 B6 ^2 U                    ex.printStackTrace (System.err);
! q. V0 k0 I' z# ^           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ U/ u" h* ~* J. x        }
4 \: [; X- s( A                return true;
" ]5 j- t) Q* U6 i        }
# n8 ^2 \& F9 J; r
2 J' m( P# O6 o) F* K- q} // end of class ProgramCompare- g6 o2 ?) ^1 s1 m/ L" X

: u) l+ n  k2 O& K* c; G- L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. u7 i6 W+ R9 e9 C* N1 t0 C7 l, L
//  ProgramCompareMenu.java    Provided by: DRS: f! j2 @/ O; O5 `
//
! y$ h2 S4 P& n% M//  Calls AuthorisedUsers.java and ProgramCompare.java( w- r; }& ~) }0 M% v+ l0 S
//
/ P! O* y4 p6 G) U+ K( _//  Driver shell for Assignment 2.
5 E1 h9 n! ^, i" x//********************************************************************5 N  T7 a; Q" g
  u7 @' N. g+ o6 W) C
class ProgramCompareMenu/ t8 {  W: ]/ \# h& ?
{: i7 U6 W' D- b, R
    public static void main (String[] args)1 Q0 V! W+ B6 }& K7 p3 J
            {
( U/ B0 x) V+ A/ r" r; o                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 o, f3 v7 d, @/ K  y3 Y! L                ProgramCompare reached1 = new ProgramCompare();
4 E& R9 ]& b, U; O                AuthorisedUsers reached2 = new AuthorisedUsers();       
" i. C0 s1 ]. `( h                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. p" ~+ W, p  @# f/ d6 B: z
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + R: K6 A' P5 C8 U- u0 B3 S
        }' Z9 M0 f) {* ^2 J6 s3 f
}// end of class ProgramCompareMenu
& Y& Q9 V% M/ G3 `) _) i! V6 R
$ S3 Y+ V( y  I: g  H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" b" U( R- j7 s3 |0 K//          AuthorisedUsers.java          Provided by: DRS, y9 d& K, {- W- Y# c# h) y# F
//                5 ?% Z. k. [0 P+ l( D# J
//         Program shell for Assignment 2
: J, q6 m3 k; g5 {; d5 z//
  c# J: X& E. Q3 d: ]; I. i//         Represents facts about an AuthorisedUser6 a, c; k( k8 R
//********************************************************************& f: r- [! z* [9 c

1 t) _3 }! U$ }" ipublic class AuthorisedUsers
% [! H, s4 u. e0 {) P) s    {, w  y; _7 K4 b0 [$ r
, {9 v! V& q3 e; b% f' u5 @
        //-----------------------------------------------------------------# m% Z5 R  N. }& c- d- S
        // Constructor6 l7 S' S) m) y9 u* o
        //-----------------------------------------------------------------
' ^7 u! `: Q+ f! Y" N" o% i( z# r# H
2 F1 `7 b5 ?2 ]9 N  Z$ E        public AuthorisedUsers()" W: x) C! D2 S, a
                {
1 i: p: O4 V2 `0 s7 g  \+ o# `! r                }
; b8 A" [+ A4 Z) {
& q* L# h0 K/ B8 W4 i        //-----------------------------------------------------------------) c# A6 }. {6 x* a" y+ c
        // Method for testing that class has been reached9 n% T3 f4 l; e* c# o
        //-----------------------------------------------------------------        2 R2 i; n. m# _# a8 N- s
        public boolean AuthorisedUsersReached()
5 q9 X5 @: {# r1 p7 e# _( A                {
( m6 u- ]+ M8 S  C- ]) U# v+ F: f; F                        return true;                        + O+ r- R& L( G+ x
                }
0 ?. d$ N0 K' J1 o. p# M; M               
6 A$ y  j5 F5 \! u" A    } // end of class AuthorisedUsers
( t% |6 |  |1 \6 H6 `: k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
% B' K5 o9 u, f  @' vShanghai - 2007
! t9 \- z2 @. y4 ~Assignment 23 {6 w- J/ r( }
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)/ k1 r7 w: f+ q5 ~  X
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.
- I4 }) r% c' A8 O! jThe staff must be able to:
) H7 W' A0 n. x8 U. [4 S9 S% v/ d  F Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& A: j2 a# y3 U! U. V; M$ g! _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.' Z3 l! K( M8 u8 w6 ^
 The interface should provide a menu so that the staff can:
: {& _+ A$ l7 |! M' S' ?* [  T8 ea) Enter the names of the two Java program files to be compared( _9 V! E" s' k- r4 j. w, Y
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- m; c4 o! T8 @1 r** 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 }' [6 k9 r! t9 X9 ]
BSA104 Business Programming – 2007: Assignment 2
3 p' Y' O1 c5 U+ x3 Z7 UPage 2 of 5; Q8 s: e8 o/ K/ E, p$ O- @
b) Print out to the screen all the lines of code that are the same; h- [. B/ O1 f& }+ V7 h0 w3 a
 Include the name of the file and the line number of the code being printed for each of the two files4 n  [! F/ o% \4 G! q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; W! T' Q: d8 J0 z
 the name, username and department of the user
5 r( |( S* M. a4 U# n/ X the statistics of the comparison$ A/ I9 m1 t8 d3 h9 v
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" R, w: U. {; P the recommendation for further checking
! h* O  K4 j" K, D" i/ R) _3 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! M1 K# V! J1 F" K9 P
 the names of the two files compared5 ^5 |8 m7 }" a4 m6 A1 D
d) Leave the program (exit); A4 j( S2 K  E2 q% u4 S- x. g
The ProgramCompare class: (Total maximum 20 marks available)
7 h  I9 k' u! K2 u+ L- h% w2. 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)  a3 Z$ M# {& `3 ?5 X, @# I" ]
a) provide an error message if the files are not found or there is a problem opening them1 U' @; i! J) P5 j- D. H
b) compare each line of code
, m  n; W' v: X  N$ Qc) print out the lines that are the same
1 D( B# S0 Y) }) x1 _d) count the number of lines compared / lines the same
# X9 W' o0 \: g  qThe AuthorisedUsers class: (Total maximum 20 marks available)
& f! \6 X/ C% l# b3. 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)
* _) ^+ j. \# s# T4. Provide methods to:
; b" R% o1 y  c& U3 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 match
7 U2 `- M7 e: |- s; f7 ?- ^( yb) return the name of the authorised user
  I3 q$ p* ^( o* J2 }: Qc) return the name of the department of the authorised user: `0 K' u8 u( Z# V" O4 p& t  o
Individual Data (Maximum 20 marks available)
/ j5 T7 V2 ?3 n2 r5. 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.
. I# u9 d( D" |6 L2 BDocumentation (Maximum 10 marks available)  M0 Q5 O; Z! q7 U( R
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., K3 S$ k/ {: P0 z; l  \5 T9 a
BSA104 Business Programming – 2007: Assignment 2" E6 O, `: p; Z( g& i
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( R& Y2 S0 o3 O不过你要翻JAVA的类库说明。你有下载没有?; m- P! S# |1 d; y* U
查询关于对比的函数。貌似关键字是contrast,还有compare) X  W4 K! e2 c; q

$ Z1 H( c# k4 Z, ]7 y1 p/ V[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 y6 X- R" s: E* S) |* i' J痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
6 o$ z. h+ b( E可以下载到的 是 jdk-1_X_0-doc$ F. z/ F- w# V. g
4 u5 o  ]2 k  k- ?# d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-27 02:44

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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