找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1700|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 k* I8 ?7 z. M& i _ 1 ]1 Z$ R: [; k" t: 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 | 显示全部楼层
//*********************************************************************2 d4 j9 \. b* n4 ~% e3 b( @; p
//  ProgramCompare.java         Provided by: DRS. ~6 g/ @1 j0 K2 `6 H( {3 c# `
//3 V4 ]2 r- }3 O" M" i, j2 h
//  Program shell for Assignment 2" B( {+ l( F- V0 F. h% O0 V
//
9 V6 Y  ~" D/ w/ U//  Compares two text files line by line
8 x5 M1 x8 Z, n9 v0 O; ^2 D//*********************************************************************  y6 p/ L! X+ B( z. b/ g) L2 d" M! Y
* F# H( a* v; r( X) P1 F4 k
import java.io.*;! x( n* j" \- B2 j( S
; y. s' A* ~" h- Y  d8 {6 |! k
public class ProgramCompare
2 P( Q" I3 Z9 S! ^! r' s, ]" J" s{* l8 Y3 f+ L7 c$ T( Z( d# V
        //-----------------------------------------------------------------8 @. e/ t) _( e9 {4 z9 d
        // Constructor
' J; U8 B# A7 Y        //-----------------------------------------------------------------
& G+ J( k; m3 ]; {1 n" _0 f! X        public ProgramCompare()6 J7 _/ J5 m* a, `
        {
1 h8 S/ T% H! b6 ~4 O        }+ }. m; Q+ Z7 u) D+ l% Q+ V! f
" o) K* q" }$ w" \
        //-----------------------------------------------------------------
: D8 k  K5 w. w+ q: g" Z        // Method for testing that class has been reached
/ O4 r+ O+ c& b- p3 P        //-----------------------------------------------------------------        4 ^5 S% R3 s/ Q
: ?2 I* Y! \& s) g/ P( J4 ~
        public boolean ProgramCompareReached()         8 c9 w& i0 j+ j
        {* j6 p' I( q# v- Y' G
      try 2 H6 H6 M( t% B& f& ?
   {        
5 D0 N2 j' F- x' s1 g2 r                        ) z0 o/ v$ E, w
                //********************************************************************3 ^8 Q9 a% }9 M9 p. E
                // Try-Catch Statement is used to handle exceptions - such as file not found ; ?8 v# E8 n. a: ~! A% l
                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ i  n9 F# Y5 W/ O2 O
                // For more information see page 534 of the textbook7 n% n( o* e( r# [5 I
                //********************************************************************
4 ]6 O3 f# f* D# D" Y- a                     0 X& Y% l( }: A0 ?6 G8 q+ `4 T
        }- b+ L- m2 l2 i
             catch (Exception ex) // Exception caught here and message displayed to the screen
) j; a# [7 ^6 u" r          {! f, t' u; k+ @2 b4 E6 i
                    ex.printStackTrace (System.err);+ A+ v2 l# G  Y& A, Q4 ?
           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ H# V0 R' F3 R7 i        }, E) ^9 E6 z- n8 i2 Y8 P+ h
                return true;( S) M! b8 X& z5 p0 y' ]- K/ T
        }
