找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1167|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急* M/ ?. c2 H, w; j. H @0 f ^9 x1 P6 C" S7 `
回复

使用道具 举报

 楼主| 发表于 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 L$ |+ r& h3 _
//  ProgramCompare.java         Provided by: DRS3 q6 B# x$ [5 m$ \2 k
//% G  w7 A2 K" q! n
//  Program shell for Assignment 2  z$ H- F7 h+ Z  E" u" x2 H
//) n3 o. r# A# O! v
//  Compares two text files line by line1 h* z" x6 |; h2 N* I
//*********************************************************************
6 Q' G% I' o; v" U: Q9 u/ D8 k
import java.io.*;
: l! e" C6 E/ b4 f2 I& w- }" \% d
% U# X3 ?9 F- n6 j$ o; N' c' Lpublic class ProgramCompare
  s' E% I4 O' o6 Z% S{  q' r4 f' G/ l# D) V$ a3 a+ X
        //-----------------------------------------------------------------2 R, x. S- s: j# H9 Z
        // Constructor
0 N3 W# X. b. s9 x) Y( i+ v. E        //-----------------------------------------------------------------+ f1 |+ D- Y# t3 k5 g" w$ L
        public ProgramCompare()4 v1 @$ x" N4 E' M- R2 B
        {
% T2 P* x+ \% l7 E) Y7 T& O        }
( C9 P" ?. O8 Y+ P
* n/ H# @$ v" i, Q- i) b( H1 q        //-----------------------------------------------------------------
% n" B! g4 v4 s2 y9 u% d        // Method for testing that class has been reached
& N" s( Z+ {/ y: g" L2 G        //-----------------------------------------------------------------        - g) t* a! ]5 g

( _# T# j, t- o        public boolean ProgramCompareReached()         5 s  H$ W: h% ~
        {
$ J, E  F; M8 H9 m: |1 O1 x$ t" ]1 G      try
2 I6 E1 w9 ^4 E! E9 g( k   {         8 E8 `  A6 L. v3 K. H
                       
6 w) j! I# B2 J8 ^2 [  R: g                //********************************************************************
5 c5 E9 }2 A) x                // Try-Catch Statement is used to handle exceptions - such as file not found
% |; [% k3 U4 `' z) t                // Reading the files will need to be placed inside a Try-Catch - just like this one!% B/ ^" ?9 Q0 v# A8 K+ g
                // For more information see page 534 of the textbook
1 g7 ?& n; r9 c! h                //********************************************************************1 K$ ~, }1 t9 R0 l  C5 H6 W
                     + x2 c) u5 l( e. Y
        }" @3 f& H5 N! Q
             catch (Exception ex) // Exception caught here and message displayed to the screen
) D( m6 k* b- K+ q! C          {% h6 ^' r7 }+ v' F" o% o! E
                    ex.printStackTrace (System.err);+ |+ B$ P6 }- _: z' u6 i
           System.out.println ("Error message goes here"); // Replace this error message with your own         
" L' T: q' N( C* [) _& g- s, V        }
' n$ W$ X# G6 A" H& v                return true;' o, y# y0 `5 J" m
        }* \1 i+ y6 _& k, E% `

8 z) B- w. \/ d} // end of class ProgramCompare+ L) N9 h& ~/ E
  t; Z+ ~9 _/ Y% G1 i1 A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( x5 N( B9 P, D- p" b//  ProgramCompareMenu.java    Provided by: DRS
  C/ m% x; Z2 L) W) k% G//6 O+ ?, K/ D: B: N
//  Calls AuthorisedUsers.java and ProgramCompare.java5 p. D$ ?% V* a0 F4 p( ?
//- X1 e1 `& v; r. h  Y" s
//  Driver shell for Assignment 2.
& O4 @1 P- S7 k3 f+ x//********************************************************************
, T$ X  e9 b; M0 K* ?+ f( h6 z) }/ k) e' G
class ProgramCompareMenu
5 k$ A- c* z% U$ V: f  c( X{0 n/ ^  I* P; o
    public static void main (String[] args)
6 i* y8 c: h0 @2 ~  @            {
. G, o6 B' g+ R                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
3 @- ~& P  C. n: i                ProgramCompare reached1 = new ProgramCompare();
' e) p/ K4 t9 p8 H5 @                AuthorisedUsers reached2 = new AuthorisedUsers();        ( w: Y; s# B2 [( W
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# Y$ H5 N# j4 }: v. W                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        " H" U8 j$ g, Q0 W' V: m/ b
        }5 ?0 p2 i0 D3 t* ~
}// end of class ProgramCompareMenu' q6 A! G8 u; W; e1 {6 z; F8 c
. T, H  S  \5 V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 z0 h) \  z3 v/ A
//          AuthorisedUsers.java          Provided by: DRS8 Z0 G# x( {' o
//                7 a2 u4 f6 n2 |
//         Program shell for Assignment 2
( }: i/ }4 n# t" I+ l' ~//
* B9 D8 i3 d$ z! E//         Represents facts about an AuthorisedUser
1 {4 y3 L$ V2 @* k) t$ J/ S7 Y) s//********************************************************************+ S2 Z9 i: l% }/ o

