找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1712|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 g9 _5 [" o; V! Q4 E* \ ) J$ Y' c3 }) ?. 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 | 显示全部楼层
//*********************************************************************
1 r; [% [, t, Q3 E' V0 K0 u//  ProgramCompare.java         Provided by: DRS
: j) r/ r! D# j+ b) f. _& x/ m' {( l/ {//
9 B% x+ k% P( n//  Program shell for Assignment 2
, z3 T0 P5 Q, [1 p//
' D4 ?$ h& G2 G# F5 x, |//  Compares two text files line by line$ e0 l) A0 r. d( f
//*********************************************************************
/ c( [6 X  H4 x# r  H5 H+ J% A/ x$ r# q" }: D3 q* s
import java.io.*;
  F; L8 w8 ?; W+ X/ o  s: O& f, ]% a" `! q: L& Y  b' \
public class ProgramCompare
8 x' L3 ~( j4 M7 F0 W" n{
6 J+ k) v( }6 p5 N" e3 Q! O: E        //-----------------------------------------------------------------% }) Z8 p; z& B3 x' O0 ?3 T
        // Constructor: F. W2 e- o7 L1 w' ]3 x. |
        //-----------------------------------------------------------------
( c/ j3 ^: x  {2 L! a        public ProgramCompare()( o8 n/ R+ j* b- d* Q
        {5 B* G1 z' Z3 `1 }7 R
        }& [) Z# ~; G' M+ c

2 A% M, f4 a  M# G2 K        //-----------------------------------------------------------------' G$ T. x& B# S4 y( F+ l
        // Method for testing that class has been reached
. [  F. @; j& ~4 n1 w5 X7 J. e        //-----------------------------------------------------------------        : P5 F/ `* r* k+ x" _
2 A6 z$ I: ^5 Q
        public boolean ProgramCompareReached()         8 ]3 J- X5 N: C
        {
0 O+ @2 ~9 }% ]+ @6 J' I+ E# j& r      try , c, Z, R$ g+ A4 d/ D% H
   {        
' R4 l6 x7 Y5 V. Q7 M5 }                       
2 I3 Q, L) |' ]" w3 O- H                //********************************************************************
' c) i. |0 p7 b) d7 K% z                // Try-Catch Statement is used to handle exceptions - such as file not found & ^: S! C/ y9 H: s7 X/ h
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
( n; V& l+ ?) w, U' T& B3 x/ E                // For more information see page 534 of the textbook/ \% Z5 |, q" x9 Z) N0 I
                //********************************************************************
- ^+ r: C+ m" L" Z: D* |                    
4 P  A- N5 |( M- Y* m        }; y# a- K1 k0 i& {
             catch (Exception ex) // Exception caught here and message displayed to the screen
) O( V; W/ Z; |* D8 Z          {+ B+ E9 i& X7 w( s2 E
                    ex.printStackTrace (System.err);
# f* R! \! ]4 O" R           System.out.println ("Error message goes here"); // Replace this error message with your own         
# L1 x- A$ {6 ^& b8 g( N        }. E) M% C2 ?  i0 w' H
                return true;
, z! f0 V% l) O; Q, t4 j, P        }
0 c9 ]# ?" U3 e$ ]) A8 ^7 `( {% `" W" j6 C$ d' k+ r1 _) M
} // end of class ProgramCompare
6 u! n: d: [! ~) n& W% D3 R* y0 `7 G! c
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************: _" J" N9 E6 V! b& i1 t+ ?
//  ProgramCompareMenu.java    Provided by: DRS3 Z$ [- ?2 ?8 X6 w
//& W" L) F3 I; q3 V. U$ G
//  Calls AuthorisedUsers.java and ProgramCompare.java) d  y4 D, i3 w$ [* ]8 v
/// d( Y' |# z, c9 `) q
//  Driver shell for Assignment 2.
* S8 E2 P4 p/ B4 a2 |5 y* L. Q//********************************************************************1 t0 |, `/ K/ n2 ]7 j8 |

# Z, U! W! y' f2 Y# `. u9 p, Tclass ProgramCompareMenu
! M1 N" d2 a8 n6 ?' y{
0 [+ t" f# Z( t- j  `9 {( B' z, k    public static void main (String[] args)* s. y% P, d' x
            {
5 Q+ v+ o2 I- }! E( G; M2 R                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 c, _9 G6 b1 ~
                ProgramCompare reached1 = new ProgramCompare(); % g6 Q. A7 ~3 u8 ~, e
                AuthorisedUsers reached2 = new AuthorisedUsers();          _2 N: U* A+ D
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. t# [+ t% g& h' A7 r  C# x0 t# r
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 m+ ^* K. r9 f* v8 Z
        }
3 }1 X0 v1 v8 s$ Q/ I5 s}// end of class ProgramCompareMenu( q5 _0 X* h4 N% K3 x2 n

& x. _7 v' {+ [  D! Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  d9 ?7 D  Z3 u6 {4 v# t. y
//          AuthorisedUsers.java          Provided by: DRS! \, v" m8 [9 {3 g* D! K; v3 x
//                * F* f- v  v; Q6 c4 Y) d% j
//         Program shell for Assignment 2
! C" O. f% F5 M  m# U5 `0 \' d//
5 V+ G. \8 F2 A1 M8 E//         Represents facts about an AuthorisedUser
5 j4 E& ~% a; u! U% b; O//********************************************************************3 @3 q( E  i2 C3 }, m* Q! a

+ Q$ z8 w* y4 c! Fpublic class AuthorisedUsers6 F/ {8 Y7 V7 M) _8 |
    {( e! e2 ?6 A8 D0 N

0 C) F5 j" d& c) `+ i& M        //-----------------------------------------------------------------$ C; n( h+ c, t+ A# d/ R
        // Constructor
! j3 X5 u& K4 q, h4 {$ Z' z        //-----------------------------------------------------------------; O8 k: N4 _: ?  k! x* u+ ?! u

7 H; V; F, N" M( T5 Q; G        public AuthorisedUsers()
  O* m; p$ m% |6 p0 h$ {# V; L                {) s2 ?: i4 _% z+ m: {4 h" \+ \
                }
& t' `" w3 p& V; T( e0 L3 ^2 Y1 J$ o0 y. v
        //-----------------------------------------------------------------: W, Z/ @0 l' W  T- h
        // Method for testing that class has been reached1 o) z) {+ J3 F! ^
        //-----------------------------------------------------------------       
7 @, O8 G4 C- d' _( n& ^; ?        public boolean AuthorisedUsersReached()
9 L. }- t* t0 @9 H8 q                {
0 W- u! @! X: a8 N- ^                        return true;                       
7 {  U9 i6 U2 |                }
1 w" g4 ^6 L" m7 m8 T* Q                5 u& v3 Z% ~! h8 K8 B
    } // end of class AuthorisedUsers1 n4 k. l% N  c1 r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; n( G* Y! J9 yShanghai - 2007& W4 p- }: w: F9 s1 M* ]
Assignment 2" K% O) I7 l0 h% a4 T
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)
5 P$ T& J+ P3 M9 ?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 ^% `' e" K0 B# T- J
The staff must be able to:) f  ?7 r+ K! l# @* B. B
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: q6 E/ x* y7 ?8 |$ S1. 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.* C8 X1 Q- `& U; i" R, S$ A
 The interface should provide a menu so that the staff can:
! q1 a' T, M8 a, t) @* G' Qa) Enter the names of the two Java program files to be compared
3 g" s8 k5 z! j! l+ [+ s5 v For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' _: }1 ?" s( X7 d, _) d  E1 }/ z** 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).# j! v9 B4 L7 K
BSA104 Business Programming – 2007: Assignment 2
* A! l+ t; z4 e( n0 ZPage 2 of 5
, u/ I& w* ?' S4 j! b" db) Print out to the screen all the lines of code that are the same
- p0 V+ O# s& K+ l; d, W Include the name of the file and the line number of the code being printed for each of the two files! j7 r$ [  e7 Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared$ v/ Y& Y1 c* z" r
 the name, username and department of the user) }- t2 M/ n" y0 Q0 V) x: j* ?4 A: ^8 o
 the statistics of the comparison2 `; j: C  ^- i
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 R8 j5 \/ Y3 _; w the recommendation for further checking" I3 j+ `) S( \
- 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
6 N5 l3 x0 w6 p  W the names of the two files compared
  H$ p+ t- w, H" N7 xd) Leave the program (exit)3 E( f# [6 Y9 b6 |  p
The ProgramCompare class: (Total maximum 20 marks available)3 j- d  F1 M& r! y1 l6 c( g
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)$ \6 [1 @2 j! A+ x, J: s
a) provide an error message if the files are not found or there is a problem opening them9 a8 h9 d% J. R, D6 o% e& z
b) compare each line of code& I; L/ e% g& M: ]5 e
c) print out the lines that are the same
0 F" ]# H7 q/ u# O7 S( a  p! Sd) count the number of lines compared / lines the same
) J( z! C+ p: P* \& x8 _The AuthorisedUsers class: (Total maximum 20 marks available)+ g- @7 E  p% k9 q. h8 {! e
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)
, j, `) l6 T5 B7 B4. Provide methods to:
! r5 h# _' v+ T$ y6 q# ka) 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- [+ L; ^% w4 u' B1 j1 y
b) return the name of the authorised user
% `* P7 Z6 a+ J, H  r: xc) return the name of the department of the authorised user
. b1 o" }2 J4 O8 r" D3 PIndividual Data (Maximum 20 marks available)
& P" L/ g+ `6 R  }, T5. 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.
+ T+ G6 {& c2 c3 `( D% xDocumentation (Maximum 10 marks available)
3 E1 N( f/ R6 g) x8 L) q6. 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.  J' l) f% d! H# N
BSA104 Business Programming – 2007: Assignment 2# G( n  y, Z- ?' ~2 }
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ W+ `$ g5 [/ w
不过你要翻JAVA的类库说明。你有下载没有?
3 d8 r2 U1 _, M8 z* q2 [, R, I查询关于对比的函数。貌似关键字是contrast,还有compare2 r- x2 a" i/ r5 N# U; u1 ^- r

9 L0 Z; C; B! Z% k. [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 C$ c6 O( Y/ _, B! k! d1 }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 B) X4 C( _+ R7 r( Z
可以下载到的 是 jdk-1_X_0-doc2 e, U) z  m- o' ~; {* l

' U! ]4 z% Y$ S) W[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-8 19:23

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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