找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1479|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 q- y4 \+ R, B0 [! \1 U- K) h1 t4 m' x- {' F. |! _7 Z! ?& t9 D- J
回复

使用道具 举报

 楼主| 发表于 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 D* \) G4 w% h9 ~1 i//  ProgramCompare.java         Provided by: DRS
9 S" z) o* S! h8 Z; n; K0 t/ D//8 Q! F' o2 \4 z2 _/ R; A+ O
//  Program shell for Assignment 2& i+ X, F0 G: V1 {) z& g- K' \
//! ~: H: V1 x2 S  t
//  Compares two text files line by line7 f( P4 }& k, s( s3 l! C
//*********************************************************************
, u6 `4 l/ M# a$ }8 q1 G6 T
. P* y6 w' s3 i+ a- Timport java.io.*;/ a1 C" F' o% ~" N
: l3 @* ^6 x( m$ z
public class ProgramCompare% l9 D% m" Q6 N: F; I7 e3 N
{
# l7 f% _: y5 V        //-----------------------------------------------------------------
7 F6 i  L" N* h1 Q$ S& ], f5 c& A        // Constructor9 v  D, Q7 b# T  j+ N* m; K" `0 X
        //-----------------------------------------------------------------
, G0 S+ u0 u. v/ F8 y* {        public ProgramCompare()3 }. m6 f6 `8 I% h
        {' O5 V# Q5 c/ E+ Y8 p. a, H
        }1 [' |9 I1 `" j6 o2 G0 D
0 s# s5 {. y6 M4 G8 N; p8 D8 \; k: a
        //-----------------------------------------------------------------
" t& b! H- {+ Y! i6 W( s        // Method for testing that class has been reached
; o  A" a' A# X  C        //-----------------------------------------------------------------        $ H3 R! G1 C# g! c% @

9 v9 Y  \; w* a) `: A1 B        public boolean ProgramCompareReached()         / {* O+ |4 d- w7 @/ j3 e
        {  d7 I7 U0 F* Q5 z/ w; o9 Y  z
      try - T) I7 D- {3 ~; [& ~4 w3 N
   {        
' L: e# g/ ]3 {; Y                        ) J. A$ q: Q" p8 z+ M
                //********************************************************************
0 Y) B/ @4 n- z# B6 X0 `) `% d                // Try-Catch Statement is used to handle exceptions - such as file not found / u4 g& A/ o- o( O6 ~, g
                // Reading the files will need to be placed inside a Try-Catch - just like this one!; m& K# q2 f" ~4 k4 B" W' Q# F
                // For more information see page 534 of the textbook, M3 V( c! R2 F, X5 l6 B. m+ D
                //********************************************************************
, T- E: X7 y! |2 B. H( A7 ~                     + }* S5 s, f4 Q3 x
        }
3 s! K1 I* d' Y% c4 X- R             catch (Exception ex) // Exception caught here and message displayed to the screen
, B- g/ u$ t* B7 L. T+ f4 V) a& H$ x          {- h$ o' v8 j& C: G; H7 _/ g
                    ex.printStackTrace (System.err);
4 ^1 O4 _6 U, D' N           System.out.println ("Error message goes here"); // Replace this error message with your own          & Q/ x0 B2 D. n% l' {" ^" b
        }
3 M5 R; H$ F4 l& T, ~, }- M                return true;- p# _; X  L% \1 U
        }
( O/ u. u) o7 N- [6 o7 k
% Y- F5 l9 _8 O6 }: B- B5 [} // end of class ProgramCompare
* X& h( `& H9 M8 V7 b" i" \$ {/ ~3 B  e9 Z% n$ ?6 F" ]+ N! V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ r4 ~/ i2 b6 e% k; w% s" d* U//  ProgramCompareMenu.java    Provided by: DRS
: C" h) w8 a' i0 a5 m//
! k! V- n5 P! z  G% j. n//  Calls AuthorisedUsers.java and ProgramCompare.java
6 _3 ?* `& L# G7 Y& n' B' p//; D" b" C% f3 D
//  Driver shell for Assignment 2.
) D9 Y; I/ A7 {, ~) r) }9 Z//********************************************************************! r- L, p; n; p! V. W4 i0 E, N$ _
6 Y) Z  e, f+ R; h; U2 S+ i* b
class ProgramCompareMenu
: k3 k  e1 x4 i. P{4 p( B6 W5 j) U
    public static void main (String[] args)
' W/ u4 u3 _" L+ ~6 i            {
, h* ^* F0 [& ^. ^* m# Z# U/ t; \                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable" @7 N. l. F3 Q
                ProgramCompare reached1 = new ProgramCompare(); , O$ t9 Z+ ~5 y2 o' N, m' j& j
                AuthorisedUsers reached2 = new AuthorisedUsers();       
% m' p- b& `. R& x                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. I' g# e1 T  u                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( x3 D8 r+ C8 r        }( J: P# R1 t. b4 k
}// end of class ProgramCompareMenu0 Y  X+ [0 W0 F9 W/ ^
1 p* \. V# q) b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, l2 k! D5 {/ O% P3 S* R
//          AuthorisedUsers.java          Provided by: DRS! c9 N, E' n& @2 K
//                9 \2 b8 X- O5 e1 I( Q
//         Program shell for Assignment 2
% P* C- q4 Q1 j0 N0 T  P//
( I. X; A. J& c  T( b# L( |//         Represents facts about an AuthorisedUser1 s! d/ D& q; N; W$ u6 c4 R- h
//********************************************************************4 P0 \! T) B( U* s3 T. I* {
; a' X; [  U' S& E- d! q
public class AuthorisedUsers
/ z+ {: I( _7 o/ g    {
% P0 d# n4 i) ^# M/ b$ W
) s# `0 H0 Q( h7 t- Z3 u        //-----------------------------------------------------------------
4 g. E  X3 \; B, n$ K) r' P        // Constructor( [  b: j/ ~. f6 n
        //-----------------------------------------------------------------
1 Y. k; b' X, Z! e3 l$ ^
( P  R& x+ C! w) T        public AuthorisedUsers()5 R/ `9 J, e# b; K
                {
' ^) c- A. Q. r) s/ O4 `5 q                }
* |) H* B" M4 R9 y9 R  l; _/ c
, D  y2 W1 H6 q* V; `) P# G0 E5 r) ?        //-----------------------------------------------------------------
8 \8 Y) ]* k" a7 G4 b& D5 J        // Method for testing that class has been reached
* |( l) ]+ U( V5 W# ~! }0 L, Z2 u) ^        //-----------------------------------------------------------------       
$ c2 Z- J& G' P# F" [        public boolean AuthorisedUsersReached()
2 v7 a( A4 G  f                {
0 W8 @* H6 Q4 Z- ]! ?- K1 ^                        return true;                       
" S9 g( [) n/ \1 g: H                }
0 Y) m, f5 o+ Z8 M               
, z+ Y# E- ?( E# y% b: ?/ Q. z    } // end of class AuthorisedUsers+ ^4 Z# Z* B' s& f3 F: _9 {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. v9 I  p- Q1 v* W
Shanghai - 2007
/ g" _0 T7 c1 m7 c( b! X  UAssignment 2" ~- p2 [1 g; r! n4 z3 B+ z$ i
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)
; d3 w" j5 }/ `. \) B* X7 i- U1. 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.
4 U2 A7 D" i% L0 C/ OThe staff must be able to:
9 |8 Y5 E- C1 }% k5 U+ z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ O4 z5 J0 I: m1 E: o, {1 |1 }. L1. 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.
0 i  z. \9 \4 N/ f& x The interface should provide a menu so that the staff can:. @9 a( o+ J, H% A
a) Enter the names of the two Java program files to be compared
# O" _1 S/ e4 U9 p8 b4 Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ w" d. B  n6 b4 O8 M** 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).
& D2 Q1 p( P+ rBSA104 Business Programming – 2007: Assignment 2
9 K4 z/ _. Q" e9 k3 RPage 2 of 5
3 |3 D- \$ h0 e. ~b) Print out to the screen all the lines of code that are the same1 y/ x2 K$ m/ o* V
 Include the name of the file and the line number of the code being printed for each of the two files
