找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1798|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 n6 G' \, A3 Q1 n6 s( a+ s2 R2 D, G: q1 G$ L( }1 I7 e, L5 M; `
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************$ E: R! M) ]* J! O+ }$ [- m- H! \& `
//  ProgramCompare.java         Provided by: DRS
9 S4 E6 |8 z7 J4 V  t  H. Z' X//
3 u; N6 ]- Z0 w* z//  Program shell for Assignment 2
$ h1 N; W" e) V4 q//1 k: ]* n* ]2 J- a
//  Compares two text files line by line
. p( N/ U2 v" h//*********************************************************************: }7 |& V" r' Y- M( f

, j' [+ b, Q& V0 C, v+ W3 e7 e8 Vimport java.io.*;
5 z- X* n# B/ R" v+ B# S2 o4 k
9 [' b' k" w- k6 e5 G9 wpublic class ProgramCompare+ Z8 [9 p) Z+ w
{
5 z" _6 L2 \, i0 S) y' P5 V+ g        //-----------------------------------------------------------------
# q" K7 F+ E' m; f6 ]- E9 ?        // Constructor% Z5 x: a' {/ q6 }4 g! X/ [
        //-----------------------------------------------------------------
( \3 S: r5 G) g, p        public ProgramCompare()  P% g9 u+ g. P! P! z
        {
, A( @1 _+ l. |: {# C, K# s# f  ^        }7 q' T& |* B& T1 a  Z, Q+ v

+ @  z* ^! X5 z( T* Z        //-----------------------------------------------------------------, R$ T5 R7 m/ F' E  C  r
        // Method for testing that class has been reached
9 X, \- d% x, Q2 j6 V) |* X        //-----------------------------------------------------------------        1 v  N" R4 s0 O$ ]  h$ y1 p  {

( h, Y8 t$ a+ U. `' U1 ?. x+ y        public boolean ProgramCompareReached()         " p; P5 R( y1 ^- E! c& v; q+ A
        {6 P, B& ~" v+ n+ r# {
      try % m5 c* {5 r( d
   {        
" A* h1 x7 ^- L& T. G$ x6 f                       
: F) t, a2 m3 t; f; }                //********************************************************************
' f/ _. J: Z; E                // Try-Catch Statement is used to handle exceptions - such as file not found # c7 C* c) N% _, Q" Y- E+ F
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
: k7 x+ `# O7 J6 U* j                // For more information see page 534 of the textbook7 |( ?6 M0 Q) m$ B
                //********************************************************************
/ H1 S( B6 l! v* \                     & M9 r9 d! S2 N: u$ p
        }
: W; m8 c! V) A- M6 b             catch (Exception ex) // Exception caught here and message displayed to the screen
: ^7 U" k% X5 a- I: l          {' W5 U' ^: @. y6 E6 T: v" D
                    ex.printStackTrace (System.err);' C+ Q2 t2 G5 C% {+ M
           System.out.println ("Error message goes here"); // Replace this error message with your own         
) G& |6 w; \( l0 ~: w5 D        }
, F: z0 A7 b7 L4 r9 a+ `                return true;* J7 U5 F. D# d5 N* \
        }
3 q$ y) v7 \# Y' y, b1 q1 @) b6 c1 ?- _! r& X% \( Q) ]& g
} // end of class ProgramCompare
$ b9 f7 N; \' S. y5 j: M3 g) s1 G  F. D( |. K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 s. f7 ]$ n6 V$ T5 ^8 {
//  ProgramCompareMenu.java    Provided by: DRS
) {5 e) m$ k  [! `$ t; F! X  P. z//
, F( H5 j. Y2 q- r/ r//  Calls AuthorisedUsers.java and ProgramCompare.java
8 s0 N; v# O( @# q//8 a! \) z9 ?3 `
//  Driver shell for Assignment 2.) R$ J" f! K8 U  z) m; b# F
//********************************************************************
+ m6 r& m4 v* F% g
* i# d, K4 W  ~8 h" H, K; lclass ProgramCompareMenu4 x; c9 V0 a; ]4 h& O- _2 h7 e: u
{
- i* S3 n; ^) [( s, \$ m, q    public static void main (String[] args)
" q$ m2 Q( L2 s            {5 g& T& V8 W$ D6 L3 t  |
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) x( c1 f. x; ^+ n                ProgramCompare reached1 = new ProgramCompare(); , i) ]4 y6 r8 T' b+ c- i
                AuthorisedUsers reached2 = new AuthorisedUsers();        . f2 ]8 {! o; k
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());9 R) @6 a$ `. o- `
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) U, x" N; K) c# K        }& F8 q* t& J  {
}// end of class ProgramCompareMenu
# }- u/ {, w, \1 g8 m! ^( i/ G: ]" L1 x8 S
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************3 A9 h4 |7 Z  i# N" H* p
//          AuthorisedUsers.java          Provided by: DRS  C& L- y, g% p  j7 I6 h( F, d, L5 ~
//               
( m% @9 @5 I4 a: B7 H' D8 ]//         Program shell for Assignment 2" p- `2 ~' b3 [: m; n
//- K. g& f  b7 y/ d* u+ u6 {
//         Represents facts about an AuthorisedUser
+ l. t9 F) X' B  V" B& @! M//********************************************************************4 l. r) X# X, p! Y% K
2 E0 _4 }2 K  N
public class AuthorisedUsers! T; d* H- W7 u) r+ k
    {' v# X. s  T, K; W' S

8 I1 y% I# W0 I1 ?        //-----------------------------------------------------------------
/ g; D# {8 N+ q6 ^' R* r0 {        // Constructor
. z. k: }! ~7 |& f, w        //-----------------------------------------------------------------
& C8 ^; L) H2 D" m9 ^7 M1 s# [
; X3 o2 @: ?# B" t3 S        public AuthorisedUsers()
1 {1 ]* Y5 T  t1 V  U                {
$ f- K% E9 i7 a! w7 n. @+ B  d7 q                }
* W, D1 [$ k9 E
- C' w" j5 W; B; J. p# _        //-----------------------------------------------------------------
9 B" J3 w$ [7 k6 c        // Method for testing that class has been reached
1 K6 q- y# g( T2 k! E        //-----------------------------------------------------------------        ! r- _1 @, y. g5 U; X, n1 C
        public boolean AuthorisedUsersReached()5 N- m1 T$ l" f9 O' n0 L- E
                {
$ N6 z8 w& a0 n2 L0 _                        return true;                       
4 l5 |0 C. b1 x0 F                }' s/ ?1 \, o5 d8 L/ t
               
! C; D0 x2 V# T* B    } // end of class AuthorisedUsers# R. n- Q5 U# v% H% s1 o" T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  e6 s( L& b7 X$ ?
Shanghai - 2007, O1 h% _* H6 ]" D* O" U+ l* t, J! h
Assignment 2
7 M- r# W" X) M- l6 FDeadline 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)
+ e5 |8 i5 R: O8 R# |% q/ l1. 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.
9 d! Z* @$ ]+ }# ]7 rThe staff must be able to:: t* }: n0 W  l$ P" X9 [
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 N* N$ n& Q+ ~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." c2 Y6 g5 S: j9 U. x
 The interface should provide a menu so that the staff can:' V6 |6 N0 k: e: T( k( h
