找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1472|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 p6 b/ _6 x9 A0 S- r; `3 ? % _- w+ S4 G- z8 H7 g
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************" T% Q. E$ j- M+ t) A$ F, b
//  ProgramCompare.java         Provided by: DRS
8 o0 M* i( b5 {( `" p: i//
; U& P$ p( N/ A) _3 ]; P//  Program shell for Assignment 24 C* D+ e# G4 K7 V; f  C
//. ~; J8 Q  n  ^; {) A) m
//  Compares two text files line by line
$ S$ \7 y% N0 A//*********************************************************************$ y" b( U  V+ M0 {( _" _) T& }
% b4 c) ~. k, W& w1 [- l7 V
import java.io.*;
5 P5 g* b  m2 I" d! _
" G" u4 @; k9 W7 {( }public class ProgramCompare' |: u' t; v3 K) l: S: y3 Y
{) ?+ c4 O! [2 H/ l) H
        //-----------------------------------------------------------------+ \8 P8 Q% m3 A' A% o6 a
        // Constructor
" @+ `9 P0 X* F$ o4 \        //-----------------------------------------------------------------! {* Z! c6 x  J
        public ProgramCompare()+ F6 H5 t3 }; Y4 T
        {" x' M! R: |/ u
        }. N, I  I# j* O( @5 W

' N- V2 p; n2 g% O0 ]+ a        //-----------------------------------------------------------------# w2 x3 n5 E+ a
        // Method for testing that class has been reached
