找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1355|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! s v; b$ h. P- r/ W, h3 a5 k; ], {9 a: W8 z/ }
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 o/ p' Y, O4 O# U//  ProgramCompare.java         Provided by: DRS! J; I" f3 U8 ?' J
//
7 |2 e6 ~1 r# Y% d6 m9 [3 a//  Program shell for Assignment 2# K/ r: P( m9 m. _
//7 c( n/ ], o& G5 N( p
//  Compares two text files line by line4 R! ^1 b5 }1 E! h4 h5 K
//*********************************************************************
/ C5 Y9 F* K$ r. V1 G3 l2 B$ d% u
import java.io.*;# N& G, t5 R0 B

' m3 o, j. ^4 S. x5 e: _1 O8 Z" Dpublic class ProgramCompare
2 \! g8 \3 L; s% V8 M{
4 y7 D# Z  F) P# J% E        //-----------------------------------------------------------------
$ C, O- ^8 Q) w        // Constructor
& o4 u* `0 {/ \/ _$ L9 y2 ^3 _% ~        //------------------------------------------------------------------ R0 y: Z+ i3 M* c# H' f9 x$ g% Q
        public ProgramCompare()
9 L2 `, w! q& M# d# V# y. W        {( k$ V5 @  y0 u1 L7 k( [: ~
        }
& y' G6 L9 E1 o. R! V0 h8 T
6 _, ?$ V: X6 q4 x        //-----------------------------------------------------------------6 G  H  k: S& L4 y8 a. j
        // Method for testing that class has been reached6 Z; }$ C7 ^9 W+ d
        //-----------------------------------------------------------------        5 |. l9 g7 E  P- c/ p0 ^6 n