a) Enter the names of the two Java program files to be compared
9 S9 I+ V' Y$ A% o) J* V+ t% x9 N4 ~ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
3 L5 F6 H1 z6 D8 b7 h% M: D9 |6 b9 v** 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 ~) ]2 [* h5 V) K$ TBSA104 Business Programming – 2007: Assignment 2# F# @% Q& B" F" T
Page 2 of 5: u4 O- R) t/ O  m  I9 S# U
b) Print out to the screen all the lines of code that are the same
, s' S/ e" C) Z, V  h: R3 r/ p* h Include the name of the file and the line number of the code being printed for each of the two files! q2 ^1 M" e' h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 Q( n& p% n$ W, }7 i the name, username and department of the user
2 ~' }8 [' Y, C0 V* N the statistics of the comparison
3 J5 R; }( k9 X: G# i- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different5 @3 q/ M6 @  k; N, K  m
 the recommendation for further checking3 @. o5 C( |1 l% 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
/ a' U' R% y* ?5 N' Q4 y9 C the names of the two files compared
+ H3 B" s+ G+ h1 {d) Leave the program (exit)
; w! J- ?* j/ K* I  Q# OThe ProgramCompare class: (Total maximum 20 marks available): C& p( P8 W; ?; V5 n
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)
, [. y3 N: \$ e- n0 c9 Z; ga) provide an error message if the files are not found or there is a problem opening them
  s" Y8 T5 A# a$ {, Gb) compare each line of code
: i) l2 ~9 x! Rc) print out the lines that are the same
9 p; e) d! e. B- g" xd) count the number of lines compared / lines the same
) |$ o# Z% A5 `. s, `# S  R2 QThe AuthorisedUsers class: (Total maximum 20 marks available)* z6 u' D: b2 A3 ^% Y# C8 {
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)0 z* S: q: S6 H  M
4. Provide methods to:
/ a7 a( @: j; {# \3 U$ Wa) 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! o& n6 M0 x; W) ^! ]# Y5 F
b) return the name of the authorised user! _4 N% D2 A$ A) y9 ~2 j" H8 |
c) return the name of the department of the authorised user
# D# Z4 n2 R8 f+ V( RIndividual Data (Maximum 20 marks available)
; [4 {4 W  ~! g5. 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.
# S$ b2 Z% m6 ^3 _4 RDocumentation (Maximum 10 marks available)/ j4 S; A  S4 d" ~' c9 J
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.
7 f, {3 x$ V- b* K: B# nBSA104 Business Programming – 2007: Assignment 20 R5 T5 c$ h  ^
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ m9 M& K. d. A
不过你要翻JAVA的类库说明。你有下载没有?
; U- D5 H$ L% G2 C. z" i查询关于对比的函数。貌似关键字是contrast,还有compare% ~' c+ P- u8 I/ @
  s/ Q4 ]5 ?& C: Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -0 |- R3 \$ j3 x; Q( r( v6 U/ C
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
) y5 u) Y8 u0 k  {" a( X可以下载到的 是 jdk-1_X_0-doc
9 D( d9 Y& r6 n, T, Z7 N# @- P/ O2 z5 G9 u  N! X# y( |1 P7 ^) q, w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-4 02:38

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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