找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1842|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" u* t& j/ n0 p" U+ g) [$ B + A. f I8 g( `/ ?. O& u) b
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************, @- Y, o& T3 n# N
//  ProgramCompare.java         Provided by: DRS
- h+ \9 Y* `0 \' X" ^' Q7 q+ m' A//
$ X$ K  f6 P5 J! }+ x( N//  Program shell for Assignment 2* c' o# h8 ^! D5 c# ]
//5 j! g* ]0 r" }" Q" I
//  Compares two text files line by line
' q- [0 t$ Q: b) e7 X' m//*********************************************************************6 M! e1 C+ D3 D7 W3 \; _+ M, b
! g* v4 t4 I. K5 X0 D# @9 {7 P- V+ @
import java.io.*;
$ M: ]# N7 F# S& d) M5 c. _) q
  h7 q0 ?9 B5 t/ x; w2 }public class ProgramCompare- @: H) ~, ~: g& y
{
& O) \% }( e# g        //-----------------------------------------------------------------
" X* X8 V, \$ h6 {  e, u+ B' }6 {        // Constructor
" k5 @: X. Y4 F' Y. S7 x! M7 f        //-----------------------------------------------------------------
' y6 J( B$ c8 D9 l  @        public ProgramCompare()/ A2 A& m. K/ p7 d- A( K+ y& y
        {3 q" d6 Z. O# X  m
        }, t3 y/ x* U$ f* T

" H8 H4 M! \9 s! v# s4 I        //-----------------------------------------------------------------
- I0 i8 j% u) G8 Y! `2 g+ S        // Method for testing that class has been reached% n; \  ?* i5 D& ^( j
        //-----------------------------------------------------------------        $ q: ^4 @- }/ y
0 U7 q! V3 A! B0 g+ P( P
        public boolean ProgramCompareReached()         ) C2 s1 I8 \4 V1 E8 J- _4 F  b% \
        {" `/ y( @" c& a5 @, W. q0 R& P/ q
      try 8 O) C: X6 [0 V% I8 I
   {         ; o2 c* R: P5 H) _+ f
                        / R* u. k; b8 U
                //********************************************************************
8 ~" M  D  f# `3 b: i1 V' Y  p                // Try-Catch Statement is used to handle exceptions - such as file not found + t  b2 f  r0 v* B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 U5 t0 ]( C8 h7 e: b
                // For more information see page 534 of the textbook
# I6 Y) a9 D6 q1 C                //********************************************************************3 W& r" ]$ S+ }: P+ z
                    
7 p7 v; q, X3 K) Q4 q+ H        }+ O5 [3 I' b1 z8 I
             catch (Exception ex) // Exception caught here and message displayed to the screen ; p1 V$ _% @9 M
          {
6 u+ p% E( Y* S% N                    ex.printStackTrace (System.err);
3 X0 U  a# G3 W) S6 v) y( i& P           System.out.println ("Error message goes here"); // Replace this error message with your own         
( P$ M+ m  {' B$ {, A: V" ~9 Y" l        }8 _2 i3 o- ~; x  n; @& w
                return true;
1 n' k# n6 u! g+ f# H        }
. S: y. L9 `1 |2 k) q  P$ U7 _
/ F$ e7 e) F0 N% _4 Y, B} // end of class ProgramCompare
0 U' _' N! B8 `! `: l/ }
# k- h& s  {  s7 E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ h7 s+ `+ A7 h0 f; ^* @//  ProgramCompareMenu.java    Provided by: DRS
- t: Q* C, X- W' Y8 j//  B; G: H& |& x, L" }
//  Calls AuthorisedUsers.java and ProgramCompare.java
0 K1 |" U  P( p1 n" D//8 W+ ~1 j$ ?) J) a& R
//  Driver shell for Assignment 2.( t+ L  p) E8 s* Q
//********************************************************************" K; x. P5 G$ @6 i1 K5 g( G

* ~6 n: D' r* h5 M, h( Jclass ProgramCompareMenu
- p9 b% D) B3 k/ z6 W0 Y{
- X4 @) m* C6 s$ b& a    public static void main (String[] args)
2 j/ _( b7 B3 u* I: k. V            {
) O% M% f1 R3 J1 P& p4 j                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable/ v8 H: l% _% B) S0 V( r& l
                ProgramCompare reached1 = new ProgramCompare();
% _% T, g3 x7 v) n                AuthorisedUsers reached2 = new AuthorisedUsers();        5 a8 r  d: T+ t" p: o+ F( t0 |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, ]0 z+ @! N. ^) q$ \- |                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + d) r( `' Y6 j; a5 B5 ]: |2 [
        }
9 z. O* G  d7 z. ?- k3 m+ @}// end of class ProgramCompareMenu
: \( h+ q+ q' V: o7 s& ]% z6 {+ [6 _% B$ u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) e: Q. r0 Q, R$ o, P
//          AuthorisedUsers.java          Provided by: DRS6 {, G$ l) K0 j7 J1 F& E1 p3 K9 x. M7 F
//               
1 s! N) H: T4 l7 v& H9 s$ Z4 G//         Program shell for Assignment 2# P% [; o  v' z$ b: @/ O
//! B, O" ~. H' x* A  |
//         Represents facts about an AuthorisedUser1 N0 `/ a) `+ O* z5 t8 ]
//********************************************************************
7 k% ]: f8 X! |" N# i# B% M+ m
5 Q- s& G( P& T3 Ppublic class AuthorisedUsers
! e; k9 \" n+ a9 k0 L1 o! C! q    {+ n" U: l" o/ Y9 z, Z

8 @) o* B: ]: k3 M* W9 x! j: y        //-----------------------------------------------------------------
1 c9 S* P- _& p$ n' F4 R        // Constructor& ~% u9 v; @4 P; j( C9 s) {& p: T
        //-----------------------------------------------------------------8 i6 n/ {7 ?* R- I/ a8 h5 o
