找回密码
 注册

QQ登录

只需一步,快速开始

查看: 924|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急/ P' r/ G+ c {- n5 c. L 3 `+ D* a" ~2 O
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************7 }7 `0 c; n1 q- P. j% `3 d6 l, f
//  ProgramCompare.java         Provided by: DRS
, l; H8 ^  f4 P0 t" h! [( w/ `+ m//: s# q8 f, @% [6 [. e/ V( ^2 k! _
//  Program shell for Assignment 2
5 r- W+ S; h  m: q$ f4 L3 K//
0 P6 m2 H5 C5 ^5 A//  Compares two text files line by line% n4 _1 n+ [" i" `
//*********************************************************************1 @5 G3 l/ @% a5 l0 n- b+ A, u" D

6 [2 e, F! J4 g4 fimport java.io.*;+ a) b, h7 P; k2 z
% A9 _& {5 e, B; N6 ]8 Y. U
public class ProgramCompare
0 i0 m0 ^$ Q; g3 e{( e3 y- w1 m" h$ `# P; G, }7 F/ _
        //-----------------------------------------------------------------
: I) O' S) A1 Q" Y- G        // Constructor6 }: O! a, @% l0 P! \+ _) h1 I) v
        //-----------------------------------------------------------------! o. h; a0 j9 f' w8 }' n
        public ProgramCompare()
6 _# Z( x  j% A        {
  B# S" {  C: f( {( I- I        }2 s5 ]: G' e8 p% [$ d* Z
0 i9 [1 S: Y$ C- I" R( {' I
        //-----------------------------------------------------------------% T7 {& b6 N4 e
        // Method for testing that class has been reached
6 ~2 f6 W/ a& U! [) d* a5 _2 }        //-----------------------------------------------------------------       
4 H/ Y# F, z5 y' ?5 a; E. y4 A% \9 W2 o/ u- x
        public boolean ProgramCompareReached()         % d# d( H" j! i0 F0 m+ g
        {  Q3 S  d3 }& k' `7 o2 `1 j
      try
4 G* s3 k( H+ e* ^7 l( l   {        
5 W+ r8 j3 Y8 D6 {( ?# F                        : @+ t9 a$ W5 g1 A* @- T
                //********************************************************************
, q, M; _+ }( c: F                // Try-Catch Statement is used to handle exceptions - such as file not found ; l0 K  z9 j3 A2 C, `6 g2 O
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- O+ T4 b( D* Q! u$ y5 ~
                // For more information see page 534 of the textbook7 w- R& \: Z) W3 M
                //********************************************************************) k. h' h! v) M/ P) y! {1 G
                     1 z1 r+ p6 ^0 G: M) q- H( X& r
        }  O" T  a! q9 B) i6 @& J7 T
             catch (Exception ex) // Exception caught here and message displayed to the screen - O, ?4 T; g) f+ p1 y+ s% D
          {: Z/ D: S" g: q' J% f
                    ex.printStackTrace (System.err);- P4 S- y! @+ I/ M( T
           System.out.println ("Error message goes here"); // Replace this error message with your own          % l6 n  ^/ m! ?) s
        }
, P5 U2 e7 i# Y2 V; O; M                return true;- o' v) c" }( I2 n: s7 b  y
        }$ m5 }0 h# `! M1 H3 j* {. W* b6 c
5 m/ C7 {' K. c
} // end of class ProgramCompare
4 n! l5 S. g& f  {' n; R% [
1 J# y3 ~2 I$ j; b1 A3 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& F( U: \! m3 P8 r5 m
//  ProgramCompareMenu.java    Provided by: DRS8 }/ t7 J& k' I6 q6 }% r
//
9 ^- \. Y2 k0 c# d! G3 c//  Calls AuthorisedUsers.java and ProgramCompare.java) R+ y( ?8 `( D2 a; C& J/ Q
//5 X3 l8 t' s; m5 E$ H, \" l
//  Driver shell for Assignment 2.# ]$ w. k, b/ v: e
//********************************************************************: M+ I& `; r5 l" ]! x) b* k/ |
# e. p/ \+ T5 c" t
class ProgramCompareMenu
  U4 v4 k; m) J1 N7 R  v{" K( p6 Z! W. X' U' m1 P
    public static void main (String[] args)
8 i3 o4 c4 E4 w% i9 v6 i            {
* }2 E) d$ H0 I- T/ S" b                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
1 L  I$ B8 m7 X* N1 F  r                ProgramCompare reached1 = new ProgramCompare(); 9 \: x4 C2 E$ x% T0 x
                AuthorisedUsers reached2 = new AuthorisedUsers();       
% _) k! u$ ?9 n: P7 G9 T                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ ~5 s5 K9 Y: C9 Z5 r) k1 E  G                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        3 K, H7 s: p; y) L0 W1 Z$ O& g* F
        }
# `/ P  L: ]( Q0 D6 }0 v}// end of class ProgramCompareMenu/ c& |% g8 s. a

' a. d& q: P+ f6 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 ~+ O7 `9 x. j$ W4 N//          AuthorisedUsers.java          Provided by: DRS
! G' Y% l, l+ G/ l2 B' f: |//                & i! g/ z. m+ h- C! Y# L
//         Program shell for Assignment 2& U: ^5 ~3 |2 ?  F/ G% a* a
//
4 m6 e2 b% i0 O: b& k//         Represents facts about an AuthorisedUser
6 X5 s7 O7 I; z1 |//********************************************************************
8 i+ b; L* j* s4 g8 D; Q, ^
$ T; z* y9 N. q8 x0 \- Ipublic class AuthorisedUsers( ~7 D& u% h8 w& K
    {
4 E! ~8 y, D: S. S- A
) n. c3 L7 g# y' A7 V5 F        //-----------------------------------------------------------------
) x) A- I  `4 h        // Constructor: j, `& P9 o3 R' t+ V
        //-----------------------------------------------------------------
