找回密码
 注册

QQ登录

只需一步,快速开始

查看: 798|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 w! L( b" G6 a% Q 3 W; B+ m9 X/ u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************6 i4 \: ]" n9 ~: p; B, M
//  ProgramCompare.java         Provided by: DRS% b  t) {4 s- P! X1 X+ b, x- \
//' N& }: ^& b) l
//  Program shell for Assignment 20 g, e; j/ |+ }$ J+ O% j7 w& Y
//
* ]! I$ t) S9 t. M  d7 n: S, Y//  Compares two text files line by line4 o8 I0 o1 j) f( A0 w, [
//*********************************************************************. M  l3 q( d  |( x/ x

/ w2 \& R! Y9 T! j* Pimport java.io.*;$ h9 g2 R1 p; C6 A, C

! o7 Z0 R) X4 K5 Dpublic class ProgramCompare
8 q4 T! T1 ]1 f& N( U{
& q- h7 I+ P6 E1 j: @: C        //-----------------------------------------------------------------' R  e3 k. j4 `0 ]  p/ V2 N5 P
        // Constructor
1 ?$ s6 R6 r% w6 u' i: Y2 v8 x        //-----------------------------------------------------------------7 H5 L4 \) o- x; u7 |
        public ProgramCompare()
  V* i  \- U# h3 h+ O# ^" R0 @( M        {. e- V- z2 o( [6 h! p0 f- }, W8 [$ ]
        }
& N3 ]6 ?# h& E) g% L4 Y
" A7 i: h3 K1 ?4 D: O8 @# t        //-----------------------------------------------------------------
  B( S) w' |( g  y4 m5 c        // Method for testing that class has been reached
: Z$ H3 B% y" d        //-----------------------------------------------------------------        , W0 y: _9 q+ e# {. g" s" m8 t* O

