找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1819|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 }! T$ i0 m. T' ?$ l" r 4 H( ]; H) h2 w- Z" V8 o1 q/ I
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
2 X9 Q) V+ S5 ]6 A4 a//  ProgramCompare.java         Provided by: DRS# c  z3 y1 B5 V0 {
//5 F! ?+ Y1 U6 j8 B4 U
//  Program shell for Assignment 2% ^  U+ q) t/ E1 ^8 O. P
//" o, ^6 v2 O; z4 @* N% d6 y
//  Compares two text files line by line3 C' ^0 @4 L3 \3 ?; U8 O
//*********************************************************************  b" K' B7 k& Y$ O# q" f* F. X

; F9 ]' K# C  m  \import java.io.*;
% Y2 `* I0 |  q. }! V- W  O
* j& C9 A0 F1 T9 z: s# }, D9 Npublic class ProgramCompare/ {( }8 C" |: d7 M8 a
{/ z9 }5 f! r& Z
        //-----------------------------------------------------------------, b$ {7 V: v* s, p8 m
        // Constructor
- i: Z- U$ f" v2 h, }$ i        //-----------------------------------------------------------------
2 o% \' s# B; L$ }! K. {7 ]        public ProgramCompare(): ]0 v1 E, ]/ H
        {9 F0 Z( U% g" `- p. q5 {
        }; \7 b; p5 w; {0 h
. T) J4 n: g2 ^6 ]6 t
        //-----------------------------------------------------------------( [3 X4 b/ H3 r
        // Method for testing that class has been reached6 Z9 G$ H, O9 q( I3 P. j
        //-----------------------------------------------------------------        6 A) G- |4 U+ H8 A0 q