; J; ^' J6 z4 Q  S! V8 o; n6 N
8 _* G3 a4 H  E1 e" U- l) A2 w        public AuthorisedUsers()
. X2 y. G5 w$ n                {6 ^  p; v3 G/ \: f" O9 y, V' M4 I3 R& _& b
                }
  A7 l5 K& b  ^, R& X# H8 l
% D  c. R$ N- S. e& A3 b7 F; f3 F        //-----------------------------------------------------------------
$ ^$ {/ k; d2 T( l' F+ A        // Method for testing that class has been reached
; g6 |  n. i/ g0 `4 J# s; U: y1 C        //-----------------------------------------------------------------        ( @" t) D+ j% L. s& f: r  W9 N. V
        public boolean AuthorisedUsersReached()
; X! |- Y6 H, x. X8 ?7 a: y                {
6 m  f, v- s; D$ u  M                        return true;                       
- e" R& ]. r1 \  ?! H" J                }3 }" `& W( x( w, W1 y
                1 z( m" R! e1 r- V6 S# `
    } // end of class AuthorisedUsers. ~: |- \+ W' d; a$ @0 v- j0 A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 T8 ]. Y& W9 n5 A  t, B% ?Shanghai - 2007
: M% ]' D. Z6 `- h7 }3 m# f# _Assignment 2( P- h. P/ Y! n8 m/ y
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)
$ B; z0 c$ f$ ]2 N1. 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.
/ w8 P: v- r2 v1 [' r8 a3 a! IThe staff must be able to:
+ F/ d3 X% C. H- m2 B Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! U1 q$ H5 A* I( ^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.
9 |* p* `* m, V0 H. a3 M  z& U The interface should provide a menu so that the staff can:
% _6 A  E! i' H9 ^3 s2 @a) Enter the names of the two Java program files to be compared3 E% B' H9 k( ^
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ I) ~- e' s" K& w* ~. V$ B** 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).
8 ^" r3 s& v) q# T, dBSA104 Business Programming – 2007: Assignment 2) l' Y; K7 }# ?
Page 2 of 54 N$ F% j* c9 x2 V+ ]
b) Print out to the screen all the lines of code that are the same3 o! z7 s4 a2 F* J  h
 Include the name of the file and the line number of the code being printed for each of the two files
* s' ?, l5 p  @& Fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ n& |8 Q4 S; u9 z' k: i9 L# B  ~
 the name, username and department of the user/ Q  Z; U" `( I4 o! Z
 the statistics of the comparison
, d) u2 k; v1 I( m- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* P6 w! P0 d. b the recommendation for further checking1 R* A( ?2 ^+ f
- 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
# h4 ~( B/ W' Q0 f8 n; b the names of the two files compared' V0 A0 H8 b* H$ R- f- ]
d) Leave the program (exit)  ?" }) t7 Z7 G
The ProgramCompare class: (Total maximum 20 marks available)8 q( K2 j# W, Z% ~
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)7 K8 T; r5 \3 _. L
a) provide an error message if the files are not found or there is a problem opening them1 I1 t' Y1 L# \+ x; q, W. ]- N
b) compare each line of code) x8 C+ x3 d5 Q5 s! ^! f, |
c) print out the lines that are the same
/ e6 d' M0 E9 |1 o6 [+ s9 G  l- ]& u$ _d) count the number of lines compared / lines the same5 G3 y% g! C, ]# f5 l6 h
The AuthorisedUsers class: (Total maximum 20 marks available). ~6 Z- [4 X/ W4 X2 s
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)! g  r, y/ t, H& L3 B! X. V9 Y
4. Provide methods to:
4 b* n. o+ k( E' i. p5 xa) 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
, O8 n! K- _' ^/ l9 ?$ jb) return the name of the authorised user
& E) I, R  N) ^' Tc) return the name of the department of the authorised user. L' r& ]1 r% n
Individual Data (Maximum 20 marks available)2 J% {* i2 C: ]. ~( j( M
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.# l. |* d. C5 W6 X" t5 ]& J" g
Documentation (Maximum 10 marks available). ~# `0 i7 u' U4 J5 F
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.
! E& t$ x/ H( e, i! w% }0 pBSA104 Business Programming – 2007: Assignment 2: \+ p+ I( u- J( U$ X" w4 M
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
0 D. e0 w& `6 P6 k$ h% D/ h' S不过你要翻JAVA的类库说明。你有下载没有?+ U' u8 B6 n3 P: a
查询关于对比的函数。貌似关键字是contrast,还有compare6 n5 f: E* c* d" j) v

, n" y" V0 S3 P0 G% q6 G. g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: |" ^3 a- ?6 x9 \" W7 Y4 _% w痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
3 F% N$ j' D1 E. r可以下载到的 是 jdk-1_X_0-doc
, E/ i: H" I! X. Z" N& t8 A4 [0 h9 o% f
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-1 00:51

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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