找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1139|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" h Q% `; S8 Y 8 J! h! g. S3 T# H4 c
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& y- K( X# q# X: B//  ProgramCompare.java         Provided by: DRS
- A, X; K. G! t& u4 K, e4 `" {//2 N$ h0 U2 y, ]' k0 G+ \0 o
//  Program shell for Assignment 2
  b- l1 M( j: \//
0 i- V. P5 O4 T. p2 I" N6 r6 r( v//  Compares two text files line by line
/ K+ K1 \, c2 k/ \0 w6 Q+ J( k3 a//*********************************************************************
# E9 \: `9 b. e+ u3 u! R: h
5 k$ n) S8 x' P2 |1 Fimport java.io.*;
# r1 G1 x/ P) T
7 L/ L" i1 O; @" q; ]public class ProgramCompare, ~4 J+ y- l8 s: g: V
{
1 b6 e4 ^& J1 R5 Z! N" d5 g, p        //-----------------------------------------------------------------" f4 X! J3 P! a( C" U3 z6 U
        // Constructor
8 l4 ~' z2 `8 A. U, c% e        //-----------------------------------------------------------------
% J9 C9 y. c& ]% L        public ProgramCompare()
9 \2 H* q5 T$ z8 E) P( u- a        {
: I0 K! W/ q% d$ w9 y        }# p) Y) \& Z0 k
3 i% m# F7 A# a0 `
        //-----------------------------------------------------------------
- _! Q% `) w  n' r0 t0 r5 R3 I        // Method for testing that class has been reached. K8 Z4 a* X  G
        //-----------------------------------------------------------------       
. ~" ~6 Y2 b6 y
( e. ~: t$ i' ]* _: n. M        public boolean ProgramCompareReached()         : {' ]& w! ^/ V+ q- ?) O
        {
7 _- t6 v/ x! _+ D      try ) E) g0 M3 ]/ k" l( Z7 ?% T0 J( r
   {        
8 l) w$ x# p0 }                        & S' G& T$ A+ O1 M! W6 F
                //********************************************************************  t9 e4 V8 T/ H8 w' U& K) [2 O- Z
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 z; U' G+ Y# O$ h                // Reading the files will need to be placed inside a Try-Catch - just like this one!
; u5 j, E5 p& ^                // For more information see page 534 of the textbook6 ]1 p, P% S  f2 L
                //********************************************************************4 e5 G' D: F& B, f  @  |% H/ U
                     , Y  k$ j, w, U5 [  x
        }/ p3 }% p7 v+ v# B
             catch (Exception ex) // Exception caught here and message displayed to the screen
5 ^. [4 k. }3 p/ s) ]          {6 b8 l# o2 w0 B, V
                    ex.printStackTrace (System.err);' F2 M+ W) n* M# A" X
           System.out.println ("Error message goes here"); // Replace this error message with your own         
" f2 N) Y/ H$ q  l8 Z        }9 z7 e5 J" B  e8 u& v
                return true;
. A6 _7 n4 D+ J1 @8 I) |6 x        }: G% V! K0 ~1 j
/ D' w: B5 O" x, w) W9 [- z
} // end of class ProgramCompare8 ?0 z7 v* }6 y+ N8 x  E* r: c4 j

8 H0 o2 d2 j, N% r, o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" X* Q# n* c1 `0 P* ^
//  ProgramCompareMenu.java    Provided by: DRS
7 U; \) Q! z2 O- S) h9 }; c//$ Z" {  X  g% Q$ s6 E
//  Calls AuthorisedUsers.java and ProgramCompare.java9 I+ ~6 n1 P4 W  _! B0 f
//
+ l: \% i2 }$ j5 u% E2 I//  Driver shell for Assignment 2.
  Q& d2 B. {) ?) y( J* d" l7 D; \//********************************************************************
' H: w+ }, G& ^! X' t# V8 f( i  X6 R/ v, ]1 [* n
class ProgramCompareMenu3 d) s, u# U. Q" {9 l2 _0 W6 w
{
8 r( }0 `: K2 J' a% ~8 s" j9 ~) a8 L2 q    public static void main (String[] args)) P9 R' v: R0 L) ?9 G( |- f& s7 x( W
            {. h1 e( E" b9 f( l! C3 ]. |' k
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 w% k  h1 h/ e$ g0 d+ L  }& _
                ProgramCompare reached1 = new ProgramCompare(); # j# M, y/ c' s$ J5 }
                AuthorisedUsers reached2 = new AuthorisedUsers();        * H; z6 \8 p4 N
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 G5 K; ^% Q+ ]0 ^2 x                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        : F- q6 E; ^7 @( K' p+ k: }
        }
5 Q6 \/ w+ c; u. r}// end of class ProgramCompareMenu
4 ]/ x! L) I( ^/ M9 u0 b! c
: x$ s" Z8 e  o3 X) `0 d//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************3 ?( m' s3 r* y- Y9 p
//          AuthorisedUsers.java          Provided by: DRS
/ O: N- P: v. R1 d; ~//                8 ]( P) s! t: c
//         Program shell for Assignment 25 E% c8 O0 Z/ X1 ?9 J; E
//
6 r0 }* T2 O- Z( l7 W+ l! G//         Represents facts about an AuthorisedUser8 d: H6 u5 X; s: Y0 T) ]; E4 s: S" b* E6 l
//********************************************************************
* `1 `0 z/ R, U+ C
  D0 |: i7 x5 Q* D$ U$ Upublic class AuthorisedUsers. G- i* ~: E# |$ w% d' @8 y
    {
; D1 w# q( X6 ]  J5 w( p5 A
" y+ d. b* B7 J8 K3 t' F        //-----------------------------------------------------------------0 \0 F4 j: R2 X$ `# v3 f
        // Constructor  z/ W0 Y2 f) s, h  Q
        //-----------------------------------------------------------------
, R' f: y4 s, a# Z4 x3 v' ~0 R7 l6 r7 G
        public AuthorisedUsers()
; c" x1 D7 c, S, X9 n, R                {
& L! l; c# p. C                }1 I  K* I+ Q% x- E; n3 m
$ S( v2 ]# g+ P+ F3 R& C2 {
        //-----------------------------------------------------------------; a+ ^8 F) _/ P- V5 J; G. d0 s* O/ |
        // Method for testing that class has been reached7 L6 x. B% f2 q; q0 P. B
        //-----------------------------------------------------------------        ; g# i6 m( I: \- U# ^. t/ A
        public boolean AuthorisedUsersReached()
" ~) m$ C6 P3 i" f2 \  O% K- w* r                {
% O6 L* I4 x/ ?' |* n, d                        return true;                        4 W7 r0 E7 t8 ]7 g/ S2 l/ {2 z
                }
" X- d+ K7 C" A* p                ; |$ A! K4 e# Q, w9 E& d
    } // end of class AuthorisedUsers. i6 e7 Q4 p0 \3 f8 a* k! w, I; W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! N) Z; e! Z9 m7 j/ [3 I% MShanghai - 20074 z" q. R" `9 F  a3 B2 ?
Assignment 2
" a4 U; {2 d& v% G$ C, n5 NDeadline 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)2 P8 J1 P6 Q8 e
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.
& h! Y0 H. S% F1 Z& t+ j; e1 b7 uThe staff must be able to:% K8 J# q2 Y2 {1 E# O, H( u' l
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.: _. q5 ~* E( q1 n% G) f. B
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.+ E; Q, H9 ]% M. s
 The interface should provide a menu so that the staff can:
