找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1059|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! O3 ^, u9 t6 Y2 {* k/ W P: a n+ I- 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 | 显示全部楼层
//*********************************************************************$ O/ ]/ ?3 x+ s9 q' ]
//  ProgramCompare.java         Provided by: DRS
8 E8 z& D/ K. V//
& R8 m9 z4 b' \; C. F& L  w4 V1 U//  Program shell for Assignment 2: p( }. a! {5 |" w, F: L: `! s
//4 `7 H  q6 K8 K1 j6 I7 t: S
//  Compares two text files line by line
9 {; v* y9 O& _' X0 s: k- {7 P* a//*********************************************************************! R/ }( j2 G" ]1 O

3 T" B0 W+ d4 h/ a( kimport java.io.*;
2 d% h+ k) J3 w5 I! z* r4 g! M
. ^! D) z9 }( |) o$ Kpublic class ProgramCompare8 W& [" P2 K: \, G1 T
{
4 `& e6 W* ?6 e. m$ Z6 q  d: I        //-----------------------------------------------------------------
$ Q  \$ h: ~+ y3 w) Z4 c        // Constructor/ f$ I- E! ?9 O& v# A  k: ?
        //-----------------------------------------------------------------
5 c4 ^+ i3 L1 w& k& G  M1 \        public ProgramCompare()8 U+ l' |1 w" y/ `, L, m( M
        {
( t* o0 Q9 _# l8 F  u$ e        }: f; ~% V* R8 B* A' |
9 p) ~8 x- e) m/ r% K, D& p
        //-----------------------------------------------------------------
9 s3 s" N$ M' A' E+ C        // Method for testing that class has been reached/ s1 Y8 K  m# p3 O4 o; A
        //-----------------------------------------------------------------        : q% F3 Q: b' @2 d/ {
' g( r7 v' D! c4 A8 t! V: Z0 X
        public boolean ProgramCompareReached()        
, a0 V( T/ ~6 I6 ^; ~        {
% e0 F0 T) v& f; L% j      try
* N$ [# V3 E, k/ f+ I8 x) s6 d   {        
( n. F  W' @& f8 w0 |2 R/ w5 M                        % ^0 u0 w' Z  u( ~& i
                //********************************************************************7 I  A* [8 f6 y4 `
                // Try-Catch Statement is used to handle exceptions - such as file not found
0 C) _; E5 M# ]* a8 p$ b& ]                // Reading the files will need to be placed inside a Try-Catch - just like this one!; y5 k1 q% H  X1 V% ]# `
                // For more information see page 534 of the textbook
8 U! e" I7 F3 v! g, s( V5 t7 u                //********************************************************************/ b5 {& a( J$ W& P" a
                    
! q! K6 V4 Y4 d8 K0 Y        }( @) a8 R" ~  v* C
             catch (Exception ex) // Exception caught here and message displayed to the screen
6 e1 q4 g0 c; ]          {
- P6 M2 o: ]  q& h5 N                    ex.printStackTrace (System.err);3 ^0 |& G6 c' C2 \' b
           System.out.println ("Error message goes here"); // Replace this error message with your own          2 a8 l7 {) m, Y: a
        }0 P. d; c! d. N/ F/ w
                return true;3 k/ j+ g; H2 d6 y# U  r
        }) a0 ^+ ^2 s# p2 ^# @4 L: {' q. J

/ x$ [( S! q& J  `} // end of class ProgramCompare
7 D7 ]7 @+ `  h1 v9 x
5 U5 S2 v7 x; ]. y( Z1 ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 C  i$ Z. H, X- z' M8 v
//  ProgramCompareMenu.java    Provided by: DRS1 }% D% C" b1 s2 |+ @
//' o$ S& ?; R; q& n2 [
//  Calls AuthorisedUsers.java and ProgramCompare.java
0 b: Q( e- d: j7 C! j+ N//! w5 @' h* Z" N2 z1 X) Z' o
//  Driver shell for Assignment 2.$ L) e0 k  n! R
//********************************************************************4 p: R6 Y& ]6 v$ B( M# e

3 ]; R3 |# M9 C: zclass ProgramCompareMenu. B3 d. n5 W" m, h' C; Z3 B3 o
{
" y# q# s, P0 @( n* c7 x% g    public static void main (String[] args)
2 H3 Z0 @( p5 K* ?            {
. F0 M- _2 k* q# J                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable. d" D" F% m7 P* N2 F6 f* Q6 V
                ProgramCompare reached1 = new ProgramCompare();
9 Y2 W7 _4 p0 N" x) l3 L+ @                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ L0 q* U* L& n, n                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
: @' W. n% E9 l" E' O8 ~( X                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 k2 K8 G) {8 D$ ]$ A        }3 V" |+ G9 B$ y. [- W
}// end of class ProgramCompareMenu
/ ^# }6 p- `7 \
/ a" [0 Q" @* @/ N$ Z0 A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# E( u( o4 H" a+ x//          AuthorisedUsers.java          Provided by: DRS1 D0 ?9 k4 D( D5 T# V1 g& D
//                * h5 C5 R7 |" g" D& t# A# u* D
//         Program shell for Assignment 2
  R6 E8 N. U$ H  @, U  j  {//
. X9 X- R/ e* C5 C//         Represents facts about an AuthorisedUser
- ?' @8 C" G1 F1 E+ F6 n  t& J//********************************************************************
- @9 }" }1 A2 \& B% _$ S
- @& g; }. b0 F$ ^! zpublic class AuthorisedUsers
+ S$ M: ^2 D3 |2 r    {# _1 t4 {; H" h" e! n6 s' E. a8 c

2 r! c' F) e/ `3 V; \        //-----------------------------------------------------------------: \7 ^; T. ]2 ?. Z+ H9 {" E4 D
        // Constructor0 {' _' p1 _  i
        //-----------------------------------------------------------------/ L2 V$ ^, T- O' v( J5 M$ k
9 h- h0 |$ `: P4 Y5 P' z. B3 }
        public AuthorisedUsers()
/ b* e( f! |* B- {                {/ e) I1 q) O, @) E: X
                }: c3 G3 g' f. V! |. N% v% }9 V
$ A1 [2 m4 _# S0 F. @& P
        //-----------------------------------------------------------------
/ O' T2 ?4 M1 k3 {        // Method for testing that class has been reached
$ H% U8 S, F* |7 n1 l' z+ ?        //-----------------------------------------------------------------        $ f- B, z5 V3 l9 p/ z
        public boolean AuthorisedUsersReached()! E' l: z( G% ^! n6 p5 \
                {
/ }1 Y0 y4 A# ^$ `: f. x5 \                        return true;                          U1 Q/ }/ j) w2 H' \# v$ a
                }
, r: }- \+ _9 N8 _! |& j                ! _6 ~  r! M8 M4 j7 s, P
    } // end of class AuthorisedUsers
