找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1458|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ x! _& d9 T) |7 N+ f* v + z0 w/ s! r7 n% G
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  q7 C0 r" o' t) h
//  ProgramCompare.java         Provided by: DRS
) A4 L  w. j7 Q2 b3 t3 t2 s- a: z//) N+ t2 V1 a1 ~: ^% s' Y; u
//  Program shell for Assignment 24 l! s" K- @% r; ^) m3 m
//1 `: f) d! x6 t# h' D
//  Compares two text files line by line
* z# f7 N$ Z- Z) l+ w2 c//*********************************************************************
! k9 T+ @  w: Q9 Y- [) n- @. \1 n8 O* J
import java.io.*;
3 S% P' Z1 r5 k3 f8 P2 X! J3 g5 S5 c$ C3 V; h% C
public class ProgramCompare
* d3 M& z1 W9 U$ ]+ ^. j( J' @{
& o  J8 T3 Z% b( }        //-----------------------------------------------------------------
9 e+ h5 A# ]  f/ ]        // Constructor* R# _, V" F1 n( o" F1 I7 H
        //-----------------------------------------------------------------! I7 X4 c& Q5 x
        public ProgramCompare()$ e# ]' ?3 H9 l
        {0 z& N1 S! i) k8 a
        }/ O& ]. Q8 i& j; k. P
4 O8 U# q0 O+ _% g: ?
        //-----------------------------------------------------------------
- r0 l% I9 L7 e% z/ z        // Method for testing that class has been reached0 I' ~  M0 v& K5 r7 T# s
        //-----------------------------------------------------------------        ' `, l4 r" c% V: N) m

4 Y6 Q/ x: Q; Z        public boolean ProgramCompareReached()         9 K2 V# e( C+ R( y) Z3 L" e/ ~
        {! X5 W8 X# T! _- ~, h( O1 T
      try 3 D, a% h5 P! G  l- `( f. [
   {        
' ]2 h! ?  X6 j: ~& r2 X                        9 l2 b+ @+ Q) s5 N
                //********************************************************************
8 @/ @3 H3 V- j9 k* a                // Try-Catch Statement is used to handle exceptions - such as file not found ( T6 h, f  l' B# e. _6 `0 K. O9 J
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
& v' s& w- F/ W" R5 l6 a9 P) J) n                // For more information see page 534 of the textbook# k+ _) p! o* @* b: o) @! ^; P
                //********************************************************************6 T8 c# l# o% X2 G/ o# \% a6 b, P
                    
2 |4 m* E' ]& C        }
3 H6 B* s8 ?2 s             catch (Exception ex) // Exception caught here and message displayed to the screen " z7 B- q6 _9 \! _
          {: Q' J. _+ W$ c& u  _& `$ M
                    ex.printStackTrace (System.err);* W8 ^  u! k* s- E, B2 k9 a( ?
           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 D6 M: a- o4 X, Y        }  i6 l$ O) B, f3 i
                return true;
, o$ ?( e. n" u$ @        }
# A. g# h: `$ k, T
, Q# E' p* }. ?. ?1 x% X} // end of class ProgramCompare
* w5 y+ v2 l* Q: |% }. d4 F5 k9 ?0 V' V4 B5 B. Z+ m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ `7 p( {/ l0 e/ X7 m/ Q//  ProgramCompareMenu.java    Provided by: DRS
  Q; V' s/ R9 o4 p0 _9 {/ C/// H" k4 J: t9 _$ h* _# i+ n- o2 ?& Y
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 C  R) n; K6 j" r- N' {//6 w( G7 M1 n. N/ m9 w3 d* @9 S6 v
//  Driver shell for Assignment 2.
1 Z9 z3 E; U6 R- [: s# E, E8 [" w//********************************************************************/ F( A4 [$ x9 a  Z
6 c& f! t$ I+ U2 |! M
class ProgramCompareMenu! o/ u1 R# N% i+ ^3 S
{
7 g, O5 M- i4 B: a/ ^' K# c    public static void main (String[] args)
  o) q1 j) D0 y/ e: r3 M, W9 C$ r/ b            {9 ]) B4 U8 @' g" J
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 |2 N+ D3 i! S$ v$ d$ H0 l& q
                ProgramCompare reached1 = new ProgramCompare();
$ h% s$ P$ R, g% q                AuthorisedUsers reached2 = new AuthorisedUsers();       
. F2 ~% c0 t1 W6 R: `# l" H+ a                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 H, f3 e  w  w' ?" M                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  d8 K! o1 M; i7 L        }% _( v" }4 P% e( J$ e9 O
}// end of class ProgramCompareMenu! v* j0 `6 ^; C' t0 u

& Z; U7 z3 ^# |/ E. z" E$ [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) Q- A& s6 ~4 Y3 a5 r
//          AuthorisedUsers.java          Provided by: DRS2 d2 y" ^: X- N, y
//               
7 I& O0 M; v2 ~3 S' E1 v3 S( |//         Program shell for Assignment 2, e2 R% K. E) a/ y6 l: e
//
! I: d& E- r3 ^  s! N% Q' v//         Represents facts about an AuthorisedUser
( N4 l' D7 R( ^" R6 ^0 L% s//********************************************************************
8 G+ \- a+ B! g5 {# Z  p2 o4 J9 {3 N0 L/ [4 L7 j# ]3 D
public class AuthorisedUsers0 z2 J/ ^9 B9 Q7 }7 g9 s& L
    {, }; N6 U0 m4 Q4 O$ T3 m) B