3 w4 O* ^# s8 c# g# X* {a) Enter the names of the two Java program files to be compared
8 i0 d' ?* O/ Q" U7 p5 i For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
  F0 W9 I+ u" w+ [0 l6 I** 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).
+ t" Q. h( ?0 b) m* K; yBSA104 Business Programming – 2007: Assignment 2
, H1 P& n' I1 A; s, EPage 2 of 52 N0 I) u, U3 Z8 T6 Q) ]* P
b) Print out to the screen all the lines of code that are the same
  a0 L3 U, }7 J; B1 r Include the name of the file and the line number of the code being printed for each of the two files- M+ q: p) v: Q4 R4 ~) S; S! \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% b1 m3 N1 Q$ o  v. M
 the name, username and department of the user
& `$ |3 P0 n7 ~6 s: B/ N the statistics of the comparison
6 n4 v* U' ^0 h7 T- I# D2 u- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( O# r; e" Q  D4 `7 O& ^. e the recommendation for further checking* L. Y  B; F2 L0 o1 i
- 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 closely0 ]# e7 c$ j% f4 z& H
 the names of the two files compared
$ c5 @9 v+ F3 ~; h$ n8 o) Vd) Leave the program (exit)
, ]4 g* i: c; w- n2 x! lThe ProgramCompare class: (Total maximum 20 marks available)
- j( v7 X6 P7 g, f2. 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)( j( G8 O- x2 I3 `# Z
a) provide an error message if the files are not found or there is a problem opening them
, r4 c: J$ U2 l7 Sb) compare each line of code
% Y+ l+ X: H6 s/ f) Nc) print out the lines that are the same' J$ w4 m0 ]5 x  G2 |$ r& z" [
d) count the number of lines compared / lines the same  w& |, l- W1 ~# ~9 i5 ~) {% p
The AuthorisedUsers class: (Total maximum 20 marks available)% u  c' K& J- Y  C/ }' o
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)' Q4 z! a2 i8 q% v3 \3 Q
4. Provide methods to:' j" `. j$ Z6 Y1 ^
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
: R" s. q6 h7 r& nb) return the name of the authorised user  {$ \+ i( P6 c4 n$ F8 z( X; `4 {
c) return the name of the department of the authorised user
5 m, F! _; r% O1 e6 X: s0 r; `Individual Data (Maximum 20 marks available)
5 A* C9 d. a% N& d: I" i: F; 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.& U! x" i1 V  J
Documentation (Maximum 10 marks available)9 Y- h3 t- x, s  D- {
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.
0 R0 q6 }9 X/ `8 L4 P3 j, B% BBSA104 Business Programming – 2007: Assignment 2' [2 Y8 }4 W# @. x: X( Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 G1 ?3 O5 U8 q2 O不过你要翻JAVA的类库说明。你有下载没有?
1 @& y' v# s# A& L查询关于对比的函数。貌似关键字是contrast,还有compare5 ^6 n" I( l# G& o5 ]2 R+ z+ {
' V5 r( k4 y0 ~/ _
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  |7 w: B( W5 \$ f+ a% d7 t9 @
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: g2 B8 y& u. R0 }$ h可以下载到的 是 jdk-1_X_0-doc
- i" u; `, }  J9 {
" L1 F3 T5 r; J8 ~% f[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-24 21:50

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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