0 s) }: Y- t0 k- |( _
        public AuthorisedUsers()
1 S9 u4 t0 T2 [, c6 J                {; A  E/ m# T5 p) ?$ |4 |$ e; \  b
                }; w7 d" `5 C/ {' O0 z" m- |

. n6 `' H, G" I        //-----------------------------------------------------------------
( d. P% V& E9 A8 c/ E0 o        // Method for testing that class has been reached2 _3 E2 q  c, ]( |1 x6 N
        //-----------------------------------------------------------------       
+ J" ?3 p; f  o2 b4 d2 y        public boolean AuthorisedUsersReached()
2 D4 }$ Q# p9 S, ~4 W                {& h. r6 V1 O5 w' t3 z% P) I
                        return true;                        ( K9 K8 w+ m; P5 c$ }4 F$ g* T$ N
                }1 a4 ^. V6 k4 y. {
                ; t. M; R5 ]/ S9 J  O
    } // end of class AuthorisedUsers% l( D9 R+ K/ y1 T4 M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 k' ?# y/ G: q: h# o6 W
Shanghai - 20079 n9 |( z& |4 r3 P9 [; C
Assignment 2
: V. `7 ^! ^$ T% Y, S' G7 rDeadline 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; R' z0 {! V# b& J  R
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.
0 R) g, \4 ]3 f" q. R3 Z% v1 M' HThe staff must be able to:
$ p4 S' s+ L- `" |8 k3 `- b$ _ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* w1 v6 o! K1 z5 b$ Q; e4 _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.! e$ a% C+ w, d- ^' s" P% ]) Y
 The interface should provide a menu so that the staff can:( B; R  w6 z$ ?3 A5 m/ |% U* E
a) Enter the names of the two Java program files to be compared
/ q4 f1 Q, i& Q8 J4 d4 b, A! z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ U$ I3 i* Y9 T' @** 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).
' v6 p/ ?4 K5 \/ A" ]3 E3 fBSA104 Business Programming – 2007: Assignment 24 J$ J7 M" f0 ?: A' g7 k$ }7 a
Page 2 of 53 N, N. W  J8 V2 `- S
b) Print out to the screen all the lines of code that are the same
3 j2 Q" q. Y2 m1 t" H/ F Include the name of the file and the line number of the code being printed for each of the two files
3 P# n- m1 L+ A2 l3 ]; y+ m  kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared+ k  o( U8 L! ~4 H9 @: h
 the name, username and department of the user  P- {+ p; i7 P  W$ L! p, k8 r
 the statistics of the comparison( h4 K$ h3 f3 W3 {
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! A4 c- J. f& K/ L
 the recommendation for further checking% ?. A  g( e; m3 b
- 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
8 M) _2 `7 r  I  E the names of the two files compared& T5 X7 N6 P4 b: S" c
d) Leave the program (exit)7 Q! ]) l# j. j9 W0 F! U' d
The ProgramCompare class: (Total maximum 20 marks available)9 E! l8 [" ?- D$ T4 _) }
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)) x0 R4 I, e6 q$ D2 e
a) provide an error message if the files are not found or there is a problem opening them
" i+ I8 I# \1 g6 }' r6 H8 pb) compare each line of code' A0 e0 k! |# a, ?9 a4 P
c) print out the lines that are the same! c/ B/ A7 F1 l8 F2 ?& P
d) count the number of lines compared / lines the same
) t: o, k0 w8 Z3 t6 @- Z1 v  lThe AuthorisedUsers class: (Total maximum 20 marks available)
! n+ O4 d8 R" K; u3. 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)! {; P' U, P4 w2 D& T
4. Provide methods to:; y. [0 g" G& b9 u# z
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 z  \/ V4 E
b) return the name of the authorised user# M7 M& a: s# L9 J" K
c) return the name of the department of the authorised user7 C5 z6 }9 j7 D/ Q0 P4 _
Individual Data (Maximum 20 marks available)
, K5 G) @! 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.: j, o8 G/ O, r. h# G( y
Documentation (Maximum 10 marks available)' x7 `" N5 y/ o! y) v1 o
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.
) O$ W! A8 f. a% d3 i# `BSA104 Business Programming – 2007: Assignment 2
( f& \- l; y% a$ q- ?Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. J! w- |$ N- e( E3 j不过你要翻JAVA的类库说明。你有下载没有?
3 i/ J" d! M$ ]  I/ C! J查询关于对比的函数。貌似关键字是contrast,还有compare
* N0 Z( V! m! t* \/ d% B9 V9 z$ J/ q. m& [. x  P
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; N! u, T4 e& x7 _4 ]痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. ^. A4 R  ^  Q可以下载到的 是 jdk-1_X_0-doc. Z- N( F( c9 O3 f; k

/ s' e! h: b) d( {, S. c[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-18 13:54

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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