找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1859|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / \$ [+ I% w( z0 Y* S( k4 o' F1 L* ~% @) Y0 o& }
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************7 \. Y$ u. z/ p3 T
//  ProgramCompare.java         Provided by: DRS
7 s8 L: G: {& W# k$ H5 f//, D& M7 O6 v# r8 L. S
//  Program shell for Assignment 2
0 u# ^0 p9 P3 Z  {//4 R6 e7 y, K! Y+ m( v4 Q
//  Compares two text files line by line4 r" ]$ A3 S* k& ~; a+ N# ~
//*********************************************************************9 G8 |" G6 J  E" S3 B
1 s3 t! O% \: P' b4 B# T4 \
import java.io.*;
# V4 O9 X: d; N( V! l$ t
0 B1 i) B2 ?- s; J' `( `0 s( ppublic class ProgramCompare
# d* d3 A6 M- ]{( A4 q" T4 g9 ^# t4 X1 y3 N
        //-----------------------------------------------------------------' U, y# l0 ?$ H- M
        // Constructor0 E- a7 M' m' d4 g: u
        //-----------------------------------------------------------------
  x( }2 h  t+ `5 v        public ProgramCompare()
- ?5 d. ~/ W; @' X        {1 k7 ^( v; Y% n8 z; R9 n& i
        }, C6 A$ Z; C" }! @1 W! K! q* }

8 a/ X* h: ]5 q: s        //-----------------------------------------------------------------
/ i" b; g+ d0 g4 }1 M0 O  O7 k9 w        // Method for testing that class has been reached
6 Q( f, Z  N9 k9 @( r- `        //-----------------------------------------------------------------        ; R* M6 B6 Q& Z9 ^  Q4 B
# W5 M2 |9 q. s
        public boolean ProgramCompareReached()        
! I1 z, X; a5 v# [+ M        {
8 o1 L- c- y1 _% R- U8 p      try 3 x0 f6 B( W& g7 N
   {        
9 h1 f% |( T* V& e" Q5 G                          y/ [. j/ K% B# |; h  U
                //********************************************************************
5 o; G: m$ P5 e9 u' N                // Try-Catch Statement is used to handle exceptions - such as file not found 9 K5 B3 p% \* c8 P) y- F
                // Reading the files will need to be placed inside a Try-Catch - just like this one!2 k9 E4 Z: `& Z9 ^
                // For more information see page 534 of the textbook
% {) J9 v! m# u( G* F' @. N: N8 |4 t                //********************************************************************
3 g. l6 S% E; a/ V* n0 Q5 }6 h) Z                     5 z2 H* y5 e1 ?
        }
1 g1 [# ^# ~3 W% z7 y) ~             catch (Exception ex) // Exception caught here and message displayed to the screen ( s8 x1 s. u- u' T2 H, _) Q
          {
! G4 t+ L& s2 U; L' x$ k1 Y- S                    ex.printStackTrace (System.err);
. ^0 U$ x4 {: a! l( {, b           System.out.println ("Error message goes here"); // Replace this error message with your own          6 m. O/ M! t# U8 S: T
        }
. ]1 ^/ e8 T5 S/ @. Y. A: y                return true;' l/ T2 I' [0 P
        }- A5 s6 n6 E6 n* N
) {/ ^4 L  _# }# d/ q+ [
} // end of class ProgramCompare' L( A+ J  U0 F. R' @
; R& x8 j. s+ m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- l: C' r  ^$ P: q7 R//  ProgramCompareMenu.java    Provided by: DRS
) y% X* v. [5 R+ \+ t8 @( S//
. t8 }1 Q, w0 k+ g  y% W; @//  Calls AuthorisedUsers.java and ProgramCompare.java2 D. G+ I0 k7 V4 [8 S3 F1 |
//5 `0 d% _/ F3 U9 \5 S# A# i
//  Driver shell for Assignment 2.# v2 Y0 z) E2 a3 _1 j% C1 Z- @5 S) o3 J
//********************************************************************
) Q! T' p2 }6 p- r5 f! O# E+ [) Y( d% N& l; h( y8 l9 [5 |
class ProgramCompareMenu
) _, J3 p0 A( k" l) ?6 [% a{  j7 D6 A: Z# F8 z0 g' y
    public static void main (String[] args)
$ X7 m* E' s: p. Z            {
: W& _; y* x1 ^+ @) T) g                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 K: ]( [# X6 h7 o  a8 y; z                ProgramCompare reached1 = new ProgramCompare(); ! s: y/ X* ~% ?# k* G4 s
                AuthorisedUsers reached2 = new AuthorisedUsers();       
4 j4 ^3 j# O' D' n' D                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! A# ^+ }( l0 a4 R3 A4 r                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 O8 A3 G  @( e! K) F% t        }7 l8 m7 x) j7 s' h; ?
}// end of class ProgramCompareMenu
! ^& T* J, X0 p8 k8 _, M  a7 X4 j# l; F! F5 D" w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" [! E' q4 C. Q7 a$ T
//          AuthorisedUsers.java          Provided by: DRS+ r% T0 z- Y# |+ O! v. \, R
//               
' A/ G+ k3 S" K. D# M5 r//         Program shell for Assignment 2& X. l7 v5 @0 Q8 L4 \
//
1 G% k0 K. `9 o4 H$ b/ C) Y: G//         Represents facts about an AuthorisedUser
  I& a$ K* b2 ^1 D//********************************************************************7 L4 H, X# n4 ~4 E

$ \7 j0 a: d8 u/ ?public class AuthorisedUsers% l& X! T/ V1 M& b/ p
    {
5 h7 r" U+ O0 S9 J* m) l
: ^' ]. y* i' }; x) H        //-----------------------------------------------------------------
( ?# v/ l: @: {7 l. x3 ?& t        // Constructor
# E' v1 n+ J+ D        //-----------------------------------------------------------------
3 N3 C" o- V' n
* X( H. [, B1 a& h8 V% K7 h        public AuthorisedUsers()
& U& U( }! ~8 m1 ~& p6 Y* |                {
/ u* O7 @6 e( Y2 t  H# j                }
+ V. F- a8 q, g! G; J# s
3 R8 _& z# L7 U/ q: N        //-----------------------------------------------------------------
6 E3 U# n6 g9 f  c( @        // Method for testing that class has been reached
2 u' f0 }/ t2 F/ R        //-----------------------------------------------------------------       
9 a; K' b+ @7 ~! J- X7 h        public boolean AuthorisedUsersReached()
  j$ N/ w3 m, B) F( C                {" I& ~) Z0 z+ N/ N
                        return true;                       
# ^+ O5 f) r" w# a+ i0 K! p  J                }5 M5 B6 v. s! {5 x7 w1 E
               
, o8 A" L2 b7 h" W! D    } // end of class AuthorisedUsers
+ Q, e& a  k3 g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ F9 r) ]- j+ t: d3 _
Shanghai - 2007
9 t2 Q& u4 T& n( V' j- a* ^Assignment 2' t; g6 K/ g0 e9 c) q- m
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)
! C$ E% r* ~, q; q3 s  F; h2 r1. 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.
0 c; i8 B- m0 ^8 y; ]The staff must be able to:
* N. U0 {1 f+ K7 {0 s% _* y Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 W% u+ L6 b# H4 y7 p) B1. 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.( k: s8 f0 X7 k4 T3 E3 R$ n
 The interface should provide a menu so that the staff can:" r# t; y2 W" a7 W% |# Q& @
a) Enter the names of the two Java program files to be compared
! M1 S4 q/ Z: M$ I9 L0 | For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ z- n3 A, o+ 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).1 |. z5 }- e0 [% H0 x: a
BSA104 Business Programming – 2007: Assignment 27 l4 e4 Z5 b6 B# L7 U+ I
Page 2 of 57 X$ f, I  Y5 E
b) Print out to the screen all the lines of code that are the same8 V9 F3 |0 o- a
 Include the name of the file and the line number of the code being printed for each of the two files
7 B: G4 V9 p* I! U% ?: wc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& m9 t6 ~' M3 a3 o6 g. |8 {& l) g the name, username and department of the user
! W2 V1 P  K* x7 H- {* K1 x the statistics of the comparison
1 y: [6 l* D( C9 t; W- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% I0 p# h. b* Q0 x9 W the recommendation for further checking
: F! S: c" K+ 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 closely9 M/ J' Q1 ?# x- L
 the names of the two files compared9 S* g  @# {$ b; K/ ?  ^
d) Leave the program (exit)4 n% J1 Q; c9 E2 K$ E
The ProgramCompare class: (Total maximum 20 marks available)
8 y. }. H# C( c! P, x2. 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$ N/ Q4 M8 n; D- h2 N6 w
a) provide an error message if the files are not found or there is a problem opening them5 N" {, W+ ~9 V# q  x* K9 b
b) compare each line of code% ?8 U5 S0 ^! f; a& r& w
c) print out the lines that are the same
8 a, P$ x% Y8 }d) count the number of lines compared / lines the same) E' f% q# R% i. l" U" [
The AuthorisedUsers class: (Total maximum 20 marks available)( M: q* B8 I+ X  Q' s
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)
* Y0 R5 V* [9 t2 C4. Provide methods to:
$ G( A+ L9 p9 j* M9 S" [7 ?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
8 v" @7 `( C6 e, X: v4 y( ]b) return the name of the authorised user
# \- V7 z* k6 N( g1 g+ b5 `c) return the name of the department of the authorised user; o! e; y; Z* x! i2 S: ?  [( a# ~4 ?
Individual Data (Maximum 20 marks available)
! F2 @- ?4 s0 c+ d3 u& E0 t# y, x$ z5. 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.7 ?3 i( M; S( C2 e& G$ v8 A) S' k
Documentation (Maximum 10 marks available)
$ F6 X; u3 N2 Z, t: O) p6 [- C6. 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.( I* Z/ B6 O" ~( z- [1 M3 z
BSA104 Business Programming – 2007: Assignment 2) c$ i6 I. H) v2 g, Z$ y2 g7 M+ d
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 \) f$ D% e8 |% m不过你要翻JAVA的类库说明。你有下载没有?0 b4 K0 R8 ~9 f: X- `" \
查询关于对比的函数。貌似关键字是contrast,还有compare1 d3 |( F7 J+ c9 ?, s& _: v

; y# }$ v: I4 _" A! Q. k* z9 J( ?4 w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。. W* D1 q5 F* E5 a; P3 A
可以下载到的 是 jdk-1_X_0-doc9 J9 ]8 j' o! M# j7 _' ?9 f7 d

2 u3 R4 ^0 ^" @$ w" s. S8 I, j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-27 08:15

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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