找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1877|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / a1 o b' l* I* `1 p, C9 K 1 q& J% D3 `. ~( t
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************$ [/ R0 X8 s: g8 l! u6 Z
//  ProgramCompare.java         Provided by: DRS0 r+ _8 e& a  K5 W0 e
//7 w! F/ o3 D9 }# {* H6 _
//  Program shell for Assignment 2# ^- F* x6 J& p" R
//
  f& K2 A% O/ ?' C+ k# \+ a//  Compares two text files line by line8 U! J& |& G; t  b
//*********************************************************************
, B. j" O+ z+ {) s' I8 Y  E
& a2 {/ D! s8 t$ Wimport java.io.*;# x2 l# w* Q" I. w  `. ]& C

' V! v( T$ q0 Y/ {public class ProgramCompare( [4 l  z) w6 e. B' L8 l7 P& t  e
{% p% B; D4 h: q. P
        //-----------------------------------------------------------------$ F6 ]. j/ }. N
        // Constructor' l) }7 b1 R5 x
        //-----------------------------------------------------------------
9 l* z6 L1 K! h4 l' m9 c" w; b        public ProgramCompare()  u. @9 r+ Y9 w/ m
        {4 H7 ~6 _, H9 R" ~( j( g" X) E- |: e; V
        }0 r+ i( ^2 l, v# y; z

3 M1 E( T% M2 v5 W( [        //-----------------------------------------------------------------
, T+ t0 T# g3 P( M2 H1 d        // Method for testing that class has been reached
, G% n6 r% o' j; t- t9 a        //-----------------------------------------------------------------       
9 M4 l/ C8 e3 N; C
$ Z' S' |7 z/ u% X- o        public boolean ProgramCompareReached()        
' G  a9 Z; t. m* [        {, ]$ d  R+ ^  [* H5 {5 X1 A6 J
      try
+ b  H8 c  B! j% q% S2 m   {        
" f. ~& }) U: h# j; u9 Y" L                       
+ S8 ~- d1 K$ Z6 w                //********************************************************************
0 B4 `1 }5 t$ M% J  e9 ]" Y9 i. n                // Try-Catch Statement is used to handle exceptions - such as file not found 7 s& X# Z- K" R/ n0 U5 Y: o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- P7 q" y% o0 R
                // For more information see page 534 of the textbook
# o% ?- u& e2 E! X7 s; w5 h2 @: ]                //********************************************************************
$ a% h1 S: G+ _% n" {6 b                     3 |8 t+ K( Q* f4 B4 q2 g; B
        }6 s) x# O+ q* z1 a) c" Y# y" h; M
             catch (Exception ex) // Exception caught here and message displayed to the screen
+ A% P+ Z  S9 n1 }( _! [3 s# t          {
; e2 j; Q1 A7 q+ V                    ex.printStackTrace (System.err);- c: K. |6 }1 w
           System.out.println ("Error message goes here"); // Replace this error message with your own          / w5 d8 o+ ~% @/ ]1 b0 q0 T/ a
        }' ]2 J6 T; d1 y" L( M" l8 `! D
                return true;. b1 A7 Q9 w: J2 i& ]
        }1 S# O4 u1 e- {  `. c0 h' f& N
% C9 F8 t4 G; c# t& }
} // end of class ProgramCompare1 t. Y9 c" s1 X1 P* Q

1 s( |4 U5 e. P" H. l" g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* V' {0 Z6 m  v3 @  t' U//  ProgramCompareMenu.java    Provided by: DRS/ U& |6 Z9 ^+ K& V& a- e$ D# G' N
//3 z, {( X& X) W8 d6 f* X7 v9 }! t
//  Calls AuthorisedUsers.java and ProgramCompare.java" C' i/ i( b( B( y
//
+ `: F' M  Y2 b, _  X% k2 w//  Driver shell for Assignment 2.3 U4 g% Z" G8 w, h0 m; G. C1 S& u
//********************************************************************
0 E$ V! e3 z4 D- x) q  ?3 M, R' V/ |' ~) L5 {, M! e1 _3 q" J( n
class ProgramCompareMenu: Z, }0 v) o" `- S& x1 }2 Q6 n
{
+ n* }6 Q* m! {+ n5 }    public static void main (String[] args)
2 v4 l. U5 w+ g) @6 v/ N" |- i/ l& x            {9 P/ E& g) E! ^; F, H+ Y9 ?
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 Z0 l& L- l0 o2 O. D
                ProgramCompare reached1 = new ProgramCompare();
6 S, i# i1 m) u. d7 j3 b% V                AuthorisedUsers reached2 = new AuthorisedUsers();       
# |8 x2 F/ L2 Z: ^: t                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
: r. C3 {/ E# d+ s7 z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & |# ?9 E0 Q4 s% a
        }
2 @) s, _/ f8 v! ]8 k# U! n& p7 n0 x) Z}// end of class ProgramCompareMenu3 ^- Q5 M# _+ f8 h+ p7 c% v
9 L( W* h! F9 t( N7 n8 i
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ W/ ^9 B& m# N5 m5 j
//          AuthorisedUsers.java          Provided by: DRS
/ d4 `! J( S9 L. G' a//               
6 O. Q9 b3 L1 P( x4 {//         Program shell for Assignment 2- F" {3 {2 X* ~. [
//) n; ^1 ]6 S7 u6 X/ A
//         Represents facts about an AuthorisedUser
) V# T* i9 w7 L: O; ]+ X+ T( _9 u//********************************************************************6 C8 M8 r! N  h! ?) d  N
' o6 J% ^! z1 G/ B4 u
public class AuthorisedUsers8 _1 S5 t$ Z: H  D  I. E4 T3 w
    {7 J6 w( f$ ?; T  U" ~

% }; t! I: C( @! `: p( S        //-----------------------------------------------------------------8 W$ n' h; G/ a  R
        // Constructor
8 u' i; U9 I- [' ^        //-----------------------------------------------------------------+ F& m  E: d, ~8 Q: V

- k6 W% i1 d3 z7 d        public AuthorisedUsers()- C: R3 B  |7 g4 V# o. ?- T
                {
5 V) p% Q0 p2 ?. J# l3 l1 |                }
  N8 L1 K& a2 @/ A
9 ~2 R6 S2 q) ^1 n( E* w( }, n        //-----------------------------------------------------------------
/ [% V. H% \  C8 Z: ]        // Method for testing that class has been reached& J7 L7 H( h* R5 E& M  _$ y+ \
        //-----------------------------------------------------------------       
1 k/ F; z0 S2 [2 M2 h        public boolean AuthorisedUsersReached()# O7 e/ _1 @2 a' c: Z0 t8 Y8 q
                {
- L& r5 [: K8 c7 G! V                        return true;                       
+ X) k& I  J1 o( _" f$ l  l% B" W, Q! @                }* O+ X& o7 K0 |$ Q' }) p
                % j# B) z; n  w+ ]8 h$ v# J
    } // end of class AuthorisedUsers
0 [1 h$ @5 l; W  Q$ e! u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 b8 e! K4 }( K7 d7 MShanghai - 2007  I" v0 g, e7 u4 }- l
Assignment 25 }+ S3 l2 f/ T4 C! _, ^" s7 w
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)
9 u( E/ _- P5 l! z( K# r" i# h9 d1. 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 o- }- X# W3 ]' m, V& SThe staff must be able to:
8 I/ p1 Y. v- M9 j Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 f6 |7 ?$ `% `; [; C( S1. 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.
/ O' p# }, ]! A' W( W  \+ l The interface should provide a menu so that the staff can:
; {* s) E8 c, c3 x# {  d9 |a) Enter the names of the two Java program files to be compared: f+ a% A. ~$ {$ |/ h/ e
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 z  y, F+ m: S# U0 f2 i** 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).
) C1 b/ U+ L/ e( f5 pBSA104 Business Programming – 2007: Assignment 2
7 j7 t. c5 S0 H$ v& T1 L5 tPage 2 of 57 w; V0 N9 R' y+ L' @8 Q
b) Print out to the screen all the lines of code that are the same
* E" ?8 L- j0 c# U  s1 _ Include the name of the file and the line number of the code being printed for each of the two files" H3 ~1 [4 l$ a- f0 h* h- j- v
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( y2 R& v; S. ^& Y; r
 the name, username and department of the user6 t3 D' G2 H0 P& U, n
 the statistics of the comparison) a8 C; L9 @) B- |
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# t9 H! u4 X/ D: T
 the recommendation for further checking, ?7 n& ^& m! 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
4 C: D  W$ h( Q% N the names of the two files compared) k1 \+ M7 S. B* o0 m- ~
d) Leave the program (exit)
; a; j  T% P) M  O' BThe ProgramCompare class: (Total maximum 20 marks available)
7 J) s' c, x, o. P" ]' U2. 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)
$ q( [4 K+ ]% G& [9 Ha) provide an error message if the files are not found or there is a problem opening them6 `- H3 b9 T( J% D' r+ D" V# v9 t
b) compare each line of code
4 m0 t3 [7 k$ e1 ~6 y$ ?2 q8 Q9 }c) print out the lines that are the same
% t0 P' d. x( f/ E* pd) count the number of lines compared / lines the same5 n) ?9 l, z5 `
The AuthorisedUsers class: (Total maximum 20 marks available)
) ^: k) l* z7 Z# s- ]4 E' c3. 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)- D6 H& N9 M9 h2 Y, R
4. Provide methods to:
8 T0 t# T9 ]. F& ea) 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
; q( c: E: p. h' N% ob) return the name of the authorised user
. m4 s' u/ e4 k: V: |c) return the name of the department of the authorised user5 e1 w5 d2 K' J2 s  \; Y  k
Individual Data (Maximum 20 marks available)
0 c9 O, W' S6 Y/ V" R5 d5 q5. 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.
" X) f8 b& `$ W4 D3 ~  p2 fDocumentation (Maximum 10 marks available). W. b* k7 d+ U. M$ N( {5 U% O" a# g
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.! s  P9 S! M* R  y
BSA104 Business Programming – 2007: Assignment 28 R9 w7 }: [0 n2 R$ H% \. y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 u0 Y6 |( k& {4 K不过你要翻JAVA的类库说明。你有下载没有?3 {0 d* j6 N3 f8 o' m5 h
查询关于对比的函数。貌似关键字是contrast,还有compare+ ?' u3 S* ]# `, p. F" v; L" w
4 M6 t$ [# v4 @) [9 v4 |
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ ~" ^3 h% B" a0 C$ Y1 R- s( J& b+ ]痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 Z$ n. O& c$ X可以下载到的 是 jdk-1_X_0-doc
2 ^3 |5 G% G, a! E* g
$ @  r, Z( w- ?: N. ~$ C9 r4 g- o[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-12-6 13:14

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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