, ~9 I: I3 |" n' p3 Z1 g        public boolean ProgramCompareReached()         , J; v$ w: |( V
        {
1 {& J; ^5 J% B2 K1 _      try - v' `$ y2 S# A
   {        
" |" E* c/ n& q0 Q; [                        / Q* L. W3 O+ j$ P" p; I
                //********************************************************************
- P0 r" s7 _" I) U                // Try-Catch Statement is used to handle exceptions - such as file not found
- k8 M0 U: c0 @6 a' M                // Reading the files will need to be placed inside a Try-Catch - just like this one!; x" C2 }% v+ X9 R) T8 p0 V
                // For more information see page 534 of the textbook
: K* h7 T: |, o9 e1 R- H7 J, G                //********************************************************************
4 I! L' v1 O6 l' T& @4 Y                    
) _% V+ J  f1 T5 S- f        }
1 P3 A! X& L' _% p' G% H& h             catch (Exception ex) // Exception caught here and message displayed to the screen . Q2 |7 s! z2 j  v* ~! M1 m
          {
9 i. K' a- J% J, D8 ]                    ex.printStackTrace (System.err);) Y  a# n. H0 s  A9 W" R) j( S  O
           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 m; `4 m* F% m1 n1 I* ~" R8 |        }' {" o$ J0 k1 t: x' w
                return true;
& I+ u" f) p7 @) n9 P        }# ^% r; [* ^  i$ ^! X) o; g
$ u( S. y- F6 Y& i" m# ?
} // end of class ProgramCompare
+ o6 W; f+ n8 W: |) y1 _6 {4 O- g5 P) a, @! U* e. L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 E& ]% w9 ^- _1 v//  ProgramCompareMenu.java    Provided by: DRS
3 |3 S9 o) {  d+ n3 ]' s& e, X//" ?+ d  C" x$ N; w$ s
//  Calls AuthorisedUsers.java and ProgramCompare.java% w+ r' X1 X% k
//* M5 h  Z, r# s/ {* x
//  Driver shell for Assignment 2.3 B- F, ]: b. a8 L. U, [
//********************************************************************8 ~* @9 t9 Z5 X1 R

( ^# V+ Q' y2 p, z9 k# tclass ProgramCompareMenu
# e; \9 }9 z( _( R9 @{; E( @4 r6 a$ P$ e
    public static void main (String[] args)
$ T  W; |# g* {% d            {
/ I/ Y3 R! k5 h+ h: b9 i  X                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: c, b1 j2 V% E+ a, Z; g                ProgramCompare reached1 = new ProgramCompare();
8 O2 {1 h9 l9 v& S                AuthorisedUsers reached2 = new AuthorisedUsers();       
' _0 T' X- {; }# I6 p3 M  F' @                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- Y- Q# P1 M0 A" \" ]# D; e
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        - v+ S; E, S7 b7 ~+ C
        }- e; e3 G& `* o7 P$ o9 Z7 D1 Y
}// end of class ProgramCompareMenu5 X, k* z6 L" ?8 v5 [
4 q; U$ ^/ W0 _! Z" _- y1 c! b5 N$ G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 {) n4 i' k, I- Z, K) v//          AuthorisedUsers.java          Provided by: DRS
6 I$ ?+ {, V7 U8 x* L/ Q//               
, r: j7 u* R1 i  n; h: S8 C$ O/ S% n//         Program shell for Assignment 2/ R6 x0 a" C8 L( J7 A5 @9 V5 t# C
//* h* L. H; O7 o6 p% Q
//         Represents facts about an AuthorisedUser, j) d. x: e$ ?/ S' v' N
//********************************************************************
8 _( l: Q- H8 I. S7 L8 k9 e! ~2 V2 ^; g2 ^% t
public class AuthorisedUsers
$ o6 _3 O( f: }+ |4 q    {5 f0 K# t( a+ \- J" ^+ U" e  B  w

* e  V( d3 o, X; b* @! F        //-----------------------------------------------------------------$ p* u0 m) @: Q
        // Constructor
8 x: f" H2 i( e% q3 u, d        //-----------------------------------------------------------------" H$ m9 ^2 G8 Q& C: O4 w# R

+ K% `  o$ B3 W1 {. I& H7 e4 A        public AuthorisedUsers()$ f7 _+ n/ g6 v7 u% K
                {
2 F- a: ^$ B# w& w' c/ L" k4 D3 U, {                }
% n' a. b, {7 n) n
- x. ]3 _9 ?! s5 |  o) w, E        //-----------------------------------------------------------------
% H/ O" f( }# g2 r  i2 R        // Method for testing that class has been reached2 h, I  b$ C; J6 q
        //-----------------------------------------------------------------        * g- S  F6 j& R4 f
        public boolean AuthorisedUsersReached()" R/ _8 u& e5 u, ^, ^
                {( I" N. g6 J5 E$ v6 i
                        return true;                        , ?: t) Y4 W$ @0 R- F
                }0 o0 t* W3 |% k
               
+ X& L" I9 s, R* Q    } // end of class AuthorisedUsers
, G5 i; `/ n( X( W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" n: S+ X; R# _, j% a% HShanghai - 20079 i1 a' |4 v5 R/ V. t6 R! S/ u" g
Assignment 2
! `. M, p0 A' r: z- O$ c& fDeadline 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)8 M. A' b8 B7 a4 b( a* d$ Q
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.
4 |9 S+ e# E7 {+ t8 {3 u) _The staff must be able to:
: W9 m2 l5 S( k& v Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
- a* f8 m# }  v) Q4 S) k1. 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.6 D$ ?7 \& o, w& W$ F# G& n" n
 The interface should provide a menu so that the staff can:
! L" E! v7 K& k9 ?3 r6 aa) Enter the names of the two Java program files to be compared6 L! W5 E  ]* N4 Y. v% [
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- |+ ~' M% z0 F( j& 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).
9 S( M% o8 _, _2 R  oBSA104 Business Programming – 2007: Assignment 2
- F+ r$ l0 ~3 n9 H4 E$ a+ F4 M: |Page 2 of 5
7 t9 N' p+ r% d, ^) ]( B0 ub) Print out to the screen all the lines of code that are the same+ M# a) R- O: b/ P
 Include the name of the file and the line number of the code being printed for each of the two files& D; U; v5 }3 w+ P% m, W' t
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, v0 |7 O6 v. e( o
 the name, username and department of the user  z' x9 `7 l. f+ I- S( y
 the statistics of the comparison
, f) ]7 i2 H$ g7 |* X- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 x) Y8 q6 u* s5 y
 the recommendation for further checking
3 \" T  I2 ?6 U, f1 Q" J5 h$ D- 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
% l+ S: @& n" X/ b! l the names of the two files compared
0 e1 s- O6 d! |% x7 _, Wd) Leave the program (exit)
7 V) {& _% n: G) y$ e9 FThe ProgramCompare class: (Total maximum 20 marks available)
  f3 x; J( M2 ?' K6 H1 g2. 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)0 I" Z- V; v, o: ?
a) provide an error message if the files are not found or there is a problem opening them
  l8 Y( c& t! F7 M  }" G' {b) compare each line of code
5 _+ a: a+ P* \5 k& j+ q/ e/ y- Gc) print out the lines that are the same
9 f" ^; n9 a  i* y: u* Q! _( N+ a$ ld) count the number of lines compared / lines the same
/ G% F3 a6 L/ m( t1 lThe AuthorisedUsers class: (Total maximum 20 marks available)
1 l2 U; k  g# Z' e8 b; n0 f3. 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)
' I! g4 S) q/ U% e- b- h/ @4. Provide methods to:4 t4 |6 h4 C) u: X# h* l
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) P: O, C2 p6 m, ~! d5 L5 }
b) return the name of the authorised user
8 v9 l* Z1 W1 Mc) return the name of the department of the authorised user
4 P5 m- p+ w) v% O* u0 d" e- bIndividual Data (Maximum 20 marks available)7 a. _7 e+ i$ Y2 `
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.
* w+ g& ]& M  e$ _Documentation (Maximum 10 marks available)
3 D5 j- ~9 N6 l. _+ Z( u8 _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., b5 a1 Y" v, D: C, w7 E
BSA104 Business Programming – 2007: Assignment 28 v) [2 H9 S, j5 ?
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了- b: [9 [8 ~5 L8 `. g; Z
不过你要翻JAVA的类库说明。你有下载没有?! E7 ~' ^4 u  _" V
查询关于对比的函数。貌似关键字是contrast,还有compare8 i, r* ^: P: N1 S+ a% L# `
- t; c0 G9 D' y% H3 x5 c* S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% }' i# @5 Q1 n+ C( j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 ~/ e. p4 i! v4 R2 c8 j  v# E可以下载到的 是 jdk-1_X_0-doc) e( s% I9 ?* y) `1 p) J% u1 P

/ A  X9 X. }/ D! M# h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-1 17:01

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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