1 ]% V  E0 K/ ^# w6 n, n) _. Gpublic class AuthorisedUsers
2 }! T' h2 l: B! m6 N    {
1 @. m* {4 T% `- m3 S! D" C* p( V  H! L( L' D) _0 O7 @" m
        //-----------------------------------------------------------------
! G  v1 y2 d, u9 d$ Y. `        // Constructor
3 m: _' ~5 P) J5 v        //-----------------------------------------------------------------
: D6 g: z4 T9 m; v3 T
+ j% ~# T8 m9 w; u+ R. t: a        public AuthorisedUsers()
$ T' e' w  ^: |$ h  J  J                {
+ ^$ J0 K) T; |  y+ u  Z                }3 d* d& `) \6 u" L4 A9 c

& R$ l5 w; @& P8 C        //-----------------------------------------------------------------
4 C/ r7 Z! Z# z1 ?8 D  Z        // Method for testing that class has been reached: ^. |3 m7 s- j% k( J& e
        //-----------------------------------------------------------------       
3 v3 {: r+ z: R0 U- q6 U        public boolean AuthorisedUsersReached()0 X1 ~8 `7 o' a) H5 J
                {, w2 i) M8 ^% o2 A7 q$ W9 F4 c+ Q
                        return true;                        ' i) f4 @  P/ k4 E4 z
                }
6 ?9 O7 w; D; H' [/ X6 ^               
' S# K8 [6 L8 D$ ^* M7 ?5 w    } // end of class AuthorisedUsers
% t/ j/ f) m) m' e, ~5 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 Q$ \0 c3 m$ J; `# EShanghai - 2007" e/ U2 i. m% h$ J4 G/ ?+ b, b
Assignment 20 z1 A' F& U' B$ \2 g9 [4 O0 l
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)
+ z! K3 f3 y( ?6 E1 _" q! L" |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./ `* m* C5 O" u" o# |0 Y" c6 N' S
The staff must be able to:
5 I; V4 ]2 D: q. b0 J: n Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 t. {0 T0 C" g5 R3 U9 c7 ~
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.
# P- Y' d$ u0 x8 d" ] The interface should provide a menu so that the staff can:
/ @/ M5 p$ R3 Ba) Enter the names of the two Java program files to be compared
, ]1 H2 y, k3 ]0 f4 w3 Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 a; ~7 J* a" o; o** 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).5 c# e' m) O) a5 q# `  r9 F
BSA104 Business Programming – 2007: Assignment 2; O& C3 y& Y9 y/ H7 m. K! |1 L$ _
Page 2 of 5
7 N: l) l; A5 G  Ob) Print out to the screen all the lines of code that are the same8 ]3 m( _; x' a/ I' n" M
 Include the name of the file and the line number of the code being printed for each of the two files" u$ B, e( u0 \2 I, C/ u0 o3 P
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 |4 L' R0 @9 ^  s" Q
 the name, username and department of the user
* p# v: e' @3 C- f the statistics of the comparison
4 H: r, A( B  f7 l( t- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 `" v& E2 x  F8 v* f) ]+ I1 o8 A
 the recommendation for further checking. Z9 @' @. w. V' b  W! V6 {
- 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# U: e* I; p0 Q$ i the names of the two files compared! U# t: F' ^2 I% R0 F" g. z6 R, A
d) Leave the program (exit)
' M+ m0 J4 x1 d- r7 ]" TThe ProgramCompare class: (Total maximum 20 marks available)
* |0 R9 I$ D  e# Q2. 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)" Z. d# x- ]* K! p& l5 p
a) provide an error message if the files are not found or there is a problem opening them' ?# _; d3 V" c6 ^; a8 Z# n' q$ s
b) compare each line of code% i$ N! i% K' X& G
c) print out the lines that are the same0 s4 F7 ~1 R8 p+ M, N: ?
d) count the number of lines compared / lines the same
9 D( o% f7 O" F" N! X3 T0 a! j) uThe AuthorisedUsers class: (Total maximum 20 marks available)0 Y& w* E+ y6 K8 j4 v1 T
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)
' L/ ?- x. |8 [/ ~  T4 G$ C1 w4. Provide methods to:
* _/ f8 |! ~  l# H$ La) 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
" |; |+ y( j( L. c! Nb) return the name of the authorised user
. z; j. A- N) b! e6 o% {c) return the name of the department of the authorised user
0 o) B/ ^6 c8 `3 |# y3 h' OIndividual Data (Maximum 20 marks available)
! g1 m4 p! J( @# _" K5. 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.
. O- }8 N! C( G, d9 S6 [* Y5 XDocumentation (Maximum 10 marks available)% R0 D1 a9 Z" ]/ 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.) f# s5 A1 [0 T+ E9 K
BSA104 Business Programming – 2007: Assignment 2
% G9 u; l! F8 `* \8 g5 Y+ C' mPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. E+ m* w* X* `8 Z% W0 l3 z不过你要翻JAVA的类库说明。你有下载没有?9 j0 o9 M# o7 Y% j/ Q! C
查询关于对比的函数。貌似关键字是contrast,还有compare# w# T; `' @* z

& L- `0 u. ~/ V5 R; X' _' n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" ^0 W8 K# Q! }8 Z) w! f
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 E" t2 V% }3 p8 B3 |% W( e可以下载到的 是 jdk-1_X_0-doc& ~. G. f7 W6 d7 N9 \
0 G$ C6 r1 M! {$ ?, y0 D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-8 04:37

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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