找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1441|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 ^2 X5 [8 g2 f7 e. _( P+ ?% t5 V) i6 u2 ~; m5 s+ J/ ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************$ k1 W8 {. w: n7 ?) W5 a
//  ProgramCompare.java         Provided by: DRS; x. N* o6 }  q0 T# v! [% A
//: ~" V4 t/ {) |" M& ^! B9 H
//  Program shell for Assignment 2
8 |; a! Z8 t: o8 [, W  b! M//9 j3 M4 A- b: V
//  Compares two text files line by line
! n8 w: ^8 r5 S% Y7 r3 t* `' Q//*********************************************************************
# ?5 T: z  {2 @. o; o
' X; l! e. e% Ximport java.io.*;
3 d. M- g1 b8 R4 e  E8 M
- y) e* P2 A5 \! Zpublic class ProgramCompare1 O$ \. U8 D: N2 R
{
) C% U9 B9 u1 r0 }1 k9 k        //-----------------------------------------------------------------
) E2 K& E  }! _        // Constructor
5 y* h6 ]: L) e8 E9 o5 t        //-----------------------------------------------------------------
: h. Y, K& [7 x( H        public ProgramCompare()
; U3 }/ x& N: l4 a        {0 J6 n% M6 H) K$ f6 Y" x5 {. |
        }) V: a3 i$ N. c' W1 C! u. O  e" B

( M/ c- W8 {3 R; M        //-----------------------------------------------------------------8 |6 z3 O( i/ \. ~& I* e. U$ C
        // Method for testing that class has been reached
6 e) r- g) O, x8 }$ G  r9 m4 r8 Y+ `        //-----------------------------------------------------------------       
% c* H8 |& o+ O  M0 e5 N; I8 j* B* i3 J% H
        public boolean ProgramCompareReached()         ( W3 L0 S) d" f1 T" Z  p
        {
0 c7 S1 G9 V8 h; v* c, ]      try 1 U8 Y. {' A" b: I5 I
   {        
& e: F" h: K, ?5 i! [7 C* E$ ]. L                        # B/ A# ?" z: a  h# a1 k
                //********************************************************************) u, j  D$ K4 M' G
                // Try-Catch Statement is used to handle exceptions - such as file not found
: R1 g$ s4 g( T" V* y* Q3 d                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ i# ^* H8 a% I1 D8 Z' U                // For more information see page 534 of the textbook4 i. a& \6 u+ a3 n  K0 [2 i9 M
                //********************************************************************
$ Q6 w% f+ L7 l: B                     1 Z5 R% f6 y- z% w& m' e
        }
3 P$ v; `1 ^6 R5 T2 r' \7 T             catch (Exception ex) // Exception caught here and message displayed to the screen : y! w9 M, k+ }  `  K* H
          {
7 b. ~3 Q7 b% k) O, L                    ex.printStackTrace (System.err);1 Y4 r! G. Q- i3 A3 f
           System.out.println ("Error message goes here"); // Replace this error message with your own          8 [# v& Z( j) z: G+ l1 R
        }: N7 x5 w2 n1 ?% M. p/ v
                return true;3 Q2 I3 x% u9 ?* Q8 B% T
        }
1 J# O+ K. m; r/ e, E) V  d4 ]- r  t
% V3 Y1 l7 b7 h" q} // end of class ProgramCompare
1 d5 G4 {( C1 ]$ [# e. H- T
- J6 E- r4 q  d: ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' g2 ^- c8 J* o//  ProgramCompareMenu.java    Provided by: DRS% q+ i6 r3 O( t! w. c! G% R6 x
//
  D' ?" {0 w% Y, }- C//  Calls AuthorisedUsers.java and ProgramCompare.java+ ?0 q' Y) t' W/ D, q% U7 r
//' Z6 p. {) b7 I4 @9 h" U
//  Driver shell for Assignment 2.
/ Q( t" |$ X# A/ O' q1 j//********************************************************************
# U& ]+ ~3 k/ R7 o; [! O
+ _, h* F# s* U# k% Uclass ProgramCompareMenu9 X4 P) H/ C& S
{( Y7 ^/ B  b; N! x7 Z2 P1 R
    public static void main (String[] args)* J4 r9 Z8 o9 o! ?; {6 x2 J. E
            {( p+ y" c" {  x7 z. U
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: R" q3 w" V3 c, `
                ProgramCompare reached1 = new ProgramCompare(); ) }* }$ O" U% _& A/ t
                AuthorisedUsers reached2 = new AuthorisedUsers();        5 t1 \0 v0 E: T9 E
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
* t" ~) m" p* z" j9 b                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 P9 Y6 }8 p+ g/ K5 `9 D
        }
! H8 c( b, _* _4 |, j) K0 g* L}// end of class ProgramCompareMenu
4 G% K6 S7 v/ j0 O: B$ p# S2 {0 |( D/ ^6 a" G3 [# w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  O9 w- k! M8 V//          AuthorisedUsers.java          Provided by: DRS# o, T6 E1 V; ^
//               
9 g# w: U8 t- R( p' Q/ r5 L. p( L7 \//         Program shell for Assignment 2
, n) k8 }3 c% x. x& Y//
$ V- V9 F7 g+ `% ~$ f//         Represents facts about an AuthorisedUser4 R( l1 d. O  J" Q; j6 m
//********************************************************************) _! ~7 t6 x" s# M  |7 w/ s- Y; X
' ^+ s8 J; A4 ^3 g& I6 \" f, A, _
public class AuthorisedUsers$ K9 x5 ?/ ~; g- y
    {8 A0 A( c9 A0 U* }6 L

# x9 ?. Q. G( g0 x  k. C( t        //-----------------------------------------------------------------3 x  P6 |' \" Y9 B- r& v5 o
        // Constructor
- J1 i4 g7 }. \$ X8 z* q% S        //-----------------------------------------------------------------, p- M, H0 c6 U- r( k
* ^! n8 \. \4 a4 k8 Z7 t" k( @
        public AuthorisedUsers()$ |/ y- p: \5 K2 G- a8 V9 B
                {% P8 \: |, h: C+ u
                }' w3 ^9 r6 S7 }: X$ y& G) s" w2 J
7 b' [6 |, W$ U$ v
        //-----------------------------------------------------------------, s1 c/ G% C& |3 Z5 N: {; S$ {8 I
        // Method for testing that class has been reached1 b. g7 e- p" j5 q) x8 H; ]
        //-----------------------------------------------------------------       
) ~" O& y0 w( f1 j        public boolean AuthorisedUsersReached()9 D+ |" u- U  f) u: x5 e( X+ J
                {
/ d; Q$ M* z0 t. x" {9 ?% V                        return true;                        ; d, x, v% w% T' i4 P; }
                }
- w4 y' Q( n# U) |6 L               
& }9 |+ c3 P! `+ B    } // end of class AuthorisedUsers
# O- ^7 H6 d- m" {0 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 ~9 u; T) K% Q
Shanghai - 2007
, A! V1 @9 {, {( JAssignment 2+ V. i6 v/ e& }+ T! Y# r
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)/ M* f( n# I1 {9 y0 W( N2 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.
3 i$ w, q, b! }! K8 \3 w9 h# WThe staff must be able to:! Y; V' P9 r( |# u
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **." g" W* X( z7 d
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.: o- _+ W+ M  @6 Z
 The interface should provide a menu so that the staff can:
$ Q4 K, P+ _; j3 {8 T7 |a) Enter the names of the two Java program files to be compared% F& q/ G0 H' h8 ^
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
" J- p) q3 \: e& E  e# ~3 J/ y** 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).- I; D, }2 `+ p* a0 M/ ~. u
BSA104 Business Programming – 2007: Assignment 2
5 j9 o( c5 w2 J# c& W  XPage 2 of 5
7 `2 W# O3 T$ h1 B" W0 A. W6 J1 pb) Print out to the screen all the lines of code that are the same
3 B2 H$ {! F. E- X6 q Include the name of the file and the line number of the code being printed for each of the two files; w7 T; |& l3 A2 U( W/ P4 |
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 _; }7 Z: [. q( y. T
 the name, username and department of the user
" V- @8 }5 |  j' Q" }* O the statistics of the comparison
& N# @# r) P9 ^& H' ^  C# H. f( f  @- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* P. |7 O: x; t* L) t" n4 n the recommendation for further checking
( j3 b, ?7 V2 r6 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 closely2 z7 O) `! ?! j; I
 the names of the two files compared
) |) I' h& Y4 J+ Y) |) _( s0 ~( yd) Leave the program (exit). z; q9 A3 r" X& I
The ProgramCompare class: (Total maximum 20 marks available)
. D7 R4 J- t- P  v! o. k2. 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)
; f+ Y; h5 G$ Sa) provide an error message if the files are not found or there is a problem opening them6 ~& @+ i% F: Y
b) compare each line of code0 P; ~" K0 F* y6 h4 H! Q
c) print out the lines that are the same- f" V2 Z+ g: b' L: _* N1 Z: ~
d) count the number of lines compared / lines the same* I5 |. L7 D/ h9 A
The AuthorisedUsers class: (Total maximum 20 marks available)
* g* |) Q* O/ v, h$ H" O2 ]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)' j9 ^- p" i4 f8 o
4. Provide methods to:- g+ R* ?% Z5 @* Z6 L8 v+ x! W
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
) U, \+ G, k5 |5 k5 o) L3 a. yb) return the name of the authorised user
+ V) @8 F1 |5 a* C% S( sc) return the name of the department of the authorised user
) F0 `/ R3 `# g* l2 W7 HIndividual Data (Maximum 20 marks available); p8 y/ o2 i! z2 J5 t
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.
. a& D7 D9 P0 f+ k) B3 s2 Y" aDocumentation (Maximum 10 marks available)6 D$ H, e% }  p4 z( {2 o! 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.) n/ g9 R% L6 G. M
BSA104 Business Programming – 2007: Assignment 2
7 y9 w4 C  F9 Y$ y) \Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
3 O+ [3 c8 q3 z& ?: m不过你要翻JAVA的类库说明。你有下载没有?
: ]; Q- c2 w9 K查询关于对比的函数。貌似关键字是contrast,还有compare/ e: j% q' H' Z; F' z
* x; R& x# L3 d9 R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, H% H2 j8 n5 h( U痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  @0 a) I- `" a  n9 r可以下载到的 是 jdk-1_X_0-doc
( Q+ S2 h0 t  x" s! h8 H
  y7 f; k) M; x2 `9 K[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-7 21:17

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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