找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1211|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 o' ?, }0 l0 A& G* v7 v # m+ Q1 d) S* x2 G" g/ m4 _
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& a! r9 r6 O% J5 U# J# P
//  ProgramCompare.java         Provided by: DRS
9 [* |9 d4 N, M9 c! q//
1 K( R5 o6 [/ y9 U//  Program shell for Assignment 2( D) b) u  G4 m3 u
//
; n; H1 X- F  @& M' m$ g; [//  Compares two text files line by line5 w8 \0 X; Z. d1 A' }8 P
//*********************************************************************
4 }1 }+ M6 t  j0 X8 W9 O( D  ]# T- f7 C3 d0 ?
import java.io.*;- ^! f! p2 c, t& p% K

+ C$ [( j% e- A- Gpublic class ProgramCompare1 m  k' v. r9 T7 N. e4 G
{
! H9 C& {0 K/ b9 X$ B! ~& q, Y        //-----------------------------------------------------------------
: Q$ B  H% D0 ^+ Z4 ]0 q        // Constructor
% ^4 b2 Q8 ^" A  r+ N6 W4 P- F! e        //-----------------------------------------------------------------1 s$ j3 g' l: o. r8 ?) [
        public ProgramCompare()
- _& K, X* H4 `* b* {( `+ M        {
. k& [& w: h( i( d8 I4 k/ q5 P        }) p9 U3 w# p. @9 `/ q9 @, Y, v

. n8 U% x4 X( `        //-----------------------------------------------------------------
" O' Q3 l+ o% `0 h, E, C# e3 q5 Z" \% U        // Method for testing that class has been reached
2 W+ @- y* w* }4 U        //-----------------------------------------------------------------       
4 M+ y  ]  T3 S4 j0 t, f, @9 @( V2 v; p
        public boolean ProgramCompareReached()           b6 j. J- K9 @, H4 V
        {
( }, @, P# N1 s9 B4 N; \      try
: U5 ?# l$ ^* }1 g+ p8 a   {        
2 z$ M9 D. n3 O4 V- A                       
- \- |- V, x: K7 T2 l/ H                //********************************************************************
5 w' d+ H: i  f* ]3 ^5 o0 F, G9 V                // Try-Catch Statement is used to handle exceptions - such as file not found
; R- T9 f9 L( E0 M                // Reading the files will need to be placed inside a Try-Catch - just like this one!
& s& ^5 V% n9 a( t                // For more information see page 534 of the textbook/ L( `. u: H3 p) ]/ Q1 F' D
                //********************************************************************
3 ?, _/ b$ _% d5 Q2 g/ ^                     , T0 I. a, I; M: G# T  v
        }
+ S. U4 z" \" y2 }' c             catch (Exception ex) // Exception caught here and message displayed to the screen 7 Z9 {5 \. f/ q
          {
0 M" l& U3 _, {, M3 b* ~                    ex.printStackTrace (System.err);+ I9 b, O, n* ~& G4 L# B  a
           System.out.println ("Error message goes here"); // Replace this error message with your own          : f9 {0 t: n( @- g, r9 |( \
        }6 u0 Q( _5 O, w: ]* X5 S
                return true;5 I, x& |( G( j0 @* x3 [8 C5 C
        }" C1 p& j5 {  K. V0 |2 C8 A

( e, @; X) s1 W9 I' G0 A- o" P} // end of class ProgramCompare" m8 @* J9 P# X
" P! l* X9 c  B- B, G/ N6 `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* e% p6 @$ ], _3 W% Y9 E% m//  ProgramCompareMenu.java    Provided by: DRS; {( S. |8 m6 D; k" i2 s
//
8 ?! v5 s6 W/ g3 y5 q1 ~//  Calls AuthorisedUsers.java and ProgramCompare.java" a2 G3 ~7 p! F) a" C5 @7 F
//% |; y( H7 d7 {4 ^
//  Driver shell for Assignment 2.
3 O' I) D! _( p: D! I- ?//********************************************************************
: L7 D/ v9 c5 _# Y: N& f/ q; i1 [0 k: o( b3 ~
class ProgramCompareMenu
) e  U: X) d# c) q8 ^) F{8 r; T& b; E4 J- W
    public static void main (String[] args)+ U" O8 g2 g6 q$ L
            {9 e5 `0 X: b' M3 y6 x2 F' f
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
+ N2 `, |& J6 w, z; i                ProgramCompare reached1 = new ProgramCompare();
4 N! T2 {8 A/ G9 @! {                AuthorisedUsers reached2 = new AuthorisedUsers();       
- g+ ^1 `4 C  S( H8 U! e% W* h9 b                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 v" S+ P0 s- {
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & n7 f9 N0 A* s3 i( V0 _$ Y( Z
        }
6 c7 V  W7 f# u- J* V. `+ d) E0 |}// end of class ProgramCompareMenu
+ `, v& K1 c' k& Q" \2 V
7 l; L1 s. p) [& Y7 |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
0 r' d2 n# M& r5 U( n/ q//          AuthorisedUsers.java          Provided by: DRS  G. H0 b. k4 x% e. t" K0 r& y% P
//                # n3 ^* y1 ]+ t1 \4 f+ K3 h
//         Program shell for Assignment 2
7 b3 @1 N: q4 i5 O% e: X8 j4 m//: n6 V0 s& _, j# E" ~7 Z# f9 \2 ^
//         Represents facts about an AuthorisedUser
: S3 S; i" y/ a, a2 o& V  L//********************************************************************
, F/ i9 _8 w. q* X( n7 M: G. q; {$ i9 `- v
public class AuthorisedUsers, I! X1 W& c+ `0 e  X) ^! S
    {
/ Y- \% P( F) m! \0 y' f; U9 i4 o! \6 J. N# a; L) m
        //-----------------------------------------------------------------
  i/ M3 S) ^, y6 A0 K1 Y        // Constructor
* {3 t5 z! A% K5 ]4 G. b        //-----------------------------------------------------------------1 V! `& h+ I% Z# F) R/ |
$ r/ n; b0 R0 N. _# Y- O
        public AuthorisedUsers()5 Q/ G* y2 n1 b5 L+ e
                {  S) A# w& ]; k; a# Y* ^
                }
; z$ _9 C' x* Q" P8 `- ^/ [( w9 M. i2 x
        //-----------------------------------------------------------------
7 {% [: F( _% _2 u        // Method for testing that class has been reached) p* R4 u& N0 F/ e. E: W( q
        //-----------------------------------------------------------------       
8 Q: i* Q6 G/ U" }" @7 c) K        public boolean AuthorisedUsersReached()0 h! ^' m5 C& \# p2 b7 c2 o
                {
; Q3 I, C7 a1 _: _% F" {! P, r                        return true;                       
" z# m1 ^  M0 S% X( b  i                }5 T* q- J0 d+ _$ U' i
                1 {$ u% S  n2 O1 q  \2 ?' t- |. j
    } // end of class AuthorisedUsers
1 b" P7 D4 R$ N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% C* j! `6 _* {/ e
Shanghai - 2007
4 F, I# D/ t/ L. r  }' s/ e, FAssignment 29 ]& f0 m" |' O6 |9 o& [
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)
5 p. C6 f! F% c( P1. 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.& ^' E* N8 d; w/ o7 {+ S+ J0 A
The staff must be able to:( r! n0 O6 O0 Q. P7 w
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: p9 K1 D+ t8 k/ w) `6 q1. 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.+ w7 O" q/ n3 k# K* x
 The interface should provide a menu so that the staff can:
) O6 Z: A& o" Ia) Enter the names of the two Java program files to be compared
1 y0 d0 y+ F7 y2 j4 W9 v: ? For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 p& y( g+ x, n; W9 v; j- ]0 P' \! K. Z
** 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).
9 _  ]3 m, m' P7 Y% P8 b8 @( UBSA104 Business Programming – 2007: Assignment 2
( J3 R+ F% x3 _8 FPage 2 of 59 Z, O2 v& H* ^1 f
b) Print out to the screen all the lines of code that are the same
8 n7 I4 q8 E# G. @4 g. I Include the name of the file and the line number of the code being printed for each of the two files
; q0 o) b' ^9 _) L. I: [c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 H: y5 B! @+ L% d/ u# K the name, username and department of the user
& p$ Z" T4 {4 U1 A* W2 j3 Q$ m/ B: q the statistics of the comparison1 S% s: T/ J5 w# B; {: S) `+ ~1 t5 {2 F
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( @1 t+ V) y5 g) u- Z2 n the recommendation for further checking
$ W. u5 f  ?' G. x$ V' I/ U- 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% G: y; p6 l) I2 P' d* @' h% _5 q
 the names of the two files compared
. F5 W4 d9 a2 b# V" R) Fd) Leave the program (exit)" l8 `# C( k" V8 b) m+ n2 \
The ProgramCompare class: (Total maximum 20 marks available)* s3 @# m2 Y  ]0 [8 P0 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)
! ~4 x, I6 r" F0 [a) provide an error message if the files are not found or there is a problem opening them  Q$ @  c0 F3 m* K1 G
b) compare each line of code) t. N0 p& A, Q) y/ W
c) print out the lines that are the same
: Z) q" l2 ]4 F7 ]8 A* h7 }d) count the number of lines compared / lines the same9 T$ C/ _. C  d0 @
The AuthorisedUsers class: (Total maximum 20 marks available)1 N: D4 I1 [8 @; M
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 W- q. w  X2 ~2 {8 S! k4. Provide methods to:; Y  ?/ X2 Q6 o. e+ ?
a) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match1 V  Y- q$ L# r
b) return the name of the authorised user
2 J/ e6 `" {' p2 H2 rc) return the name of the department of the authorised user
$ J* X8 e6 P" PIndividual Data (Maximum 20 marks available)6 x5 [1 O& b# }" t: a- u
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.5 H1 R* D: _# y8 U, o+ q! K3 K
Documentation (Maximum 10 marks available)6 \5 P6 a& M& H8 W) 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.$ X  \- f% v6 |4 c% C0 Y
BSA104 Business Programming – 2007: Assignment 2  U+ o% O1 b' N, l6 K6 r  U/ v
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
" E1 w6 U; ?' i3 M. p' \不过你要翻JAVA的类库说明。你有下载没有?# E/ u+ P- F- f6 k
查询关于对比的函数。貌似关键字是contrast,还有compare( n: @) Y4 D6 N
! c3 Y! L) |# t9 f# h% S2 ]+ [. J
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" ]8 P/ I, u4 U: _. J1 J
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 j# X, q8 ]) \' L8 D6 e
可以下载到的 是 jdk-1_X_0-doc
7 E8 D; R. J6 t, X: V, e1 Y: o
- p! w0 d" D- W$ b) f% @9 r/ e8 }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-18 21:43

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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