找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1385|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / y5 d; `$ |7 A6 |( O9 [/ z4 ^5 W* E6 V9 w0 n. V/ ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************: N: p9 @! Z0 H+ C) k7 E
//  ProgramCompare.java         Provided by: DRS
& j; {, R0 [& j% g- Q4 J2 A1 A//: T9 |( |/ H' R4 E5 u& n. T7 u7 J# g
//  Program shell for Assignment 2
4 L- J3 k! }% A% `  B//& C. u; ^0 P1 G
//  Compares two text files line by line
! {6 L1 Q, n6 O5 B- k" [4 w3 }# b//*********************************************************************
8 Y! {; y4 i# n8 E! K
) G7 ^4 ~/ m5 Iimport java.io.*;
0 Z. _5 S! E' w$ T0 @
6 \, J5 t+ H: Z$ Wpublic class ProgramCompare
0 r: e/ o# u2 @7 m{
# B+ ]0 o* q; n- W: y& H. O        //-----------------------------------------------------------------
# {  I2 W0 V/ ^. F  S" L% R/ o        // Constructor
1 Q, `  Z( x4 t0 }) {: R        //-----------------------------------------------------------------1 G9 E* _5 Z' Z( l: G; [1 V5 r
        public ProgramCompare()6 \' G2 r) }# \" v
        {2 d! U9 ^! V5 ?" K4 E8 N+ @; i
        }) ?5 v/ Q$ i6 M/ S; S: o

0 F% L% O2 M1 b; U5 n        //-----------------------------------------------------------------2 J3 q. p5 C$ k3 a) n% g
        // Method for testing that class has been reached
, g" \: M( k& [2 c        //-----------------------------------------------------------------        & [' ^: r' M4 q: s# U7 ]
, l  y# P3 F7 y3 r
        public boolean ProgramCompareReached()         . Q/ p1 ~* Y; s% e1 U; O
        {: j2 z  N: `* b9 w  r0 M! _* {
      try
' R! p1 P9 k* U6 |2 y0 b* P   {         & ^) C4 |$ L! H! m
                        8 r0 p) h9 @: V8 L( U  E# |* V
                //********************************************************************- V& I8 u& q# y% d6 O" C: p
                // Try-Catch Statement is used to handle exceptions - such as file not found * t3 {! j9 d" N- p$ `
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 F2 H9 d; z( O+ d8 M7 K                // For more information see page 534 of the textbook/ W) A: P$ C1 E3 d. h4 @" Z4 F
                //********************************************************************* i& o9 w8 j+ T8 v* l
                       ]) H& J* f  U9 U- C$ K
        }: o: L, Z0 M3 x2 q" e
             catch (Exception ex) // Exception caught here and message displayed to the screen 4 H; Z/ V" u$ M1 N0 _
          {& p3 h/ ~' x, ~; w
                    ex.printStackTrace (System.err);
& K* g) }% `( V7 I8 K  S% U           System.out.println ("Error message goes here"); // Replace this error message with your own          , D; \7 M2 v( U$ \
        }2 v. g2 l% \$ w( H
                return true;
0 L/ J8 W" D4 u9 M4 l) w2 T        }
+ s8 |1 h' S- H% F" l$ m
7 X  b( m& D3 A# F( U} // end of class ProgramCompare4 u" z6 K% k/ S+ r6 m4 @6 G
8 u% t+ P% j! a( z5 A$ _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  |/ }+ T' g9 w& P; k5 x' L. c. K# C
//  ProgramCompareMenu.java    Provided by: DRS& u! w2 t9 z) G6 C
//: [0 G+ r) j& A# c4 R
//  Calls AuthorisedUsers.java and ProgramCompare.java2 J1 h/ z3 u% H) m
//( W$ M) {5 f- \7 W2 h. n
//  Driver shell for Assignment 2.1 x$ ~7 ]9 j/ Z* ]2 t4 v
//********************************************************************" [% c: I/ x# V) ?
  Y! G' q: t- z: m' _3 ]- n  b3 l; G7 B
class ProgramCompareMenu9 J. u* {: h6 m, W$ Z
{$ e  l1 g% D. q' ^/ x" \, o
    public static void main (String[] args)* z# V+ [, j/ \3 P4 ]
            {
! R( f+ A: ?$ D. e7 n/ ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* \7 n8 M2 ]. U                ProgramCompare reached1 = new ProgramCompare(); 8 ?/ @2 x/ F7 v
                AuthorisedUsers reached2 = new AuthorisedUsers();       
, g! L; G6 t% {                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());+ y9 c  y  j# j' O
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. x- u9 h% x$ g. K& Q        }
! C9 {  E* I! D4 f}// end of class ProgramCompareMenu
* |# l# l. S0 H* V) Z2 ]' |" k- I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 |5 b% E6 O$ H# N9 ]. ~" g. s1 A//          AuthorisedUsers.java          Provided by: DRS3 w- g6 f) G/ [/ ^: {
//                3 t5 ?8 t9 Y( C3 s3 n5 M+ s
//         Program shell for Assignment 2
2 V; z3 `' u# m: N$ K//
) T' D  w. f4 z5 n1 i//         Represents facts about an AuthorisedUser; E" f) e6 D; H) z
//********************************************************************
3 f1 W9 K( j, F! ]4 `
8 o7 R0 a! A9 ?public class AuthorisedUsers
" \4 I1 ^3 q7 C    {
/ U2 C8 v" h) l) \3 x7 y& Y& ]$ I
: _6 m7 O3 ?) Q4 a1 m2 [: Z- M        //-----------------------------------------------------------------7 j& \: I$ {! E2 `
        // Constructor7 t0 A3 ^* ?/ {
        //-----------------------------------------------------------------