1 i1 g3 z# Q1 H        public boolean ProgramCompareReached()         2 i1 S2 R$ ^9 x3 `2 V- |
        {( l, v4 h& E  p* W
      try : v/ U1 t- L8 [7 K8 j2 f% m
   {        
) p$ i7 W$ s. L% n/ z, ^* p; @4 U                       
! ?0 |1 `$ X$ f- `9 C2 G" d                //********************************************************************- n7 C8 q7 z3 Y! ]
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 |) |$ {, y: x6 s! U# P                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, G" v" E. n- w1 t. q' i: S: H                // For more information see page 534 of the textbook8 ]" e) N3 G% \6 _8 g
                //********************************************************************
5 Q$ ?6 \2 l! n; I                     ; d% R# v, n7 C2 `' ]* N5 t7 V
        }
3 f1 l) n. [0 X, U2 a! [             catch (Exception ex) // Exception caught here and message displayed to the screen ' s3 C  |) }2 C7 j
          {! J+ r. X. R5 r, `( O! z" H
                    ex.printStackTrace (System.err);' c. S% I/ S: i+ G" y; c
           System.out.println ("Error message goes here"); // Replace this error message with your own         
; T- F' T& Q5 x0 r1 O        }$ M) |) \# G5 I& i/ `, C
                return true;
; [1 z/ v3 R/ Q% b        }
* Q8 p, J+ |* O  ]  ]4 t# b) y9 D6 g! j/ ^  l- i' q
} // end of class ProgramCompare! \, O4 f& B* w6 A0 Y5 N. X

( g! w) G1 v, Q& t0 w4 [& p9 V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 s6 U$ s! I  D/ q5 u+ P& O- U/ C2 Z
//  ProgramCompareMenu.java    Provided by: DRS6 s4 {+ Q5 q5 V! q$ ?
//
2 I3 t5 b5 F4 N//  Calls AuthorisedUsers.java and ProgramCompare.java
2 A% s' g  Z% i//* o, y# w2 e! G2 P+ I9 w) Y! D
//  Driver shell for Assignment 2.* V/ L2 r/ W! C5 A+ N
//********************************************************************  V  ~; m% g% b, i% U3 Q
+ w& i# |4 L- m# Z
class ProgramCompareMenu$ M5 `2 O' l; V
{# r) z. M! h- t
    public static void main (String[] args)- P4 C- }* G& K
            {
8 p0 y! z2 B9 @" j+ ^& `                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 `  E, @, v5 b9 C) q) \8 B7 K3 b9 C                ProgramCompare reached1 = new ProgramCompare(); 2 V% s; F4 |# F
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- ~9 H8 `" e3 _1 I" H                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ e/ M; A1 i% U  X$ S1 I                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
* M0 {8 k6 c9 Y0 Z/ ?/ W; o        }& n4 H& B/ S( _* T5 H/ {
}// end of class ProgramCompareMenu
; C; g+ ~. A2 K& P
) |$ f: Z5 ~: B( ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ N7 C8 w3 A5 e' h  d* H
//          AuthorisedUsers.java          Provided by: DRS
) {& W6 ]5 p4 s8 ~//                - h2 T- k7 A0 A# C9 h7 W
//         Program shell for Assignment 2
" n" w; L. I) b1 a. t9 l* _; A//
; T( g0 T8 g& Z+ x7 n//         Represents facts about an AuthorisedUser
6 V$ H2 T2 {# X//********************************************************************
( c; R4 b& h( [$ J) V; ?
* X6 r. L3 g- d# Y5 l4 Rpublic class AuthorisedUsers$ ?, v" S' o5 ~  A0 E1 t
    {
+ x0 h4 ]* N# X# V0 P/ K# C8 a2 N  i9 N
        //-----------------------------------------------------------------9 I3 T: }" i# d; v( ?# i# `
        // Constructor
+ z' E9 S/ w# x; o8 x3 S! s        //-----------------------------------------------------------------# C, }  i( Q( J8 G

4 N8 P2 y# O" S9 x3 L8 q# a( x        public AuthorisedUsers()
3 A- f9 {4 Z+ G5 W: ~                {7 s" c  R5 u$ j" T% D$ n' `% @  ~
                }
7 T/ ^4 ?8 p" A2 W  u0 y9 x0 v4 W) G! X
        //-----------------------------------------------------------------
  T) U2 M) [2 V& W        // Method for testing that class has been reached' I4 X9 F( e$ J( E2 ^: o% P' g" v
        //-----------------------------------------------------------------       
! A2 S+ r$ J$ U( e% N, |* o1 i        public boolean AuthorisedUsersReached()
: Y2 W& i8 s/ z! y( V9 C                {4 b% u- d  `$ ^  k8 Z5 F2 S5 u
                        return true;                        5 w5 B) v8 L$ l4 J
                }
: Z( M1 Z  m/ ?3 o                0 s' T4 a+ M3 Y) d- x9 i% B9 i
    } // end of class AuthorisedUsers
) f% e8 Q8 I% A# b+ T8 e0 Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
% ?# m, `: x6 p% F# Q3 `9 EShanghai - 2007
( p5 b7 y2 v, N: N; D3 ?Assignment 22 v. I4 \5 u. }
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)
. z3 P8 E- Z8 S) S5 ?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.
' p% h( P& Y' H1 ~/ ]6 }' i9 SThe staff must be able to:) O, y+ m# K. i( ]" }
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% M) u  ^, x  r" n& P# r4 v1. 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.
4 N/ T* K6 z& X6 S' }8 W The interface should provide a menu so that the staff can:* ]( E, X# u7 h. [+ R. X9 `1 h
a) Enter the names of the two Java program files to be compared; r9 A- j5 \  ?( X- U
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
; N4 S" m; M8 c  D, O6 T** 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).
+ L6 _" [- j. y* N; PBSA104 Business Programming – 2007: Assignment 2
9 G+ o# y& w  J5 cPage 2 of 5
& b0 m5 }( u* W5 [& cb) Print out to the screen all the lines of code that are the same1 F, q1 q7 c! g* Y" O1 d
 Include the name of the file and the line number of the code being printed for each of the two files
; |: Y+ [! L+ H$ V( Y! cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" O. C' e6 l; h1 b3 }* t the name, username and department of the user; R) O2 H  a4 b) ^% z
 the statistics of the comparison; ]2 }, A* X( B3 N
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
  S- F0 U/ u8 C. R' S the recommendation for further checking& U  g. J# I0 B2 i- {* o7 u( u' f
- 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# k' ]* t% x, T: n$ R; a
 the names of the two files compared
% H* k  {# i4 |/ gd) Leave the program (exit). r& F3 u" _+ {2 o: m( ?
The ProgramCompare class: (Total maximum 20 marks available)4 |, d- Q: F. m9 v7 b
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)
6 z3 l* q# @- Y/ B7 B! k# Qa) provide an error message if the files are not found or there is a problem opening them
3 w, C/ Z- M4 n0 sb) compare each line of code
; N) }7 _* w/ R, J# v% @& o$ Mc) print out the lines that are the same
* A7 @" U  S' K# {0 a5 h1 D. U% |d) count the number of lines compared / lines the same* o: c6 ?4 {9 t0 }! D
The AuthorisedUsers class: (Total maximum 20 marks available)+ i+ M" D2 f" b7 w; n
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)/ c) A* B8 O5 D' q' Y. L# G  M
4. Provide methods to:  D) H7 n4 a  h
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 match
- e2 v4 {( E$ ?- g1 Eb) return the name of the authorised user
1 ?8 g" i4 Z; u# oc) return the name of the department of the authorised user
* N  W. L% u+ r% X0 p6 s* SIndividual Data (Maximum 20 marks available)0 ?# x  X% `9 B! s& Z0 N8 ~- i2 ~
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.8 ~- Y# R' ?' p: V1 B, m3 n0 i: B" z
Documentation (Maximum 10 marks available)
1 z) [( U# Z( a$ p6. 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 O* T7 v. q0 A4 IBSA104 Business Programming – 2007: Assignment 2; T$ f! L5 @, D8 [
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 t1 H' k* J) W9 e: l# T
不过你要翻JAVA的类库说明。你有下载没有?. R2 s* h- H! r1 L9 b2 u
查询关于对比的函数。貌似关键字是contrast,还有compare
* i8 n) w3 m! r; C' e( O! J; X( @. X  v7 b$ K( s! ?( v8 ~& P! J. B4 t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' R4 ^) L" i+ ]
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! m3 o7 d5 H7 [4 I
可以下载到的 是 jdk-1_X_0-doc
6 F# f6 p* k4 z: M2 I- a9 C& r4 B* E4 M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-5 23:22

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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