找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1440|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ?% [' o# b7 n# w2 s! y3 T 7 L9 |% G5 N; \
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************( R; n# p( u- H( m0 h) g  U- f
//  ProgramCompare.java         Provided by: DRS
7 ?9 b+ }! B* q' j- `5 g//3 e# C1 t6 R& [! l
//  Program shell for Assignment 2
" y; E! K/ n2 S- x//
! }/ {( C/ l* _  L4 l//  Compares two text files line by line0 Z3 i' K7 ]7 B3 \. Z
//*********************************************************************0 v9 o# a! q$ [; Y- a$ [0 U6 S

* A8 Z7 v# o+ M- J! |* Zimport java.io.*;" F! J/ ?% W* ]7 ^

- {; U1 R" x: Z" z; f, W6 wpublic class ProgramCompare
5 Y4 [2 I/ ?: J; T{8 w* A" l9 o- v. o
        //-----------------------------------------------------------------; P# t( j6 E+ [+ f5 ]( C6 p
        // Constructor. S) a: ?! M' @. A. O0 L) k2 c! L$ z
        //-----------------------------------------------------------------2 E% w6 \9 \  \5 l/ Z( n
        public ProgramCompare(): ?+ [/ l7 ~( s
        {
7 Q& n3 D/ Q, Y+ j% s. i! f; v        }
: f5 t  V+ d) i; O3 o" D5 p
; s+ a, o% c7 S        //-----------------------------------------------------------------
" P# ?: R: _2 ?2 s* z! Y' b, D! S        // Method for testing that class has been reached5 B/ ]  ?/ M* @+ h5 H% M; y: Z
        //-----------------------------------------------------------------       
% }1 y$ Z( h# p( F
/ o! W0 ^' M4 G5 V' u! l: o        public boolean ProgramCompareReached()        
2 @# b: `) X3 L2 j' C5 v7 y4 ]) B        {
! O0 i5 t7 c; w      try 1 \: ]6 \& n  g1 H' W. ^
   {         7 L! _. ^7 m, l1 X' e
                       
9 V1 u' h9 y/ R" \                //********************************************************************1 v; x( j# [1 L9 E4 Z% u4 E/ b$ m
                // Try-Catch Statement is used to handle exceptions - such as file not found   \2 x1 t/ G/ c! v' |7 Q
                // Reading the files will need to be placed inside a Try-Catch - just like this one!" E# F' u3 D6 L8 k2 \* G+ }; [
                // For more information see page 534 of the textbook& ~6 f6 U9 S5 a" Q+ o6 u
                //********************************************************************3 p/ W' m" u& _3 f9 _
                     1 o4 S; e9 ^/ r, F! C1 e
        }7 d* U. H0 q" ]8 N! x* K; \
             catch (Exception ex) // Exception caught here and message displayed to the screen
  }8 R, X* z. h; F6 w4 o# U  V          {/ k6 s# Y' R% t' ]: q
                    ex.printStackTrace (System.err);3 }4 k  G/ [4 N1 ]+ \8 a, R" J
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- j. O( h$ }3 I. E6 _; ]2 `0 S% D        }5 l) O* t% [( M1 L3 i+ r
                return true;0 H+ \7 v; V6 _5 r6 r
        }- ]3 n" S2 ?; A# \0 b" y7 {7 [' {% a

6 V, |  t; Y! M' J1 r8 d} // end of class ProgramCompare/ C/ p. r4 h, t1 t
+ O1 g1 q! ~; N$ F. e: u1 f  v# g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 J  F5 ^* D6 d1 m& q7 S. @" F//  ProgramCompareMenu.java    Provided by: DRS
; r3 a% ^8 T1 T( Y//
! L& ^$ @' |6 m8 M. [//  Calls AuthorisedUsers.java and ProgramCompare.java3 a; L5 M* Y5 G! Y* d9 [
//& F& k( I; C( I  L& R
//  Driver shell for Assignment 2.
& a& j$ x. r# V5 G5 j+ G, A//********************************************************************
" C& O/ w2 f0 s2 [/ L
( k( w/ \' z( T  {8 E! Eclass ProgramCompareMenu6 a5 ~7 \! Q; k5 N
{
! {6 {$ t( S, X. l% T) Z" d% \% `2 l    public static void main (String[] args)0 o" J! Q8 s" |* m. W* s
            {
1 u$ ?7 A- C( R: k1 G: h                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
1 \3 d5 ^3 i, g$ `' d) `                ProgramCompare reached1 = new ProgramCompare();
& X1 u2 s2 K; c                AuthorisedUsers reached2 = new AuthorisedUsers();        7 G9 X) X: p* `: K" T5 v
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());, E% E: J: ]; q, W% \& Y; j4 f
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; w  }+ C. h7 m; _        }
1 k" c7 O7 X, s# `( D$ ~. ]}// end of class ProgramCompareMenu/ ]& U4 N; t2 j) m# M" y
. ~+ N$ C1 A3 s' m5 {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- ^9 ~. c' `$ c& T//          AuthorisedUsers.java          Provided by: DRS8 {0 V! Y2 i. w. q
//               
# }4 |' }5 M2 V4 U) E//         Program shell for Assignment 2! |5 t1 U2 P+ c  k; B1 c
//
7 s2 a3 Q9 e( M& o1 o//         Represents facts about an AuthorisedUser' V$ {& E' B8 v) w% G- j1 {4 B
//********************************************************************, j3 k( g& m- T) f$ E

( R8 `& z# P" R+ F& g* z1 C2 Opublic class AuthorisedUsers
0 s3 s3 U9 N- a* C$ l# m) _    {6 J4 E- c1 x( h' U+ f3 m% @

" F  G/ z- ^- B" f/ x7 @  D; O+ @        //-----------------------------------------------------------------5 j% p9 X: v5 y3 W) [) K) }
        // Constructor
- {, I+ M1 h1 M1 T1 _+ h+ w        //-----------------------------------------------------------------
- H4 v4 l7 q. ]7 S2 ?1 M+ c) r. B. Z1 E; |. v
        public AuthorisedUsers()( Q9 J. B  \! t
                {3 Z$ Q9 W7 |* O
                }& l) ~5 p/ m: y# k/ x

. H& V& @$ K; ]$ @6 q        //-----------------------------------------------------------------; r6 _9 {! g$ R: l, H( L
        // Method for testing that class has been reached
  F3 I; D: v7 V- T! _& h        //-----------------------------------------------------------------        # Z0 u4 E3 j- N- c' P' a
        public boolean AuthorisedUsersReached()4 D8 I9 E: A0 ?9 m- }
                {
/ t5 L. J: J( x) H  g                        return true;                       
8 X9 c+ l& B3 x& i* ]3 Y; ]4 C                }7 l+ i4 t$ g! K. P
                / L+ `7 W) j2 v* l" I
    } // end of class AuthorisedUsers1 i, ?( y. @: R" l
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 m. {7 W2 v' M( s# s
Shanghai - 2007
$ |1 [$ R8 \$ c8 G; DAssignment 2
. A- U: _( W0 d0 R7 _6 MDeadline 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 E4 o& X- B0 k' a, |
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.( y+ b5 l9 t3 E* M* g
The staff must be able to:  V5 p, y/ Z' S& L/ M
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  ^2 X2 p* P3 @0 I$ j, r
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.
1 V, a, S0 W9 a' x6 m The interface should provide a menu so that the staff can:" \0 ?: C/ N  L
a) Enter the names of the two Java program files to be compared# E6 C( n$ C6 X, _6 s; m2 E
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ j* d8 j5 I( |) p  a** 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).4 z& I, x- m8 z7 N. _
BSA104 Business Programming – 2007: Assignment 2; {5 ~2 ~; F% z5 D7 t3 v3 y! r
Page 2 of 51 [8 S! A$ K7 `/ t
b) Print out to the screen all the lines of code that are the same
& U5 O+ z  U% C- o7 j' s1 d Include the name of the file and the line number of the code being printed for each of the two files
1 [4 b& v9 I/ y: sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
% G6 A( k2 _: l; m the name, username and department of the user
+ J9 T; T& i7 {0 `* T the statistics of the comparison
3 S0 J' s4 E$ D+ v- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% m4 g6 r! E1 h$ } the recommendation for further checking
. A/ T2 L* g1 V7 J9 O+ V- 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  H$ V6 l# z- J  o4 s4 e
 the names of the two files compared/ s8 u. r7 C2 c& n; C
d) Leave the program (exit)- o2 b! L% p& q, g) I& p
The ProgramCompare class: (Total maximum 20 marks available)+ _* `& H( p1 k+ p% b! L$ e# {3 g
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 H3 q* s" k% [0 }# y3 \5 O& `3 W
a) provide an error message if the files are not found or there is a problem opening them4 P: ]; D. r# S- I% s
b) compare each line of code
* d# o3 t( e( x2 Kc) print out the lines that are the same. M0 v8 G: T7 [
d) count the number of lines compared / lines the same
: x7 u( M9 ]& T& P& A( zThe AuthorisedUsers class: (Total maximum 20 marks available)7 a% S. |& q' i. L; j
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)( `6 B) F" z8 P3 f* f3 Z1 d
4. Provide methods to:
! T$ h* ~  b- b! ja) 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
# @" B+ N( M, @' C1 N2 r- bb) return the name of the authorised user& Q9 D4 y( ?( Z+ y: a
c) return the name of the department of the authorised user
) W. M" E9 i2 d5 v9 FIndividual Data (Maximum 20 marks available)+ x7 n# {- v% L7 o# Y5 L9 K9 {9 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./ @% L  `3 d0 h
Documentation (Maximum 10 marks available)) a  G& T2 t1 W
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.6 Y' |" [* P+ G: w( s+ K, I
BSA104 Business Programming – 2007: Assignment 28 |8 t0 m0 S- r0 a8 t- u0 C8 ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了3 Q: e. d# M" j& i6 ^% c9 ?
不过你要翻JAVA的类库说明。你有下载没有?
) W8 Q7 ?% ]# v! _9 X" o查询关于对比的函数。貌似关键字是contrast,还有compare
6 V$ C$ o0 u& A9 K. w2 T' Q% A" O' B7 f4 P& Y; H2 i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
" k+ e' I: [2 @3 z2 f. f, `2 r痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
( a% y8 ^! Y8 [  X6 O可以下载到的 是 jdk-1_X_0-doc
: c0 o7 D0 z( I9 ?
! F1 q1 M7 K" m( |  C7 l[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-7 09:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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