找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1365|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& n0 A: O: e" [9 K5 q0 x' L" J- X, L & |7 L8 Q% f' v1 t8 {
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 E. c' J0 K. K7 O
//  ProgramCompare.java         Provided by: DRS
! Z, f1 G7 L% x1 h; |//0 M7 \; t5 Q6 g  r0 y& t# ^
//  Program shell for Assignment 2
7 w# v0 m9 Q5 }//
! \: Q# V/ a5 e  _* F//  Compares two text files line by line
; b8 q2 q. i* h- t" X1 U# A//*********************************************************************$ T, }* {! s% P; M( c( n# n( S
, [& x4 Q" m# G6 C( `- e& h
import java.io.*;+ ]/ a2 c( J( p0 W$ k1 u7 {
1 q5 l! ~/ p) w/ K
public class ProgramCompare
. S3 Z- v8 G0 t1 I3 D) d{& }+ C8 p5 m# o  p; K
        //-----------------------------------------------------------------
4 {# j) P& I4 Z8 h, d4 J        // Constructor
3 x+ t9 n5 q/ r4 J        //-----------------------------------------------------------------" X2 M6 o8 @3 b0 }* Y5 t1 Y
        public ProgramCompare()
& a8 I4 I# w# K! k        {
; f6 B, u5 x6 j        }
. c* o# C6 y. J4 }
! u# P" M& s8 t        //-----------------------------------------------------------------6 k% ]+ y3 S; q2 h0 X, t" G
        // Method for testing that class has been reached3 i& \& t  ~% w/ l& \* Q6 g" m
        //-----------------------------------------------------------------       
4 ]' o5 X$ j' S0 u9 V. C$ ~
3 o: S; x# b( F# S( l        public boolean ProgramCompareReached()         ' ]$ }: \5 e) P7 u9 @
        {
* v! Q' h% J8 w! }& p& x      try
2 X+ w: \0 s0 u/ D8 J   {        
1 a. g* W- R" {- _" D                        * M( s$ ]# |  l, h% e- I
                //********************************************************************
6 b! c/ k2 R3 `( K; E                // Try-Catch Statement is used to handle exceptions - such as file not found + b  {7 _4 K9 N3 I2 S- h; G) R
                // Reading the files will need to be placed inside a Try-Catch - just like this one!7 r) d5 D) a4 n, U2 a
                // For more information see page 534 of the textbook. s/ x* N3 {! s- v% ^! X) `  F. A
                //********************************************************************# d% u* v1 v: i+ J
                     ) L- U) {7 S! I6 g& o& Y
        }% T. e  Z$ J- u! O" [6 t
             catch (Exception ex) // Exception caught here and message displayed to the screen
