找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1744|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 % i. _" z1 j- B) S1 K. O& }* J' r- P" x! A# a* {7 o6 A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 ~6 {* H3 f2 D
//  ProgramCompare.java         Provided by: DRS
1 I+ a1 D8 Z. Y5 w//) }8 ]! E$ W+ I
//  Program shell for Assignment 2
- g! |: k( b& W6 p- z9 V" a. Q//# f+ n" q4 g. b* z+ r
//  Compares two text files line by line
! A2 M2 {8 `4 n. F! V0 I//*********************************************************************$ n& t# _  l9 y+ [$ e4 L) w2 u7 l

" O; [7 d0 ]+ k) ]. v+ ^1 kimport java.io.*;
# O1 z0 g! p  ^# S
, i" g7 V9 B+ t4 q  hpublic class ProgramCompare
8 p' }* V, e8 O6 n) y% x$ I! h5 p{
$ |* i6 h( m5 N        //-----------------------------------------------------------------& x' R6 j1 e# v: x9 a: k
        // Constructor8 E1 U! [; A5 A
        //-----------------------------------------------------------------
: b! j& Y- H5 u! Q        public ProgramCompare()
6 _% \" G2 Y& r; D2 G9 ]( e; y        {( J/ F6 W. ]7 ^5 s, ^! c4 [
        }5 \+ X0 ^5 B& t! F5 Y6 Y+ T* w

3 u+ T5 ^* N& n% q7 S        //-----------------------------------------------------------------5 E) A6 x' k$ x
        // Method for testing that class has been reached7 b$ q! ~+ a0 |$ l" @
        //-----------------------------------------------------------------       
5 R0 B- V- q" n( t: [, G: }# P' I8 y/ N% H8 }/ n+ ]7 ?' I; o
        public boolean ProgramCompareReached()         3 g% E1 Y3 F3 D7 k% U1 T
        {( Q- X: ]; T$ n  K% b
      try , j7 s( R8 f: t" ^
   {        
. }/ m; d2 f. u6 J# X                       
* P+ q; P% m  I, e: C- R( }9 {                //********************************************************************" v: n4 Q; p: ]! f6 {, z" W
                // Try-Catch Statement is used to handle exceptions - such as file not found
# r) a  R% ^; b) o                // Reading the files will need to be placed inside a Try-Catch - just like this one!" S0 X! l+ I" |9 S
                // For more information see page 534 of the textbook
0 d; z- a4 ~& D. ]/ C! i* B/ M& h7 m                //********************************************************************
( S) d9 Y4 Z" C  {# T, s) K! W  Z( }                    
8 s3 C, N: J. d; v; }" R3 I        }4 R6 Q- K! k" k3 v3 a
             catch (Exception ex) // Exception caught here and message displayed to the screen # M5 S; m( Z, X
          {1 J1 L" D# r% D' l* k7 O
                    ex.printStackTrace (System.err);+ p. p) C* K7 f( s3 u! D
           System.out.println ("Error message goes here"); // Replace this error message with your own          2 }( |$ f+ U* ]! C
        }
# ]* C1 o) p+ k0 C. |                return true;
& l1 v9 U7 C/ l# n1 l3 l        }
( o, h. a7 r, P9 k4 u8 }
( y1 `3 H8 U& K} // end of class ProgramCompare
: z; ~3 H4 D; G8 O; O9 u: y) r* y2 D  j$ L0 g* {( f5 a$ D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* V+ e0 N- c; K5 T5 G//  ProgramCompareMenu.java    Provided by: DRS5 g7 r1 Z7 u; I+ w/ k) o
//
! ^# y( C" ?5 m  G//  Calls AuthorisedUsers.java and ProgramCompare.java7 x) b' [) N$ N3 F  E( J- f
//6 K6 j" s2 H6 f3 x
//  Driver shell for Assignment 2.
8 o& z. ]8 V: g$ S% r, h5 F8 M//********************************************************************: H" K2 F0 ~! X, b* w8 f( _

9 X, K- r  d9 _) w/ ~& bclass ProgramCompareMenu, a( q7 Z3 m7 q% H  t" A
{* I: I, @5 s9 [) P$ f1 ~1 x
    public static void main (String[] args); s& |! I  [5 C: T
            {9 w) |$ ^2 G3 r3 Z3 V4 M( Q. p
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable6 ^4 }5 l  J0 R
                ProgramCompare reached1 = new ProgramCompare();
  J8 W! i) |: Z: r  `3 T* q0 K                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 a/ L; t0 G' X4 C                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 C9 G% Z7 S+ {. G4 R
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          X. M/ e* x0 x  {
        }+ X. r+ C! z. F
}// end of class ProgramCompareMenu
& u: d, R' e  s4 D3 p8 c& `! X. D+ U: ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" m( Y& Y( Q& L/ ~//          AuthorisedUsers.java          Provided by: DRS% q# d% @  H0 k, w5 U% i$ o
//                - O2 }6 N' E1 x+ @0 R
//         Program shell for Assignment 2! X* E: y3 h- z) F- S0 c- t5 ~
//7 w. U2 C( B* m+ l; m) |$ `
//         Represents facts about an AuthorisedUser
4 Q* X2 a4 ^  J& S! D//********************************************************************7 Q3 O2 ?8 b$ @" A

# u) y. C/ t; [) J/ }public class AuthorisedUsers; X$ y* ?6 w: ]; {
    {
9 v4 Z# W0 z* V, s5 S# o
2 n2 G6 Z* R$ {1 a. T- u        //-----------------------------------------------------------------0 ]5 }1 w2 H- G. E; F) h. Z  z
        // Constructor; n( {1 L. c6 v9 ?
        //-----------------------------------------------------------------
* p  f: E: l% Y# u, [8 [  O$ A2 C+ r+ T6 A
        public AuthorisedUsers()
% l' l+ ~0 f! n- W2 C                {
1 L0 P9 i3 Y2 x                }
- M. i1 N. H. H( T0 w% @+ y
9 c2 b1 c9 Q: n8 @6 s. X        //-----------------------------------------------------------------1 u9 Z# O" q# ^3 y! r
        // Method for testing that class has been reached
6 e' O8 i) E7 o; Y* q' b! [        //-----------------------------------------------------------------        ! I0 e. H& G* J
        public boolean AuthorisedUsersReached()7 }# m3 L8 ~% W
                {% \% T; K. {0 C. z, B& D% n& `! ]
                        return true;                       
/ P- n8 L0 z4 T6 R6 D0 S' c                }* u, C) \8 b; v' ]  H2 ~
               
* Y4 r0 y# ?. x# F# \  r2 p- @    } // end of class AuthorisedUsers
) z* H5 @+ ?# e, W  x$ L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ q6 _* x" ^+ qShanghai - 2007  k! V  B, d% S8 M
Assignment 2
* C6 C9 T& T4 CDeadline 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)* U6 q% U, Q& U) G4 o
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.
7 Z5 k. K' z! S8 a3 K/ AThe staff must be able to:
0 h0 Z: z! W% U3 q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **." H$ w! e" z, c: n- 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.
; C' }! `: b/ ~ The interface should provide a menu so that the staff can:
5 f/ I# S/ {3 A# S7 d, fa) Enter the names of the two Java program files to be compared
: W, U2 L, w. T9 Y% w8 ]  J. r For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# C- {. k+ }" q' u: }# r5 S5 s** 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).$ d8 r$ l; D7 j0 k( J
BSA104 Business Programming – 2007: Assignment 2" I+ t0 ?/ ^6 }1 S
Page 2 of 5
* b4 `. F: ?1 H5 d( Rb) Print out to the screen all the lines of code that are the same
2 @3 v+ j7 c8 {% l1 [& E0 [$ K: H3 J Include the name of the file and the line number of the code being printed for each of the two files1 {5 l+ B  ~  i4 O
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( g5 x0 y3 f- ?+ _5 d2 E, q
 the name, username and department of the user
* b# y8 L+ c# y the statistics of the comparison
  a( m: ]- p* I( X$ c0 c9 A- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 J. L( P$ s4 t6 y! W
 the recommendation for further checking; T. D) P- @" ~: f2 y2 a1 q
- 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
; o' L* T- {' p8 }. s/ r the names of the two files compared
: L- S/ X" ~, E; u/ Td) Leave the program (exit)
, Y9 X: R* @) i5 p& c( [: VThe ProgramCompare class: (Total maximum 20 marks available)8 ^* P& I/ ]' T; n& [- d
2. 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)
) Y6 }& u- s5 ia) provide an error message if the files are not found or there is a problem opening them# V4 _6 t8 b" \4 Y/ K; m
b) compare each line of code
. D% F" ]( R( D( T5 z  @0 }0 Uc) print out the lines that are the same
7 N# ^  r# K. {2 g; {9 Pd) count the number of lines compared / lines the same$ h: f% P( c4 Z+ O
The AuthorisedUsers class: (Total maximum 20 marks available)( p( u: |& w1 r" Q
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)
0 E" l/ I( `% j, w4. Provide methods to:
6 r, Z" L  t' @3 H2 Z5 _+ 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
* U( B3 z' A7 L+ J. x% k9 Wb) return the name of the authorised user
' M" y; T/ X) @% |2 Nc) return the name of the department of the authorised user. y9 [: B, W0 k8 W' `! L& R
Individual Data (Maximum 20 marks available): a2 P- q/ m2 l4 N/ \
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.! s& W$ p' h- w9 s6 |8 h3 _  M
Documentation (Maximum 10 marks available)1 ]3 ^, r8 D7 \
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.
9 i% [! o' b; k$ d, h/ _9 wBSA104 Business Programming – 2007: Assignment 2
+ S0 {# [) U9 zPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
, J. l' M) O( S2 X# v& ?不过你要翻JAVA的类库说明。你有下载没有?: e4 Q2 U) w5 [/ c
查询关于对比的函数。貌似关键字是contrast,还有compare
* f+ ?: n+ K4 m" `4 D1 u% `' g
+ K3 ~. N1 D! N7 ~" N[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# v+ \# t4 @5 _# Y1 N痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 o1 n; @/ a, M2 E
可以下载到的 是 jdk-1_X_0-doc. l' R7 s6 N4 Y+ |: |
" e+ q) v4 m6 }. {3 M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-21 02:59

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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