找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1199|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - _3 d6 p, m# }: M+ s0 t- A1 v, C3 F; i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! S, F6 M, `6 H+ A2 v; ^
//  ProgramCompare.java         Provided by: DRS
% k9 Z2 @# f- G' C5 g$ @. K//& D- k. ^* U* P/ [" h4 @" |
//  Program shell for Assignment 2
% k# n  L% B2 L! l//( e2 r" L* u% Y! D1 T6 X7 w
//  Compares two text files line by line6 g; V0 K" b! ^7 `. f
//*********************************************************************
9 d3 V4 K  I/ _! u- ^( a0 C+ I* l0 H+ p6 H( E8 B
import java.io.*;
4 f- b$ \  E* F6 W7 \8 n* F& U
3 E6 t1 r. Y! Q8 p7 w- c3 \public class ProgramCompare$ }$ J4 j1 P9 T; r* \* f; I2 N; K3 Q" }/ Q
{4 I2 R% {6 B- l. T2 y4 Q
        //-----------------------------------------------------------------8 K, R6 c; Q" `
        // Constructor
) e1 {2 m- {3 a) ?9 N8 U        //-----------------------------------------------------------------5 _, r1 x. j* W$ O' N( V2 q; _
        public ProgramCompare()
) A# w) g( S3 D; ?0 G        {
7 E$ A- ?2 F8 u8 r7 Z* o% E# G, ]        }
! C. o! c6 J, g  v
! m, w4 Q; P2 x8 c. `7 ^& m. T        //-----------------------------------------------------------------; w' z1 s6 h9 i( v0 N4 e* S6 h1 p
        // Method for testing that class has been reached7 h9 G& K' B4 c/ Q0 P/ K
        //-----------------------------------------------------------------        9 ]. d5 L; }' l4 n; I

4 h. d* q3 Q! ~) @7 d( D0 D9 p- E        public boolean ProgramCompareReached()        
* p. i/ J6 C' [/ C$ d& }7 t/ o        {
6 o! }* Z& H6 d4 q/ ?      try . [5 i: X5 f$ Z. {1 u
   {        
0 V/ p- {6 K& f, u! F                       
. t& Z) h( M! n7 [; _                //********************************************************************
' l* ^' U7 ~, ~, G3 h5 r" p                // Try-Catch Statement is used to handle exceptions - such as file not found / Z/ H& u$ p: d) u5 o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!8 {" n! S4 t' z+ d' I$ N
                // For more information see page 534 of the textbook9 Y% i1 c4 s% y) T! W
                //********************************************************************
* n6 C4 T3 P7 }2 ?4 A                    
; \0 [, ^$ I9 w& y8 u        }% G! ]. S6 y8 a" c6 c- O' E2 w9 B
             catch (Exception ex) // Exception caught here and message displayed to the screen
+ s% _% M# K! @8 g5 g6 T( h7 f          {
6 z$ s4 }; x0 ?3 b# @0 b1 O8 Y                    ex.printStackTrace (System.err);" n4 K5 i! E/ V
           System.out.println ("Error message goes here"); // Replace this error message with your own          / U; H+ |1 _( u# G7 v
        }
! Q* @& \, l2 y3 x9 Q                return true;* C* y  z" Q# H
        }
2 n6 @( b% i, E, a! `+ ~. E% n: Z: [5 z
} // end of class ProgramCompare( @1 x4 d  I9 ?& |

! J; p% O# v! \1 p. D4 p6 e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
3 L) k8 B4 @, n7 ^//  ProgramCompareMenu.java    Provided by: DRS
/ Q. j" x) ~/ V/ S# O//3 [- I, t; ?  e: }/ ]
//  Calls AuthorisedUsers.java and ProgramCompare.java
5 }9 W% y. G- T6 T% w//) ~4 y( D1 n9 u( r
//  Driver shell for Assignment 2.
% A4 U5 r- o* ?1 Z3 U# H//********************************************************************3 E9 f0 u" s8 M# F: I