- t5 M, }/ q* T/ ^4 Q8 w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, k) A" H+ G4 s. y! I
Shanghai - 2007
4 i4 A1 O5 z6 GAssignment 2! N& |2 |- u; L* M
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)
& ?/ @: p) g) G* h% U: f: 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.
% Q/ x6 H+ b0 S# RThe staff must be able to:: G7 `! i: ]2 q3 Z% q% a
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
/ Z8 s' R$ I7 S) W) J1. 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.3 l3 J1 g3 i( W8 |" j
 The interface should provide a menu so that the staff can:
  P1 T; W! R0 H7 O# x# `& \( O+ Ya) Enter the names of the two Java program files to be compared
! e" m8 f' J! h6 A" r' B For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
  R/ S5 _% N& z9 ]" @** 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).
  ^( Z% E3 i, \  I3 C6 iBSA104 Business Programming – 2007: Assignment 2- ]  C( Y  ?& R" @# ^. J
Page 2 of 5
2 U' ~6 S, C+ Z  E( w3 Kb) Print out to the screen all the lines of code that are the same
. ^6 B* a# \) k. l- [2 P Include the name of the file and the line number of the code being printed for each of the two files
2 y& v) b& Z" ?; m/ ^* E9 ?# A0 Jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& A% v! L" F; J% C6 d  v! S
 the name, username and department of the user
5 n8 ~6 T0 z. a7 ?3 D$ j the statistics of the comparison& s! O- x, s  c# E' F2 Q
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: J7 Z4 W8 D! J$ k
 the recommendation for further checking
6 g8 u: Y2 p: l* P0 N- V2 j) X- 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
% T4 e0 W5 L8 s, q the names of the two files compared: i! L4 R& U7 M& `+ j7 E0 N
d) Leave the program (exit)
  c% g/ O9 V6 G' L% OThe ProgramCompare class: (Total maximum 20 marks available)" r+ o* `" J1 p1 b, K
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)! k  m! I& `/ ]2 e% p( \
a) provide an error message if the files are not found or there is a problem opening them
& S& V: N" m/ ab) compare each line of code' Y) T/ [) }* D6 E  W9 ~4 e
c) print out the lines that are the same
: u3 j1 z2 y$ G5 d5 [6 M$ ed) count the number of lines compared / lines the same  a2 I) A, F4 q+ c& G8 N
The AuthorisedUsers class: (Total maximum 20 marks available)' l4 G, n8 A& a$ V0 e; G; X- P( X
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)% t: o2 l1 B4 u4 `  [' x  ]( i
4. Provide methods to:
+ d) p) O0 M( W/ a  }7 w# A& ka) 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
1 Y( `6 M$ K2 Q1 wb) return the name of the authorised user9 g3 J# n) k' ]; e9 r
c) return the name of the department of the authorised user1 m) L- T( L" Y% P1 O
Individual Data (Maximum 20 marks available)
% v/ C* }3 N0 q$ o5. 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.3 q+ ~: A5 K2 n6 Y# S' a& ]* g4 S- l
Documentation (Maximum 10 marks available)
' f& r1 W% U$ z6. 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.
/ T4 X6 @8 h4 }" Y: p3 hBSA104 Business Programming – 2007: Assignment 21 L7 z6 X3 J2 f; O  a. k5 h4 p5 S
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 _9 U- K8 c: r2 G9 R' r  J& d
不过你要翻JAVA的类库说明。你有下载没有?" [- F: C- v, n& @
查询关于对比的函数。貌似关键字是contrast,还有compare
* f# \% z  d6 B0 M$ S) C: d7 L' U/ B0 d6 d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 I: Z* M: I$ d# U0 @5 j痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& t  X  V" `3 j% L4 j: T可以下载到的 是 jdk-1_X_0-doc$ I5 a: T2 @( A

% _" j: c! Z- |) @2 X! Q9 o[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-16 07:24

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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