# i9 P+ ^7 ], ]- l$ Tc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* \2 L# `4 c, i4 E: b& U the name, username and department of the user0 U) q6 j- _& a) d: w# Q& x
 the statistics of the comparison
% o7 |# z) I; i- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
; I& M; f5 P1 z* n the recommendation for further checking7 S0 ?' Q; E8 ~9 j, O& V
- 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; X% S; Q8 ]; G0 b, ?
 the names of the two files compared
$ Q* `, b7 p0 i( Q( _9 Ad) Leave the program (exit)
4 U8 \0 W& u+ y  {; B# XThe ProgramCompare class: (Total maximum 20 marks available)
# K+ e- n& ~+ e2. 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)1 D* C5 T: W. q0 m! H1 l
a) provide an error message if the files are not found or there is a problem opening them% Y2 d$ \2 @, q2 k2 c
b) compare each line of code
% S+ S: g1 ?. xc) print out the lines that are the same
  x( [$ i8 p( w% ~4 b5 Qd) count the number of lines compared / lines the same, R# Z/ o: y8 V) p& L9 q9 d; ~0 J/ r
The AuthorisedUsers class: (Total maximum 20 marks available)* }: v* R, O% K( w7 i
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)6 H6 t. e; v- U0 o
4. Provide methods to:! K& M' T" j# j: V' T" o! B& Q7 O0 |5 B
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
( w* W" c: b  ]$ j+ ~( D4 |b) return the name of the authorised user. a2 R6 Q  |7 |" S% d$ w
c) return the name of the department of the authorised user- o& J2 U! J& k. r
Individual Data (Maximum 20 marks available)0 j* P. s# f; _9 c( G& N
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.
% B' S/ h0 g+ U/ {- v  D+ xDocumentation (Maximum 10 marks available)/ V7 ^; ?) L& 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.8 Q3 l3 b* w; {1 y& ~
BSA104 Business Programming – 2007: Assignment 2' `+ T2 u' {- ?6 J+ @; P& V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了( g$ h, Q" v$ z/ `) c5 H' a- g4 h
不过你要翻JAVA的类库说明。你有下载没有?
% O; v/ V/ z$ }9 F/ [& N4 P查询关于对比的函数。貌似关键字是contrast,还有compare: Q3 Q" {+ I2 @5 ~# a" m8 K

2 G' y: c8 D5 [% m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
. p/ c6 k1 H9 X- f  J) Y. `  {痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: U& O( M. [4 K. s! t
可以下载到的 是 jdk-1_X_0-doc- P" O' k2 f1 V( i' T3 h! M% Z. E
) G, V* a- B0 d0 u1 U- G
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-23 12:32

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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