找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1870|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ I& W$ k/ q( n ^5 ?! ?7 G4 V " c5 l% Y5 P; `* S
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
+ h8 N5 \6 N* b//  ProgramCompare.java         Provided by: DRS6 [* s( }4 H9 {7 b6 s; q, D1 |, j
//
3 {+ M3 ]" y, M//  Program shell for Assignment 2
4 l: p# j( ]/ K8 w) ~4 m//
; U% V: ~3 K; {; i- y//  Compares two text files line by line, v3 D  ^/ ]: [0 p" g. w
//*********************************************************************
! K: _2 E( e/ V# S9 _3 C+ v9 n- F
import java.io.*;
/ h/ c! U% C' B0 f
5 D! k1 W- w% @% Epublic class ProgramCompare
' m+ I$ q) O, r{
; k. s8 Q; N1 h- g. S7 [        //-----------------------------------------------------------------! J% f' s8 m5 e7 Y, [
        // Constructor* w8 K) F4 ]& B8 {- n* Y, x- V+ |0 G
        //-----------------------------------------------------------------  K2 B3 b" K' T( s% q$ S
        public ProgramCompare()
% S$ V3 V" R1 b- c  P: l* Z        {
: m4 a- i& G8 d        }5 F7 @8 b) q  q$ y
2 {1 x: F) |2 |
        //-----------------------------------------------------------------2 T; A5 s* D6 N7 o# E
        // Method for testing that class has been reached; D- i; j' v0 ?7 Z( p( y- X
        //-----------------------------------------------------------------        ; q& `; ^0 E' Q# p+ V
+ q" z3 z7 |. D6 P" Y3 d% b
        public boolean ProgramCompareReached()         2 {/ ]  c2 q' O* }, {' o- X6 s! {
        {
& j; p2 |. v( Z" r  G0 K      try
+ f; H2 A5 R. f. T- D   {        
0 _% k2 W; }8 a+ {, O! r6 f7 ^                       
9 Y! e4 _' Y' y, v                //********************************************************************! N+ N, A5 q/ L
                // Try-Catch Statement is used to handle exceptions - such as file not found
: {/ A4 l: e+ s" {" z$ p) v                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  S. g. ^5 \- s, b8 t" Z* `                // For more information see page 534 of the textbook' A6 q9 u4 ^: J5 Q2 Y* Q
                //********************************************************************# @2 a# f1 n4 C; ^# [8 o% g. y9 W
                     + l- A9 s4 h" {4 Y/ o* M5 x
        }
5 x2 R2 R" B+ f$ {0 Z: N             catch (Exception ex) // Exception caught here and message displayed to the screen
( x1 \6 W, T; x3 ?% g4 X          {1 P% G+ O$ S7 I2 g- b! {) Q1 \
                    ex.printStackTrace (System.err);5 d, ?# L0 E2 x5 ?
           System.out.println ("Error message goes here"); // Replace this error message with your own         
3 E# t2 P; ~( j2 f        }
, G/ @6 s+ z; Z9 k7 M" k, H                return true;% `* U- f; t1 }6 O2 i- P
        }( g$ o4 I! O: H, E9 r* b" x" \( ~

, C$ I7 Z/ I& A, l& q} // end of class ProgramCompare! G; w0 ]% x% ~8 ]
" ]% T& `$ a" @1 k5 a# Y. C$ ~5 n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 E- ^) J' ?+ Z0 a" e0 ^//  ProgramCompareMenu.java    Provided by: DRS
1 Z# H6 W( |$ N4 A2 B' M//0 ]1 x7 X# j. S1 r
//  Calls AuthorisedUsers.java and ProgramCompare.java- r/ f9 D6 y! c& ?
//
* O# O9 G! S  p//  Driver shell for Assignment 2.! B& q% h" I# ]- v
//********************************************************************; P* G1 s0 v6 k6 B8 E: N* \$ p
: C4 ]# M2 S4 C% d6 {! _2 Z
class ProgramCompareMenu
$ S& p$ }8 c- a1 t0 B; o1 N; S{
5 ?0 g& Z( b" w6 d( n3 f/ z" f( \9 F    public static void main (String[] args). y1 |/ L4 s, p9 I* r
            {
$ S* H' f# E  ^& y6 r4 E/ n2 `/ A                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! K" d; _6 R+ N7 A
                ProgramCompare reached1 = new ProgramCompare(); ( n# V) M4 ^: h' I1 D' S
                AuthorisedUsers reached2 = new AuthorisedUsers();        # s  j% V5 ^+ q' s
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 E% ?3 ]+ g8 J6 x; P$ m/ P" b; |# o4 s                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 ]$ B- Y' w3 H3 `" @0 m* o        }
" o- r$ a% R4 ]# t' T1 l& ~; U% X' f}// end of class ProgramCompareMenu
8 X  z! s4 e3 ?0 Z
+ ]: f' B/ X8 m& I( V4 L2 v8 n, {" o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; U2 S& ?4 I% w; ], v//          AuthorisedUsers.java          Provided by: DRS  [" O/ A0 n4 R2 f4 c
//                " E* {9 I" C/ J* a  |% j) b
//         Program shell for Assignment 2
! d+ L/ C/ N! F& l, O8 f//
3 t5 C. j& ~9 ~* i//         Represents facts about an AuthorisedUser
6 n+ o/ p1 n$ h0 H5 Z//********************************************************************
+ r7 n' z% F% L. u  |
- I- T5 z% [3 Y! V! vpublic class AuthorisedUsers5 r, S, j6 ]: i; Q8 C
    {
: L/ V7 w* p) k2 q# ]- o$ {3 Y" T' g" w/ \$ {; y
        //-----------------------------------------------------------------
6 r  b: ~1 T+ Z0 K, C        // Constructor8 T; w  w9 I- T/ F% Q9 F; a
        //-----------------------------------------------------------------0 T  o: f# P' J: w  L6 R
+ t4 R9 Z7 ^& f1 F4 G
        public AuthorisedUsers()9 |" N6 w/ Q; R) K
                {
  M' }- C6 h& S  u7 \6 }2 R- P8 d                }* d8 V& {, i. g- y
5 I/ r* s$ [/ e* q& F4 t
        //-----------------------------------------------------------------
! d4 K0 K- {* n! w        // Method for testing that class has been reached2 p* `( e+ }% ?3 f; f  t* b
        //-----------------------------------------------------------------       
5 \$ L3 Z5 c7 S1 i8 \        public boolean AuthorisedUsersReached()8 J9 M; \1 Z/ w* G: t7 R
                {
3 `% G8 @" h) W  p9 G. s                        return true;                        5 J: O! K7 U, F4 j7 z5 E6 S' Y
                }
) H7 G" r3 q+ ^( l, V; o               
: S$ T1 ~, I. H: u    } // end of class AuthorisedUsers
9 r. |& L, A7 v& i9 t7 J5 s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( {6 H% ^8 A% T8 O1 wShanghai - 2007
/ O2 f$ a: V* z8 W$ L% NAssignment 29 e& J! L1 b2 K& D# l6 t$ N+ B3 O
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)9 W+ j5 c6 m8 a+ Z
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.
' ~8 \& Y" Q* [: K  ?1 _0 cThe staff must be able to:. w" E4 z6 g% @' a( o- u
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ e# I/ d- q2 s3 m; C1. 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.$ L1 j, }' x) z: J, b( h0 k5 V
 The interface should provide a menu so that the staff can:
6 H+ ~: s9 d5 Ua) Enter the names of the two Java program files to be compared
; Y: |- B& p! w For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 [8 T- t: J( V/ j
** 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/ S1 C4 i+ RBSA104 Business Programming – 2007: Assignment 2
+ j. @9 N6 H3 a, F, bPage 2 of 5# I' d) V7 u7 {+ r6 l
b) Print out to the screen all the lines of code that are the same
5 H, d$ S- ~# A/ a9 x! {5 Q% m Include the name of the file and the line number of the code being printed for each of the two files9 v' g; `4 S! U. G1 S+ X
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 X) ?2 G! {" ^5 G: c" r/ M the name, username and department of the user
9 b, M- q: K. X  ?% u the statistics of the comparison
8 d1 Q6 B, r) R) v- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different( O3 _3 l$ Y# a, t% y3 n
 the recommendation for further checking  }8 J6 e5 g3 w9 t
- 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$ y: s! c, x) n# g6 O& k# t the names of the two files compared
2 p% `: }& Q" N' U. O3 H; q. id) Leave the program (exit)
$ R: }$ V8 W2 A! C( WThe ProgramCompare class: (Total maximum 20 marks available)
6 l' ]2 d# j8 n* w1 Q3 e, _, _0 y2. 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$ X0 |7 D- m9 ]( v; Da) provide an error message if the files are not found or there is a problem opening them
% M* {9 e3 V6 O, v: Y% \" rb) compare each line of code
3 e! m( p, f" h5 n5 Dc) print out the lines that are the same# @8 q- d' ^7 m
d) count the number of lines compared / lines the same
- ?( [& c2 j% U/ K( u' O/ nThe AuthorisedUsers class: (Total maximum 20 marks available)
* a1 @1 q) a6 ?" v3. 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)
  @1 f* B% T5 G5 X& w: w& X$ P3 A4. Provide methods to:/ i, l' H3 I, H0 e7 J( P1 T
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
9 i3 w: `, x, g4 u7 y; Gb) return the name of the authorised user
" j9 g" |2 s9 M" I5 Z; a$ S9 qc) return the name of the department of the authorised user3 i0 l  \/ j) r) S( p
Individual Data (Maximum 20 marks available)
  h% |$ y7 \* V( y) o4 N5. 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.
# ^) u% R! ]# \. t6 y& ?6 QDocumentation (Maximum 10 marks available)
* R( q: x2 D' N- q$ A: f6. 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.8 {& U( C0 G; x& C. j
BSA104 Business Programming – 2007: Assignment 2; A$ p; v+ a; ]7 y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& c0 L! y/ e0 l& w3 z
不过你要翻JAVA的类库说明。你有下载没有?
6 Z7 s% o8 [+ ^0 U' Y查询关于对比的函数。貌似关键字是contrast,还有compare- }- q* u- [" l
) X, K7 s' u* L: W: W  R) q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  X0 h, W2 v- R5 m" [6 Q7 }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
/ x  K& _4 h/ y, {2 v可以下载到的 是 jdk-1_X_0-doc: |1 v! @$ s4 r$ X; B$ h, F

( _6 }/ U9 s9 `/ s[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-12-3 05:14

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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