6 T; K! c4 J9 h- Y0 Q& j( k          {# k6 y2 y" Y. k  E- i4 o
                    ex.printStackTrace (System.err);
( p$ x! j; }9 u8 m5 f, e3 Y" a' d           System.out.println ("Error message goes here"); // Replace this error message with your own          1 M# S! _' l* O. h" l. e; Q( l! k, t
        }/ s- U1 s/ l+ m* O
                return true;, p) \/ n% A9 V7 {+ o! C- e$ K
        }. D* h; D$ {3 M: E$ v* G. C

0 x3 Y  N3 |1 z! {} // end of class ProgramCompare
' G9 G5 F, ~( {" j4 @' b/ x8 \, Z6 \0 Q6 s5 Y7 `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
5 f  ]( a5 c* J9 v: P, E7 u: h//  ProgramCompareMenu.java    Provided by: DRS# x+ @$ `/ O" B
//
* O) Q3 o# v$ S; C//  Calls AuthorisedUsers.java and ProgramCompare.java
# Q  `+ k6 r9 `//1 ?6 c9 J6 S+ k; h# E" p
//  Driver shell for Assignment 2.
! Q& @( T3 z% x5 s6 v$ C4 C//********************************************************************( z2 o  \1 ]0 ~) [* I2 [1 B

* j/ B1 s& E( y* l) w1 U' l8 w% p4 Mclass ProgramCompareMenu
* o% k8 h4 z8 o+ Q{
& U% W! D! X2 a* ^    public static void main (String[] args)
1 k; F9 q; h+ K  v$ _* I% R            {
. o+ r$ w6 |+ b+ g3 |  o& X                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" I9 |9 ?7 v. |                ProgramCompare reached1 = new ProgramCompare();
" v8 b8 q1 R8 }8 i                AuthorisedUsers reached2 = new AuthorisedUsers();          t8 j% g, P# ^2 X  m5 f; |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 {: w  e$ s! B; k0 `! |) v% c- l
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" `( q' w% I$ j: f        }
) o$ k1 s, L3 c) z8 ?5 Z}// end of class ProgramCompareMenu
; z' k7 B/ j% l+ e8 r
* A3 p4 K1 @. u7 \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, b* e3 P# \- B) w5 k$ m" u2 v5 A//          AuthorisedUsers.java          Provided by: DRS) N- t( l' ?% [! i
//               
6 B8 B, o- G/ @//         Program shell for Assignment 2
; E( S' F: B1 y0 g2 C* |# P% e5 G# W//
$ F% i( X7 l5 J: e) k, [" u5 a//         Represents facts about an AuthorisedUser! E, v3 C6 T/ p; ?3 d+ @
//********************************************************************" Q) ^& p7 g: L: H8 J
0 w4 ~7 k, K" D, T4 \
public class AuthorisedUsers
' N7 K5 b3 k& e1 q" l) O    {
- }8 H% D8 f# T$ L, p# {9 ]
; q1 U& ~0 r+ U0 Y8 L0 I" @        //-----------------------------------------------------------------% t% Z' r$ X  N8 ~
        // Constructor
5 I/ `2 k) Y& e- K2 M: S/ D3 p        //-----------------------------------------------------------------
" ~4 m# ^2 P" k% d6 T
0 f# W; F8 w2 G. T: b( J# g& P        public AuthorisedUsers()
9 G  ]5 Q6 C7 v. ]- H; k                {% L: [/ z4 T  c4 T
                }9 g3 b- m- W3 t$ C0 J
: f, n% X& C' i
        //-----------------------------------------------------------------
. j3 N& `) N- A# R        // Method for testing that class has been reached
2 v8 x- `1 D4 z8 K0 v7 E        //-----------------------------------------------------------------        & m1 d; N" L# v" P$ \6 }. M3 W
        public boolean AuthorisedUsersReached()
; y2 ?9 `1 |( E) X7 L                {' v* F) B2 B9 G
                        return true;                       
, T. w( C! m$ o% x# p; n                }& k1 _  G9 V* X) M: [4 `& O9 ?0 O
                ' A, O8 n" E: f8 L0 c
    } // end of class AuthorisedUsers$ y6 W: |% i3 H% G  t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ o% o3 Z; K  ?. C: MShanghai - 2007: y( w+ n6 C- w; N1 ^/ F9 Q
Assignment 2
2 F- x8 e) t; N. G8 D1 hDeadline 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)
7 o8 M1 F6 S" o# P- V. f" k: s1 ~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.9 O+ ~! V4 d) _# ?- V! o
The staff must be able to:, m2 i* C8 Q9 `! @1 q$ U8 l
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., b' s! R4 u" _- \5 S" T" p% Y) V) y
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.
7 k3 b9 @, l$ i/ f The interface should provide a menu so that the staff can:
2 a, _* k' n2 [! r( Z' oa) Enter the names of the two Java program files to be compared+ |1 Z- Q* o3 D$ }$ P
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 c3 M7 S9 n- ^4 _1 t% v  Y
** 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).
/ I2 E! a9 J# F# }6 jBSA104 Business Programming – 2007: Assignment 2% {6 y' y2 B$ O; |& t5 F6 d
Page 2 of 5
! U, w" @1 W, g  \1 ~9 Xb) Print out to the screen all the lines of code that are the same
; A5 K) n( H1 o8 D, A Include the name of the file and the line number of the code being printed for each of the two files
. _& o8 V9 H2 e! Y5 f1 Gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared' T$ z5 F% `( \, [- A
 the name, username and department of the user
3 g# s1 s# e0 ]! W  a the statistics of the comparison
) H7 h/ Z) K! j9 M  r7 t! F- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ c$ J3 Y% _- ^ the recommendation for further checking( f/ p4 n8 B4 f! ^7 e
- 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% M4 q2 M6 z1 J8 U5 H
 the names of the two files compared
) ?8 M1 X. `8 k8 x1 Xd) Leave the program (exit)5 E6 O' J# e2 t7 y0 }
The ProgramCompare class: (Total maximum 20 marks available)3 M, d) {% J2 E% v/ F
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)% I4 s$ Y+ X5 Y5 t6 N( Z. \
a) provide an error message if the files are not found or there is a problem opening them& v9 ^, ]4 H9 F  X7 ^+ `
b) compare each line of code' V# N3 j4 X! X0 q. `0 J
c) print out the lines that are the same
3 |9 z& O( \( od) count the number of lines compared / lines the same
1 S) p% A$ q: V& [* hThe AuthorisedUsers class: (Total maximum 20 marks available)
& v- z# G% u- h) H, U3. 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)
( l3 w# |- W. n' W5 t% a4. Provide methods to:8 R; S0 w# ]4 @, m6 i
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 match0 W$ O) k3 g6 F" c: w
b) return the name of the authorised user
' @+ y0 W4 ?+ U9 P8 pc) return the name of the department of the authorised user" S8 S# R$ n( V2 L3 m: Y+ @
Individual Data (Maximum 20 marks available)* a' M, B! n6 o! B
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.
/ r, J" x3 p+ e, TDocumentation (Maximum 10 marks available)+ w# X7 ~4 R; r2 E0 I: a: D
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.
) z( S2 _0 k  G8 TBSA104 Business Programming – 2007: Assignment 2
; C7 I/ v6 z  i# @  j5 c. @Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 ]) E& z" ]1 b" w$ |* o" {1 P
不过你要翻JAVA的类库说明。你有下载没有?
' K$ G6 m$ j! ?) H1 k2 A. J5 R查询关于对比的函数。貌似关键字是contrast,还有compare- G& C4 v" k4 H, b2 ~; ~

* c3 b# v# c, s, D6 s! ?9 h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -) y4 ?- E3 o* E, D8 s0 ^4 V# A0 }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。( s: a. C( @# g- j( O* J6 u) _
可以下载到的 是 jdk-1_X_0-doc
2 U  {0 ~7 {1 ]" E% x- {2 n( |" ?* n# _1 B7 D1 ]7 h3 Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-8 07:11

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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