# S6 J( D  s1 V1 _0 H  U, M# O9 o. E5 s7 I4 ]9 F
} // end of class ProgramCompare
! i& H+ k# X$ E- A2 D  _3 |5 A1 m% n6 k  n6 ], S6 d
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 W  d. A8 D7 h2 O& t* n
//  ProgramCompareMenu.java    Provided by: DRS, i, e; a: z! ]7 }: r. u; b, v
//) u3 K4 k' w9 ~6 d3 W; W7 k
//  Calls AuthorisedUsers.java and ProgramCompare.java+ \3 b, a. Y1 c4 L1 e$ g( o# h5 p# ]
//: \5 m7 T! g5 h7 Y
//  Driver shell for Assignment 2., j$ K+ A* ^  d2 V$ S
//********************************************************************
4 l; F/ |( Z' E, ]  _" L7 D. Q! P( _0 p
class ProgramCompareMenu& s& W# w) Q: l! Z
{. n2 N7 {3 ~2 {" _
    public static void main (String[] args)+ O' ~, ^5 b6 i5 a: r/ ]6 n
            {2 }' H0 n  }& S& h/ w" k) K  V* ?
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
' k4 O5 l) L( ]. t# V7 ]                ProgramCompare reached1 = new ProgramCompare(); $ b, ?# I* B* C6 ?: O% J
                AuthorisedUsers reached2 = new AuthorisedUsers();       
3 y5 b$ y4 s$ \                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());9 u7 v9 J" Q4 t) p; c' z2 s
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) Y6 b- K0 @; e0 Q( F6 ^        }
8 R, P* h, b+ r8 J* u& y}// end of class ProgramCompareMenu$ s4 P1 C. `& k, ]& y9 D
+ c% Y- ^( x2 C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  m. }1 _3 Z  I( S, x% V//          AuthorisedUsers.java          Provided by: DRS- \* Z& }  {2 O6 A/ Q# F
//               
4 t- F; \4 a* M//         Program shell for Assignment 2
, Q6 F" I( ?, N+ Z2 H' n; q7 O//2 m- ~$ V) f9 d1 O) d
//         Represents facts about an AuthorisedUser3 c0 {: T! L* v9 |
//********************************************************************
, T& b, a& j# H7 M! i
  [) D) v6 d- C" K5 p8 x; Gpublic class AuthorisedUsers
) Y% w8 {& c5 K# Z" C    {5 T8 Q5 [" b# v" ]; I/ ^
5 f$ n" W1 e  I/ p1 K; J
        //-----------------------------------------------------------------
/ a* M2 z1 T' t; Y, c. y        // Constructor
' [3 o2 y% Q. }        //-----------------------------------------------------------------% d, t( g& f# T6 b( \; |" k
" B2 L8 \) }# O! G7 Z! R
        public AuthorisedUsers()8 U& S0 w7 H- ?+ |' F
                {
7 `. w4 r3 K" l3 Q                }0 _; l* D/ \& f9 i8 i

; n! P. S2 l9 M1 ~        //-----------------------------------------------------------------' I9 J/ N. T4 K) q) e+ z5 e
        // Method for testing that class has been reached- M( n. ?/ Y, m5 o% t7 b9 g7 }
        //-----------------------------------------------------------------        8 x& z1 r4 y2 i4 n
        public boolean AuthorisedUsersReached()" z3 X7 @. J% |- \! t. w9 F
                {
2 q& M/ }2 x9 Z6 X# P: v                        return true;                        5 ^4 G* L5 \  C7 Q# Q! \& F& X
                }
8 g, ]% p9 l. q0 h, q9 v               
; J9 ^& x( R) c1 K  ?& o+ W    } // end of class AuthorisedUsers
9 `1 f- L. z) t3 D* v% |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ y% X# s- a* I+ y
Shanghai - 2007
4 V/ o/ G' w( d; y- z! hAssignment 2
. ~% v4 r8 `, l' Y* pDeadline 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)
- f- K1 F7 S! w% X1. 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.
+ {: [$ f0 J3 O( j8 _The staff must be able to:
5 p" W" @4 E9 m# _1 D1 ~ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.8 ]" Z6 K% B- _! h; I' l( [
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.! ]/ p' D* Y: u+ N1 e( g" H/ J# n
 The interface should provide a menu so that the staff can:
: h' b4 N; M3 oa) Enter the names of the two Java program files to be compared
# p5 C, K2 ?) g. B0 t2 C For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
) \7 B5 q5 }  e! J** 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).# a( g* }# [' X3 X
BSA104 Business Programming – 2007: Assignment 2! d1 |  V, w; P5 m+ b
Page 2 of 5# w# x; L& q/ @, L6 @0 ~: l
b) Print out to the screen all the lines of code that are the same
/ a; a! O% @# D: ~& {  c  ?& Y Include the name of the file and the line number of the code being printed for each of the two files
6 C% g% _( a. N. bc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared8 V* l8 L% K- N2 \
 the name, username and department of the user
6 f% I" y/ i3 [ the statistics of the comparison9 z/ h. z! W! n8 W$ i
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
$ Q9 [$ X% S1 Y5 r1 s the recommendation for further checking
" Y( I; C% h' ]& O* H5 v" C- 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 closely4 Q: v2 Y5 f6 n2 }( ~1 n
 the names of the two files compared
# u+ q  I/ H: I& p3 v9 l7 v. Ed) Leave the program (exit)& `1 H! P. w# s. t7 z& x) Y$ C, ~
The ProgramCompare class: (Total maximum 20 marks available)- T% @& j- a. Z& ?- a! x
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). ?  b% p9 g+ x: T1 B: w
a) provide an error message if the files are not found or there is a problem opening them& p9 t- X8 k' m  j- W
b) compare each line of code- O: u( T) s$ B$ j& k0 h4 N1 p$ b
c) print out the lines that are the same, L4 F  o' _& U# F8 ?5 {6 \
d) count the number of lines compared / lines the same; E6 \) L% z7 q# R1 B# |$ M
The AuthorisedUsers class: (Total maximum 20 marks available)& E! u. j1 b# R. m( f1 @
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)1 B- R9 o0 N. m' ^1 p
4. Provide methods to:
. _$ r, p1 n9 @, s6 m; J7 ]4 v3 n1 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
+ f8 l6 J2 @- c  P. J( ^6 \b) return the name of the authorised user) X  c8 }: ^' {* F5 h
c) return the name of the department of the authorised user
4 ^0 q9 o7 @* g+ v! b2 HIndividual Data (Maximum 20 marks available)& [4 C. M8 E. c4 F" o# c2 N7 c# q" |! S
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.
. V- z$ O' ?% v% c8 y( W1 XDocumentation (Maximum 10 marks available)
  E$ c$ j2 o  g; |+ N/ {1 Z, o6. 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.3 y4 q4 K4 f# t. d8 H2 z
BSA104 Business Programming – 2007: Assignment 22 y1 R) Q) o7 {) Z4 k5 O9 ]
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
9 \3 V& f4 n4 W. [不过你要翻JAVA的类库说明。你有下载没有?2 D) r' x* d1 [3 P/ j, `# B( R  y
查询关于对比的函数。貌似关键字是contrast,还有compare. f! {  z3 Z0 L

& P) c0 Q* u4 H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
" f  X- C! q6 o" G9 C8 a痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 b/ R+ P$ H& M: {; e可以下载到的 是 jdk-1_X_0-doc1 s+ |! \) A0 c# J
- h6 r" \, V% M' K2 p" ?: |
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-4 22:23

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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