3 M) i8 V& y2 P$ `% i$ v. z+ [        //-----------------------------------------------------------------        ) x7 B! m! c+ L! f0 U. T! [* X

) H, I" O2 K# L) P# r0 R8 x1 v4 V1 ]3 F        public boolean ProgramCompareReached()         % f/ r' s) @' r, D3 B- Y
        {
% e2 E, h! e0 D" s      try
+ v4 l, w4 }5 W) F& x8 b% t$ y9 j   {         9 t! \) i) ^& d( n7 ^, M
                       
5 F1 b9 ~: e: ]) [) A& f& m  M                //********************************************************************, l- ]) p( k- L1 m3 U# G
                // Try-Catch Statement is used to handle exceptions - such as file not found
. t& _2 ~- H  t+ ?# W; z8 O. O                // Reading the files will need to be placed inside a Try-Catch - just like this one!
' D  O1 Y7 h2 V7 z$ U                // For more information see page 534 of the textbook' ?" L4 z: I! g# k
                //********************************************************************
# G2 c% J* \# g! y2 g, x4 ~6 }                    
+ L; ]; l1 C; _) }+ L# z0 \- m6 I) H        }1 a% u" T4 E9 L6 J
             catch (Exception ex) // Exception caught here and message displayed to the screen ' }: N0 \8 [: ~, P. A
          {
  Z5 E: E; k" ?! c% k7 z4 {* u; |                    ex.printStackTrace (System.err);0 t' U3 o7 u1 b0 G* D7 |
           System.out.println ("Error message goes here"); // Replace this error message with your own          1 g% C7 ]+ ]* r% S
        }! N% K) n) B4 I5 W2 S
                return true;+ y: u' F( X# n! a; s
        }, W0 A3 ], q& o! N+ M% w& P
! o4 y' a+ E5 a
} // end of class ProgramCompare* d( n/ E. k0 w) d; W

2 u/ N& I& F/ A0 y1 n. i* C2 t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
! J2 |; \  `" o/ P5 D//  ProgramCompareMenu.java    Provided by: DRS- B! }5 U1 C0 ]# m$ _- Y
//
2 R* J/ i3 O9 t1 |2 y0 w" h6 ~//  Calls AuthorisedUsers.java and ProgramCompare.java
( j" V# f3 W6 K; k7 O/ d% ]( _//; I! @' A8 h1 {* d' y4 C
//  Driver shell for Assignment 2.
( l( c0 h- C( _' g//********************************************************************
+ ~  @, @8 d# |  ~) }0 V, H3 f0 b2 _( W+ F, r
" P+ M, \+ C: x" X# b. hclass ProgramCompareMenu4 D3 u+ ^- D! S4 l4 O
{
  z2 t. y# H5 E% A6 O    public static void main (String[] args)
8 X5 r- F- E' ~& g            {
8 Q+ C) g+ j* I& [- f2 G                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: C& {/ V( ?/ Z: A8 U: Y# I: v
                ProgramCompare reached1 = new ProgramCompare();
, B* ^; P" J) P2 \2 ?! j5 s                AuthorisedUsers reached2 = new AuthorisedUsers();        - D: L9 B  v8 o
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. N! n2 l+ h4 n3 p8 A
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ; A) O2 l9 o& ~( U
        }" R9 `: @- _3 S$ a# A* p$ s  x/ K
}// end of class ProgramCompareMenu6 w& V& @; J: A

4 h) Z9 {9 x! t% D0 O; R) @7 ]6 |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 I9 _. J3 ^0 {$ R1 p& t* m) n: E4 z//          AuthorisedUsers.java          Provided by: DRS
% Z9 f, @: B2 F9 s  p8 Q//                $ p; M* }5 p% \& \3 L' S1 |  s3 Q: `
//         Program shell for Assignment 27 U. }  v4 ^0 ?' H' e  {
//
" t6 D; V5 Z) H" l0 l  x/ J6 a3 a//         Represents facts about an AuthorisedUser
( l6 y! y, u' k& Q% i$ c  e5 w//********************************************************************; e& h0 R+ i/ n9 z$ q7 ^

3 Y$ F9 a9 a/ @: |% j! s0 x3 O' rpublic class AuthorisedUsers
! t. q0 j' z6 Z% w: \    {
! [0 \* ~5 P4 H, ?, B% t- s# F% q8 k( E( E* C- a
        //-----------------------------------------------------------------
! L  F  A% `1 g( E$ N  }2 A        // Constructor3 V6 |; }$ [% w
        //-----------------------------------------------------------------
! Q" ^+ ^9 p7 B; A0 u- A7 ]( Y# ]  M. H+ [6 @
        public AuthorisedUsers()
5 n# H; X, o5 I% q6 Q& N( r  a6 `                {# n2 X5 T2 w" x+ V5 X: D3 S
                }
0 P4 R  R6 `* h' j3 f) P* H; m- L' b% z  d
8 Q2 G9 q" d3 g: P: n  S        //-----------------------------------------------------------------
% ]' ~* v: i% F+ W% ]; A+ i        // Method for testing that class has been reached, {! R! |# Q* @/ c- g& u; x+ z
        //-----------------------------------------------------------------        ' g3 ?: ^+ P' s  z
        public boolean AuthorisedUsersReached()2 T2 x, r) e/ C' w! _* x
                {0 X3 h: t' _8 V9 Z
                        return true;                        ( A: R5 ^# n5 A! D' |# T
                }1 r9 V2 B/ r, m* o5 Q
               
1 z# ]3 J& _: U& ~    } // end of class AuthorisedUsers
; J$ H% n/ f. p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 H* D) p& [: {Shanghai - 20072 M% H4 L6 z( [' |8 P, ^
Assignment 2
" N4 k4 b6 _* w5 U# m( FDeadline 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)
2 g, o6 H% Q) O: w0 o# ^! p4 R  M1. 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.* }; ^# B  N2 g9 d+ o9 k
The staff must be able to:; D1 O; G8 c- Y* g
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  z/ X4 J# s% s5 f) F1. 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.
- @# c, W) j3 Y' h# x8 l2 V# Q6 ? The interface should provide a menu so that the staff can:
: `  m/ p% e' Z4 xa) Enter the names of the two Java program files to be compared* k7 Z- D2 D0 c9 ]7 j" Q4 Q
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' V9 \$ ]' [0 B** 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).+ j! w7 n9 J5 v
BSA104 Business Programming – 2007: Assignment 2
+ Q' ?, S) a3 z; o+ M0 W- APage 2 of 51 p- ]" N. e5 W+ g
b) Print out to the screen all the lines of code that are the same( ^6 \3 s# H- ~7 H
 Include the name of the file and the line number of the code being printed for each of the two files
1 e. r/ d3 @, t- g+ U# xc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, b# M( v' x) _3 d: f
 the name, username and department of the user; L+ Z4 p7 `0 F7 I: H, v( C
 the statistics of the comparison3 r9 _* d9 k- E8 C6 ]5 F  h9 R
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! a) W, I; p2 a5 ]# ~  H# k the recommendation for further checking
$ v3 P9 v* ^: B$ 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
( n8 M7 P& _  n; h, ~  p the names of the two files compared
* _' L  N) M% e$ |5 m- X, F) O$ Vd) Leave the program (exit)1 N4 s9 C% V6 @3 F( S
The ProgramCompare class: (Total maximum 20 marks available)( l8 q' W! R) P" t3 L
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)
4 F$ M/ j8 Z: ta) provide an error message if the files are not found or there is a problem opening them
9 I) [2 t) s% E: c$ j1 ]  F6 }b) compare each line of code
# ]/ c2 r$ ]- J; d  |7 nc) print out the lines that are the same" u) u+ R4 C, _- K. w9 Z
d) count the number of lines compared / lines the same
# D  X, Z! F8 A* n( Z5 _The AuthorisedUsers class: (Total maximum 20 marks available)9 u  r# e, L8 W$ O
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)7 X3 u4 ~; V" z; G
4. Provide methods to:
* }: |" ^( ^+ n6 Y, Ua) 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
. x( ~* R# K* X0 b1 _# Tb) return the name of the authorised user0 i+ P; w; \" A) q6 o
c) return the name of the department of the authorised user; _/ H& |" e7 `$ G5 P. a
Individual Data (Maximum 20 marks available)$ H9 j* z2 D. ~% Y! M
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.
- i5 {1 M: j5 V5 ^Documentation (Maximum 10 marks available)! Y) u3 b3 S2 x% E- r, S
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- P  i# s/ u( A4 c5 CBSA104 Business Programming – 2007: Assignment 25 D( S3 `0 `% ~! f* V6 z8 S+ R4 k
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ a3 w& z3 i: J1 K  ~  I不过你要翻JAVA的类库说明。你有下载没有?; K" B: N2 ?0 P* ?
查询关于对比的函数。貌似关键字是contrast,还有compare  |+ i9 f& o- {7 P& k

2 L  C  q- X* e' c* s- J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( D, z& B- s% O' c/ j/ _9 ^痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
6 l0 {, ^. B7 E( V9 ]可以下载到的 是 jdk-1_X_0-doc. e+ z/ u# h, t$ }2 Y) X
7 \" y+ {% ~* Y3 r+ o# I$ D" J
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-21 20:30

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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