找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1537|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 \/ z5 s- _5 Z% w, X3 @! i' u. Q+ u5 S1 r: s0 h/ Z& X
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 v5 ]2 H0 u$ z. v
//  ProgramCompare.java         Provided by: DRS
: ]$ s4 ^( z; a5 d: O$ {5 s! D# e//
: C  f7 k* [/ j$ k0 ~$ `0 ]' U! b//  Program shell for Assignment 2
" r3 N& {; X0 \5 n0 N( l//  Y5 s( x! W7 z. R/ r% _; S
//  Compares two text files line by line& H4 Z- k* r9 L6 M
//*********************************************************************3 j, j5 j" M+ E: {% v
) l! M5 ]' N0 T; W+ ?& t
import java.io.*;- I/ ^4 @/ f1 Y3 K  N. A

% s# l1 ^# W9 ]* A  T# i! L/ fpublic class ProgramCompare+ ]) x8 l8 j* ]6 n1 G
{
% |0 w1 a# v- E1 B        //-----------------------------------------------------------------
5 o8 G. d; ?, g! Q8 O        // Constructor& i4 E2 L2 T, Q6 y1 s! C
        //-----------------------------------------------------------------* c" x- |4 Z7 E/ D
        public ProgramCompare()0 Q. ~( U- z) _& f: @! U4 [0 u
        {! i- \, i' A0 s" D  G$ ^
        }  [% m. X; d7 u( _6 @# m

1 h8 Z/ o1 B$ [) M( A) P( Y        //-----------------------------------------------------------------1 Y- l5 f. v& z& H, r
        // Method for testing that class has been reached, W. E5 J# Z  `3 w" w9 @
        //-----------------------------------------------------------------       
7 O( G7 `- H: z# v9 E" O4 F: r
+ M* q4 k2 @# F: ?        public boolean ProgramCompareReached()         $ r9 u9 m2 `  P( _; q$ O) W
        {' D6 W! g" {6 W
      try - e4 v+ i) D) x; L  H- G( j0 I, y9 @6 n
   {        
. C% |; w1 L, J0 Y  J! V( N+ }                          u% Y5 p# k; k$ J" e9 b( w
                //********************************************************************$ _  }9 `+ q3 t" w5 |. W! i
                // Try-Catch Statement is used to handle exceptions - such as file not found , m( n( Z8 H1 _, P
                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 o! m5 X7 o: y' H, [; |- e7 b
                // For more information see page 534 of the textbook5 \$ _; `1 q5 j; m' n- |
                //********************************************************************
( ]4 S3 D& y& K                    
* s  @: q9 t. f( c, J        }$ |) O" t; @3 _  e- v8 t" c
             catch (Exception ex) // Exception caught here and message displayed to the screen 3 M. x5 }) n# T; e9 w
          {/ b" }$ j3 s! G7 n+ Z+ c  }
                    ex.printStackTrace (System.err);
8 q" T& b: @% [% t           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ A3 b9 r& p! G% u        }9 |; |! f- O: Q2 |
                return true;+ Y# M. b: O" t5 D
        }4 b9 o; R% n& X" O4 v. _% d
4 k8 r1 k& Z6 @7 x% v0 Z
} // end of class ProgramCompare
" ^) o/ P+ i( S; D
0 u( H8 {' ]3 v6 E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 x5 |4 e" A8 T% z8 T  w//  ProgramCompareMenu.java    Provided by: DRS
/ x- e7 B) b3 F6 K; e//: v) G, O2 M# }) h$ u0 B: u
//  Calls AuthorisedUsers.java and ProgramCompare.java
# a4 [5 |4 t# R//9 {# K3 Y* B$ ]4 I7 \" z1 S
//  Driver shell for Assignment 2.
3 Q* |: W0 \5 A//********************************************************************& r' A  n* M$ Y( m6 S) K( W) m, @

# ?+ a& H0 L' N/ v5 dclass ProgramCompareMenu6 r  W0 D! M7 w$ X" z
{
/ u: ~) w6 W- I$ ^0 h    public static void main (String[] args)/ E- b  Z. {! o2 Q% W" N$ P
            {# S* R7 l4 h4 ?9 G/ x
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 }& s3 v% L" p  c1 t8 G; q: C                ProgramCompare reached1 = new ProgramCompare();
) N+ T4 T  P7 c- }! P                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ m# T: q0 u$ s+ l' L1 n. ~& [' q2 t                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
- P3 u) o/ m# @. J# N                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 H8 \1 @+ h5 n9 w6 Q' v7 k        }
% P* o8 k# V# F/ T- b}// end of class ProgramCompareMenu& v9 H  }' L" k
# a7 B) `  Z8 |
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************: |1 Z% R% |6 W) u/ }1 M. X
//          AuthorisedUsers.java          Provided by: DRS! N* O7 }9 M2 c- v# w3 s  e
//               
& P6 L  V1 v$ W3 b8 U* ^  k, M' J9 G  Q//         Program shell for Assignment 2- B$ i7 h3 m% M+ G
//8 Y+ Z4 ~) C+ d" c. g$ D
//         Represents facts about an AuthorisedUser( g( Y/ I. X% W8 J7 D
//********************************************************************
+ t6 f# z/ e0 V5 P0 r4 f& ?
' ~$ L  y* ^! Y" X/ f% r0 d6 P% Ipublic class AuthorisedUsers
+ d( g2 y/ I# A: m1 O3 D& B    {
2 G1 B' ^( N2 e7 {8 j) W2 p/ T+ B1 ^
        //-----------------------------------------------------------------
: r/ X) R8 j. I2 I! f        // Constructor
: P; ]: _& F( T# m        //-----------------------------------------------------------------; ?* G: \9 k1 D

! x  g! x: t' }3 k7 n        public AuthorisedUsers(). F# j' E% ^- ~: `* {
                {" K5 [9 f1 f" K6 p* {
                }
9 X5 f: Z) R9 t) S' r( |3 G- F
- \& K' I6 P7 n* s7 `; X7 D) U        //-----------------------------------------------------------------, l& O& Y8 G0 s0 ~
        // Method for testing that class has been reached# ~& q( n! ^* Q5 J& z8 w$ N/ P
        //-----------------------------------------------------------------        1 h% m1 W. N3 V+ X
        public boolean AuthorisedUsersReached()" ~' d, b9 `) P9 o$ _
                {( C8 I( K/ K2 A% v  \; C
                        return true;                        " }* A0 ^" g7 l6 x  S
                }
2 R" c/ \9 Z  C" G7 ^% q( D               
  f7 r3 q; L+ i3 ?    } // end of class AuthorisedUsers( r3 W& W% {! Z' ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 p9 Z. r7 R8 Q, f
Shanghai - 20074 f& r" j1 \& ?, ^
Assignment 2# B* n! m. @, e0 K
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)
( C0 l( @3 Y5 ~) }, H. t1. 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.
* A2 h* h; \" YThe staff must be able to:4 K$ T7 K" g) S
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.8 B4 M" @9 V8 E) U
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.$ D( G' w, e1 S6 i3 e
 The interface should provide a menu so that the staff can:& Y1 J! w3 f" V4 g6 S9 A# J. w
a) Enter the names of the two Java program files to be compared
! r9 g' P+ J6 s+ m  _ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 V0 a) n) e# ]. c
** 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).
; v, X5 }  S! `( ~3 @; ~BSA104 Business Programming – 2007: Assignment 2
1 B5 i7 u5 A% @3 FPage 2 of 5
! B3 A9 f0 R! c, O. O+ ~b) Print out to the screen all the lines of code that are the same
9 ~( y( {8 e1 ?/ S* v' i# |% m Include the name of the file and the line number of the code being printed for each of the two files
6 M6 j  o2 \, kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared' f; J/ B  Q; ?" n3 x; k
 the name, username and department of the user( [( y  `) Y3 T! r- j4 d
 the statistics of the comparison- Q$ w4 V7 P$ t5 X& |
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, i  A2 j8 L) D) T8 l8 v9 p' e
 the recommendation for further checking5 X1 Q& J( C/ q+ E- r
- 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
) W' k* P. Z$ y the names of the two files compared
1 w2 A2 G# O( Q+ M* V7 f) ^. e8 D( |d) Leave the program (exit)
, R; E9 x( L/ s/ B; B% V  mThe ProgramCompare class: (Total maximum 20 marks available)
- M# Q' h- o5 I: }! x2. 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). `) Z  B/ l0 f. W' A0 @
a) provide an error message if the files are not found or there is a problem opening them8 [$ ]) A$ j% h% {
b) compare each line of code  Z$ e8 s/ ~5 _# r  C
c) print out the lines that are the same
" l/ V; K! s/ ?9 ?$ n4 O$ V7 Q) R& id) count the number of lines compared / lines the same
) s. \& y" i4 R7 S" FThe AuthorisedUsers class: (Total maximum 20 marks available)/ ~1 L8 R6 e0 P5 H( R
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)( j# e7 v& v' j
4. Provide methods to:6 O) J( f$ C6 n- S
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
$ n. y6 J& {. k0 S! O$ i/ b0 Hb) return the name of the authorised user/ m" H  x- x9 x! d. [& E. B* K
c) return the name of the department of the authorised user! B( e& C0 D' J$ l5 {! n) t( o" [
Individual Data (Maximum 20 marks available)/ e0 \$ ?7 U( y! D
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.5 h' g0 J7 |3 ?/ I& m: M, t! n
Documentation (Maximum 10 marks available)& {3 C& X" Q7 u8 u( u8 s! j& Z
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.
. w* o7 V( j0 w7 CBSA104 Business Programming – 2007: Assignment 2
0 M0 X9 g9 p! A0 \Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ M. ^7 a( H4 X3 ?0 Z不过你要翻JAVA的类库说明。你有下载没有?
  L* e! F& k3 L8 m+ l% |1 S查询关于对比的函数。貌似关键字是contrast,还有compare
# }6 S7 n' r2 r$ l5 |) V6 O+ t# g& T) ^1 D9 y" q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 e0 B) ?/ P& T" }' z# [( j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 Z* ]+ Y0 H+ L, X- Z5 p3 [; }
可以下载到的 是 jdk-1_X_0-doc
& t% l& y% `. x+ O/ L* L2 G
2 ^7 |1 s% I/ ]+ m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-12 09:28

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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