9 b# q8 r2 j1 L6 y8 }2 B. [1 E, H8 W: f) |
        public AuthorisedUsers()7 E' ?: n0 e! A% h0 v
                {% q/ ]* A- B; b8 R; _# M
                }
% C4 e% c5 }% y9 T7 d% u' x/ u8 T' q# K0 I5 A6 n
        //-----------------------------------------------------------------! x5 W1 h! |- @" f+ A# [, f
        // Method for testing that class has been reached
4 ]5 u1 P  g$ l) V3 u        //-----------------------------------------------------------------       
. O5 X4 S8 I. k& p# ~" i        public boolean AuthorisedUsersReached()
/ c; ~: G# C8 ~( D) S; Y; ?  `                {
0 w( P1 i! B  x% ]5 t' |                        return true;                       
- Z2 E" R3 x- n, U                }
8 N3 G; R. B8 l3 X                ( Y4 w" t$ Y: N( o( U! Y! W
    } // end of class AuthorisedUsers
! ^% x5 ]& x+ A3 W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 ^8 b/ M: f7 B  q! N# F
Shanghai - 20078 w% D$ x* {! ^  [5 X. j
Assignment 2/ W8 m* G3 m+ Z- }# 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)
$ t3 a4 C! o* T0 i1. 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 q/ f# H/ w/ F9 k
The staff must be able to:
% H% P6 u) n2 B! s6 b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., t" S' m+ M) S6 P5 `7 t( Q
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& c2 b3 b+ v5 B4 \3 E The interface should provide a menu so that the staff can:! x5 {4 G* ~4 ^" f9 D+ e# k8 O
a) Enter the names of the two Java program files to be compared6 k# t" ]; R, n6 X. d7 m3 B7 d
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
  ^5 C0 d5 j% R' h9 [" U- J; I** 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).$ D/ k# V# h) p
BSA104 Business Programming – 2007: Assignment 2
0 M5 N  B4 w9 {Page 2 of 5
$ T$ ]9 ^5 ~- |. s; Q9 {9 B/ A) F* vb) Print out to the screen all the lines of code that are the same
# C; s5 }* K" T( G( \ Include the name of the file and the line number of the code being printed for each of the two files
6 z/ R" z6 \5 s5 \& `* Yc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; v6 X2 P& |3 S) M' B9 c the name, username and department of the user6 c. m7 a1 x# [, i% E
 the statistics of the comparison  E6 B$ i  k  |; p" r5 ]
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
+ ]1 O! n; Z, {/ z5 j7 h the recommendation for further checking
* q+ W5 S' l# 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' ^) U2 |" Q" _5 u9 O
 the names of the two files compared
$ n; C9 o3 f! @) p3 _d) Leave the program (exit)
' _3 A( b9 ^- }6 b1 `& t2 \9 NThe ProgramCompare class: (Total maximum 20 marks available)/ Q) l9 O4 j9 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)1 E0 c/ |2 [/ X. K5 ]' Q
a) provide an error message if the files are not found or there is a problem opening them! s3 s- t7 Y* J/ V$ J
b) compare each line of code1 i( u) c8 m" Y
c) print out the lines that are the same
6 A5 o* O6 J- O9 y" [6 y: X. vd) count the number of lines compared / lines the same5 \# Z- K+ \0 o  r: H7 x6 M
The AuthorisedUsers class: (Total maximum 20 marks available)! p8 M- g+ T- A+ w2 j/ C) ^9 h
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 q9 a  t- w0 a7 H9 O4 p  H, `
4. Provide methods to:9 D4 T. m" q% `3 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; v; Z  Q4 w4 H. q
b) return the name of the authorised user
& }% ?$ X! l! dc) return the name of the department of the authorised user& k0 d/ _* h8 H8 W
Individual Data (Maximum 20 marks available)0 Q" p& q. b  @5 e
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.
- Z9 D$ I+ D) [5 WDocumentation (Maximum 10 marks available)- f: d' k( u" F# N: S8 x
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.5 S. m9 _: @  w) {# B" _, U, Y
BSA104 Business Programming – 2007: Assignment 2
5 B9 _/ L- q. @# u3 h, rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) v* O! r6 {0 [: E5 E  i+ O
不过你要翻JAVA的类库说明。你有下载没有?# b- c: U: Z! U0 x3 T# T
查询关于对比的函数。貌似关键字是contrast,还有compare
/ `: b: O( M" n& f) w) L
  h9 A3 O5 j' S5 g% L/ u7 C) h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 U% K$ D( q* `( p! N! _! Q3 T0 u痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. `* Y2 L  ]7 K7 w. ~可以下载到的 是 jdk-1_X_0-doc2 C: Q+ n! H5 l  C. {  \

: J1 Z/ Y  @+ Z3 c5 j' P; l[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-15 17:17

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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