6 K, j& P& r  M: u# x! k
        public boolean ProgramCompareReached()         4 Z5 m4 J1 k0 e! l  Q, e0 x
        {
4 E# |3 x9 g9 m* U% @      try
7 {! l- R8 m. w, s  B   {        
1 b4 i* Z4 K3 h3 D  u8 `  ^/ J/ Y                       
0 o4 \0 A" `( `9 y/ s8 I# Y' Y7 o( x                //********************************************************************
' R0 }! S% m' R, X7 u7 z6 g8 e                // Try-Catch Statement is used to handle exceptions - such as file not found
. R3 q! [+ t" t                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 w6 W% j+ E. {, X. r0 f7 o: h
                // For more information see page 534 of the textbook
: j# s# Y$ J, h4 x$ ?8 r3 h, Z                //********************************************************************: {9 D+ i& h) ^5 g3 K6 _
                    
) _. D2 R; I1 @% W- }        }: O# f4 |: A8 f. {: k1 b
             catch (Exception ex) // Exception caught here and message displayed to the screen 1 n3 s( V+ E# L% [$ n' g# C
          {# R6 o( \9 t. Y% {' C+ [9 u
                    ex.printStackTrace (System.err);
) A. G$ V* S; |) X3 _9 |           System.out.println ("Error message goes here"); // Replace this error message with your own         
* Q$ i" x- E8 d* a        }
! J! d( J* p, _; e; `# M: ^                return true;
+ H( ^3 ~# x, b+ J! _& [        }8 a- f/ i( }) o, \1 A
. \' q& t4 W# A% m, _
} // end of class ProgramCompare' j$ i: k( a) h9 N( m+ [4 P/ M

  o- `% H1 N" `# B& V8 Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, {0 G+ T& y5 |//  ProgramCompareMenu.java    Provided by: DRS& y* Q3 B" P0 {
//
4 A. d# y) ?* T' k- U) y) ^//  Calls AuthorisedUsers.java and ProgramCompare.java7 `* o# Z8 \& x' w2 C
//: g/ ~' W" l. i4 O" p4 R6 {: a
//  Driver shell for Assignment 2.$ {. c+ g  k% C
//********************************************************************7 @( M9 I4 u, O* o- H

+ V6 M! E& X# e7 }9 Eclass ProgramCompareMenu% G3 [/ H2 ?/ r& R- t
{
2 S+ `9 P: a* H5 W, L    public static void main (String[] args)
+ m7 }7 S" D$ \; z# x            {
! t# H4 J8 F% L+ p  |7 P                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! H) U% O: _* }4 D# R- m1 b1 P
                ProgramCompare reached1 = new ProgramCompare();
1 B0 p( e$ h3 @" ^                AuthorisedUsers reached2 = new AuthorisedUsers();       
. }7 W4 ?0 Z  C/ x: U" S                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 Q& X/ }+ N( \8 L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ! |9 m4 E1 e6 c
        }
; W( z9 e4 S4 y* A2 G6 f0 M& I}// end of class ProgramCompareMenu
0 [: ]2 ~& c/ m" H( z5 d
6 `( j  x. T  V7 {- r: o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; a# y& H9 q8 C4 U, T4 }//          AuthorisedUsers.java          Provided by: DRS
5 R& r1 Z" U! R; B0 w2 f$ H//                3 J7 \1 h: P' [/ p( H! F  J( w
//         Program shell for Assignment 2# ?* ^+ g; O7 H2 ]) \
//6 x, j. W1 w6 }" k. y* [
//         Represents facts about an AuthorisedUser
6 F+ ]1 F+ i0 A. ]& L: u! G3 v//********************************************************************
7 ?- r  x1 Y" d5 R% M# }( k
& d9 q, i6 E0 r/ I1 R$ tpublic class AuthorisedUsers
6 g6 x+ P7 ?0 \! F! M; D    {
+ a: M2 \+ R1 ?/ N: k2 q  Q, R6 U8 R( \" a' v
        //-----------------------------------------------------------------/ ?$ w+ r$ S2 ?9 ^+ h6 n
        // Constructor7 w4 [6 ]0 Q( J  V" P$ Z& F
        //-----------------------------------------------------------------
2 G  m! b9 o6 i. E' d5 D: L" n4 B1 x$ V; a6 }# Q
        public AuthorisedUsers()
& W1 r* E  e1 W5 e4 |7 n                {# Y" K2 O; _4 E% o. M& H4 Z
                }
5 h7 a( u0 W: g+ ~  {& S. ?. t2 z. i' @. v6 F7 l3 C
        //-----------------------------------------------------------------
+ `) L0 G  F* |% e7 I1 f' Z1 f        // Method for testing that class has been reached+ }5 H) q. O/ O: i) K
        //-----------------------------------------------------------------       
" p  z0 D0 a$ }% h        public boolean AuthorisedUsersReached()5 J" m8 B+ k' f$ _! f+ C
                {
- V7 M1 W$ @, s                        return true;                        % I: e; O& y5 ?
                }: _+ ^/ X! W. A; J7 t5 V( r
               
9 e& d+ `  z$ F3 \- H; P3 v    } // end of class AuthorisedUsers- M7 x- B+ S* N6 y  @( y4 w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 e3 V, s6 L# Z  q6 b: x& J( I* MShanghai - 2007
! W: @8 g8 @& e& j+ M8 wAssignment 27 s* ^0 s. J* a2 I8 [4 _* C8 W! C
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)% W4 p& g4 {6 U4 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.1 X# u8 t# r4 q% U
The staff must be able to:
) l+ b& M7 |4 Y4 n( r Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
( q0 f7 v3 |  V6 J9 X1. 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.
# I+ D+ d4 X3 z/ \" G2 ?/ J6 ~ The interface should provide a menu so that the staff can:# ?0 d3 w9 M; N
a) Enter the names of the two Java program files to be compared0 [& w' d. W. O; C
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. P6 t# y- [" P, ]9 c/ M4 Z1 s8 ^  }5 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).
; l, _% \0 `8 q) o! q7 ?+ oBSA104 Business Programming – 2007: Assignment 2
( W& m& c! w4 j) {8 B' a! }$ ?/ [5 LPage 2 of 5' r- c7 z( A1 t. I0 y( i3 T6 E$ z
b) Print out to the screen all the lines of code that are the same
' {% `# \1 l: ~- e Include the name of the file and the line number of the code being printed for each of the two files
9 ?* f* K7 z) M7 u2 Hc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 S  D' w' y4 X
 the name, username and department of the user2 o# l/ J. N2 h  K6 W, I
 the statistics of the comparison
8 D. i/ `9 F: z) T+ `- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' m  k) L/ O7 P0 k  l; |9 \5 \8 e the recommendation for further checking" A9 m' |- h5 A6 W0 b5 n$ 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) V7 W0 r, L% ~. C
 the names of the two files compared) }$ W7 ~5 S' l5 m* |9 j# C: ~
d) Leave the program (exit)
5 O+ n, Z, b' p7 ~1 fThe ProgramCompare class: (Total maximum 20 marks available)
' e# I) n, X7 z4 g5 D6 s, c# o2. 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)( o* z. [% l' ^' Z) l2 J& U& s
a) provide an error message if the files are not found or there is a problem opening them
2 q+ H( _; H' m0 e7 m1 d) jb) compare each line of code  ^# A" P" X2 u8 ], Y
c) print out the lines that are the same  r+ q8 c5 c  k: ?) W: m
d) count the number of lines compared / lines the same
+ j- X5 g6 [3 W# U: W1 EThe AuthorisedUsers class: (Total maximum 20 marks available)
, z% g* i4 V0 j, k1 c. Z3. 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)" @* B+ T) M  J" n! u. w- V
4. Provide methods to:, t5 ]' r$ K  D7 B9 G! i
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 match8 F+ C5 ^$ i9 u* [8 J3 D3 Q
b) return the name of the authorised user
1 U# t* X4 d( a7 `( ^6 \7 O3 Dc) return the name of the department of the authorised user5 L2 p. j; w7 G, C* v& ]# N
Individual Data (Maximum 20 marks available)6 A) Q. u4 o' A5 L+ H$ j, [) l
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.
2 y( E# j8 i9 J! Z9 ]Documentation (Maximum 10 marks available)
, W! @% K- s* S6. 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.4 E  `) C8 G& n/ S9 |) D% {2 n
BSA104 Business Programming – 2007: Assignment 2' m, `  Z, z# c  O: Y0 |
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
" U$ n1 ^" z7 B- C/ E, X6 c不过你要翻JAVA的类库说明。你有下载没有?
# i0 B" A$ W# Y+ b$ i查询关于对比的函数。貌似关键字是contrast,还有compare2 t8 c" V1 H0 Y  C( C/ `/ P& r
. a9 S& E( L7 d. O8 m- l. z; N
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 P4 @" {2 Y) A痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  n. E/ R9 z4 N2 d* \可以下载到的 是 jdk-1_X_0-doc& v) _( l, l) ?% _+ o

6 H: `" [. J; ~% |5 R& j8 h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-13 02:59

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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