' L+ b& D9 q% k2 @& E( B) E
        //-----------------------------------------------------------------2 ^( G/ U& s6 d' b+ S- o4 t5 p9 D
        // Constructor
  o$ x7 d8 L: t# ]% k        //-----------------------------------------------------------------, g  j2 c8 q! A' r& S4 K2 F2 c
% z2 }  U$ A! s6 Q, `/ f- N7 `
        public AuthorisedUsers()
6 F6 [$ O, a! O8 ?. r                {
! [! P, X$ y. z) c- Y! j                }& e- Y; [9 c4 T2 f4 A

& v/ E2 l, Z4 n) D. k7 E" g* c& A        //-----------------------------------------------------------------
0 E7 W4 H! {" F7 }        // Method for testing that class has been reached! Z$ `. K% ~5 e4 G0 W" |4 a
        //-----------------------------------------------------------------        4 k' I3 U! B1 a$ V1 F& H7 M
        public boolean AuthorisedUsersReached()
1 \( L4 f5 s% e  Q9 t1 T                {  K9 O2 M# z* r; |4 p+ U  F
                        return true;                       
; W! y1 T7 c; v: X) T                }0 h( l" z" \( R
               
+ }' k7 Q+ w8 G& G    } // end of class AuthorisedUsers
7 r: }) a! L$ X1 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 }9 [4 n; q3 u  ^. w1 {& f
Shanghai - 2007
3 r/ v9 p* \% N. v6 YAssignment 28 Z2 T1 g: Y, R! p- P* G3 H: ~
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)) r7 o, h% m; |
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.
5 `4 W" n8 ?; P7 b0 vThe staff must be able to:
6 g- S3 Z+ V/ o0 h  y& O Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.2 x) R7 o# S" {  K% |3 y
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.
- v2 x3 Y; q$ g The interface should provide a menu so that the staff can:
) [& U) F) T- q) C2 b( s8 Q0 s: |a) Enter the names of the two Java program files to be compared: O, p, }. e3 o& B2 [1 B
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# h/ Z. a. N$ N8 V) M** 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).
% K( r+ x% u. cBSA104 Business Programming – 2007: Assignment 2
! X9 X- v( C+ `5 J3 G3 ePage 2 of 5+ G) S5 [( h9 _. l+ T
b) Print out to the screen all the lines of code that are the same
. t9 W% X, T) C: {6 O Include the name of the file and the line number of the code being printed for each of the two files
6 f9 C, y: Y- j( h( b* [" Sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" A  G, p' c/ E
 the name, username and department of the user& _# F/ a$ l4 N" i7 R
 the statistics of the comparison
& \9 u- t! U- X4 x$ u- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 M5 K5 U+ S6 l3 Q% l0 u the recommendation for further checking
# O! e* a# m! \& ^- 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: d% s) [: p  f) L9 ~8 S# G2 w! r8 \
 the names of the two files compared
3 l. r3 B5 o& I- H: h/ kd) Leave the program (exit)/ C) T, C. t' M/ _* I2 X
The ProgramCompare class: (Total maximum 20 marks available)
0 `9 b& A; [. F7 R2. 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)( ]4 X6 `2 E" f1 E0 Q
a) provide an error message if the files are not found or there is a problem opening them
) X: |  U3 p6 ~! R$ Xb) compare each line of code1 c; I* n( Z; ]  q' ?! L
c) print out the lines that are the same7 r& I8 z2 q; t
d) count the number of lines compared / lines the same) C4 j& D# W; u  x) y3 y
The AuthorisedUsers class: (Total maximum 20 marks available)
# V" X6 m* `0 u* m2 ]* F" }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)" A1 V, n, S4 H9 J! M
4. Provide methods to:
+ O& I. h+ G* ~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 match0 m; s; c9 h1 L. u9 {  E
b) return the name of the authorised user
! G, D- ^- }: D3 @% U* gc) return the name of the department of the authorised user9 D$ u6 o, e: A0 p
Individual Data (Maximum 20 marks available)! J4 u/ @% G9 F+ J/ j* p8 f0 E
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 K% _* d  U  K( p9 s
Documentation (Maximum 10 marks available)& a% M3 B" r6 o
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.% [4 S. F0 x. I+ V9 v6 |
BSA104 Business Programming – 2007: Assignment 27 S- R8 _- T8 B5 a0 V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
: N$ z5 J# l  B* W不过你要翻JAVA的类库说明。你有下载没有?
* {# P1 \6 R5 j* j; C查询关于对比的函数。貌似关键字是contrast,还有compare4 v7 E0 K+ U, B2 @, ~, w
" B: |/ y; i7 U1 ]& @- x
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
+ q4 ~: U; L7 H0 H& B/ i痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* S% t( q  v- B. R7 b. z0 i可以下载到的 是 jdk-1_X_0-doc' a( \+ _. e4 L

6 z; ~5 K! H7 F+ T. @& e/ v# N[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-15 07:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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