8 }# z& S' ~4 v3 u' Oclass ProgramCompareMenu
9 T9 c" r4 `7 i1 \. ?{
( ]; n1 H9 K. a    public static void main (String[] args)3 ~) H5 m( O( j( v$ ?2 v; T" D
            {1 f0 M1 M0 r0 C: J
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; p$ }0 G- V9 q  ~; |, y0 W6 n
                ProgramCompare reached1 = new ProgramCompare(); & x7 u6 L& V% U5 `" T* M
                AuthorisedUsers reached2 = new AuthorisedUsers();       
0 ^: p5 b& D2 Q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 Z' I4 y2 C; \$ n% D2 d- g' o
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 i' d8 M9 z" U5 ]        }
8 r. R: R$ C  U  J' p}// end of class ProgramCompareMenu& y. s. }  A' @6 z
! l! x+ J' O- [' E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 O' x! L" Q( }& i7 D
//          AuthorisedUsers.java          Provided by: DRS. t" q. x5 R& Y/ i- P# \, O
//                1 X* b% f9 J$ f( _) b: \
//         Program shell for Assignment 2
- I7 i# F+ f" H$ b. z//
# p2 [3 b. ~* P/ u' m//         Represents facts about an AuthorisedUser
# n. h% R7 z& Z6 t//********************************************************************$ n) w) k1 d8 B
' L1 [& G8 Y, i2 R. S/ ?
public class AuthorisedUsers
" \5 L5 N6 L  T# J9 k6 W$ C+ o    {
: w0 a; k6 ?6 O& t# r3 ^" F& y& Z' ~: a  J4 Y' w1 ]) g, H
        //-----------------------------------------------------------------. a# N. d; D: x" J3 W
        // Constructor
+ e" _( Y9 g5 O' u- B        //-----------------------------------------------------------------; @2 y9 K9 E2 {. W* R3 q% ]

* D) l5 U& E0 ~9 P        public AuthorisedUsers()
* l( Q9 `1 H. G. `- b. z                {
) H, [+ _# H# m! e5 g                }
* s7 `' F+ u/ W
) y2 U5 B9 f' {- {- o$ o4 B        //-----------------------------------------------------------------3 Q7 k0 ?& g8 J5 v- ?
        // Method for testing that class has been reached
% G) a5 N/ B( e- X( E        //-----------------------------------------------------------------       
0 P. H5 X2 Z$ Q        public boolean AuthorisedUsersReached()3 m7 y! w  {8 N: o# U1 v
                {
( X* N6 x! w' Y% M5 [                        return true;                        5 L* S  G, K5 O! }& ~: U5 J
                }+ K" f0 Z8 y  f# R& G; j
               
& d; o7 f9 }# @1 r. p$ {6 J5 m    } // end of class AuthorisedUsers/ s5 r( V3 Y6 o8 J8 a* D4 o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; m* L/ x+ S: ?* K5 H! W( LShanghai - 2007
' m* N0 G% d6 w3 ~4 @Assignment 2. F7 v+ W8 t' n: R6 W* A9 z, N( 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); w$ Q  k# N8 ?  B4 J8 W# F" N
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.
4 R; U1 W8 }4 p0 iThe staff must be able to:
5 a3 _4 t" P+ E( E8 w Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 g7 p2 F' k2 j. J/ l+ s# S% 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.' C, P1 }# M* L
 The interface should provide a menu so that the staff can:
5 y) Y9 w& ~2 fa) Enter the names of the two Java program files to be compared- I' V4 p- r1 V" L
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' |7 i8 F% j( j# P* h6 a, g* j( n0 k** 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).
! p' m2 A% t6 B. S" E4 l! LBSA104 Business Programming – 2007: Assignment 2
& E/ A8 e8 ?$ O/ [! UPage 2 of 57 H7 E' \" K: ]) m
b) Print out to the screen all the lines of code that are the same
4 l  i% N) W; P: P/ x& i Include the name of the file and the line number of the code being printed for each of the two files4 G: O' e$ P" ?5 P4 I! P" {) t
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, H! j, b% L( {7 H6 A  u4 p5 {
 the name, username and department of the user) f* D" l6 ?- G# J
 the statistics of the comparison- V; t7 N# h4 f0 u3 |& B5 k
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different& c: w0 i* i  r8 |- {
 the recommendation for further checking: D1 B5 v" V6 I/ P# 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) ^9 v* `* \6 _% ]) @( p
 the names of the two files compared0 }; r4 {+ W' V9 k: a; l5 j$ R. c
d) Leave the program (exit)7 U7 _. c& B3 G$ a* v
The ProgramCompare class: (Total maximum 20 marks available)
% V- `, H( L% H" B( z4 i# w2. 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 D$ y- [1 a/ [; x' ?3 m
a) provide an error message if the files are not found or there is a problem opening them
  [" u4 |" r9 Q7 |% Mb) compare each line of code
* e. ?: z5 ~3 V4 ec) print out the lines that are the same( N8 }  `$ R7 D2 y! |+ |8 B: r( }
d) count the number of lines compared / lines the same# q" \, x! U/ Q# U' _+ f
The AuthorisedUsers class: (Total maximum 20 marks available)
/ g, x# b, I; M3. 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)' Y; c6 |7 ~8 L
4. Provide methods to:
5 Z) f" L' k+ a; F2 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
2 {- Z$ u( P: ]( u) x/ J7 Lb) return the name of the authorised user
) T7 {  g! ?3 ]( ~( uc) return the name of the department of the authorised user
! v  I+ Q' N. m+ \( WIndividual Data (Maximum 20 marks available)
& [0 E( W7 L1 X$ j: A5. 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., k% M" W7 M( l% @( N
Documentation (Maximum 10 marks available)! }) ?8 d2 R# [9 t5 w2 p- }. N/ n. Q
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.
. _! _3 a8 O+ ]8 y" HBSA104 Business Programming – 2007: Assignment 24 h" \! I8 K% K* F
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ O8 b: C7 `9 j& x# D; |不过你要翻JAVA的类库说明。你有下载没有?
1 B9 K! b, q+ Q# e5 h查询关于对比的函数。貌似关键字是contrast,还有compare- Y; x* f* \: R6 n6 n0 ~

( S* z" O' i0 U, i- e* \# }7 E[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -0 s/ ?; n/ r% n: m) w+ ^2 G
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ B6 f/ j/ Q4 m  \& T可以下载到的 是 jdk-1_X_0-doc
+ L4 ^4 B# v7 }# s1 m! x! a9 l5 Z! O8 ?, l( C3 F/ h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-16 15:39

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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