找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1063|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' z( y8 Z5 S; w/ f& } ; o" y1 [+ z3 Q5 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 | 显示全部楼层
//*********************************************************************
' R% E- k& P+ o! t5 D+ z//  ProgramCompare.java         Provided by: DRS
. n# T- |, O, O$ w0 ]8 V% s) C' b//* G& b% `/ G2 U. d) A( z  x* q% p
//  Program shell for Assignment 2& z( o0 e/ Z$ [9 t
//
1 Z/ T2 h) h+ q% B1 F//  Compares two text files line by line0 h" o. W( H, o
//*********************************************************************- P9 i4 ^+ X) t! [/ ?
6 W/ I4 t" R1 p7 u9 u& v  o) a( \
import java.io.*;
3 b( j& ^3 u. v9 t, j' V% r1 S, `' g2 G0 u
public class ProgramCompare/ T/ J& v* S" p) a1 a2 U& ?' f
{( V* v& n2 U4 s+ ?6 |% z6 U1 }* g
        //-----------------------------------------------------------------
6 Q3 r, x4 W+ r- p( r% S        // Constructor  F: ~+ g8 e/ ]9 w' U& a
        //-----------------------------------------------------------------$ O, }- j1 D- n9 r. T
        public ProgramCompare()+ Y: Z8 u5 ]/ U% v/ Q# b- h' ?6 V
        {& m1 w3 `8 `0 K+ F- R
        }
7 o: G  E1 j9 K1 y8 T9 V
$ S  X' h- E4 ?1 @9 l        //-----------------------------------------------------------------
% s. B/ D/ {! [: h) F& f        // Method for testing that class has been reached
3 f$ G0 T1 o0 T5 \4 W        //-----------------------------------------------------------------       
. |$ m9 I) P9 T6 l7 H0 k6 k8 f
7 C* I3 _9 a  w0 h5 B; O+ B9 c        public boolean ProgramCompareReached()        
# d. D& `1 d+ h( j# t( V0 i        {7 P  H8 b  l; B) v, f% ?% l
      try # B) F" S6 x1 u( `( T6 q& e
   {        
, c! x" Z1 t9 x; z$ \# w& K                       
! ]* `, h+ q) w4 r8 b                //********************************************************************
5 W5 n  s& ]% \' q5 |( |                // Try-Catch Statement is used to handle exceptions - such as file not found # s5 l+ e( e7 M9 i+ r; Q
                // Reading the files will need to be placed inside a Try-Catch - just like this one!. ?- V6 K6 f! o: Q( i
                // For more information see page 534 of the textbook8 A( H- [2 `" k! _" _/ v
                //********************************************************************
( E1 ]- ^( q/ ^5 z                     0 t7 ~, c/ s% E8 h7 M
        }
) m7 e2 T' x+ ^2 _& }, R             catch (Exception ex) // Exception caught here and message displayed to the screen % G3 B. r, F: G  f, U" h
          {
$ K6 x. u( P- M7 Z) q9 _                    ex.printStackTrace (System.err);
& A( u% x, B/ n' Z( A, h% ?8 S; E           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 ]) _. Y) F% z2 O% w        }6 t! o: G2 d; @
                return true;5 l& O0 t' T6 k0 [* C' [% h, c; T$ K
        }
' b2 H6 I( p7 v3 p) c
! Q$ z% ?- c6 [( g# F$ D  A} // end of class ProgramCompare
- g, p$ f4 a" x  Y( k* `/ V- i# P  F+ s6 u( H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; P; ~# x# a0 ?% J
//  ProgramCompareMenu.java    Provided by: DRS9 i7 a3 u( {+ K! A+ D* a& ?( }
//
9 q( D: d) h: m$ E//  Calls AuthorisedUsers.java and ProgramCompare.java4 X- e7 f* c, a4 O# O. O' T: g$ Q- T
//; z% ^9 {4 P6 [# z
//  Driver shell for Assignment 2.& f& N9 X; ~) F% a& w* x
//********************************************************************9 A; z4 V7 O. p: Q% w

0 x  Q1 Q( d0 E/ W) f( Uclass ProgramCompareMenu/ M( S5 A( m0 t& }
{8 W' x# z+ o+ o  M/ X
    public static void main (String[] args)
4 H7 z: F2 F8 O( j# t! L8 h            {
; }$ _. Z7 B8 g2 C% x. m                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
# ]8 ~" H5 W/ v                ProgramCompare reached1 = new ProgramCompare();
8 c' Y! I# S( L2 r                AuthorisedUsers reached2 = new AuthorisedUsers();       
! }0 [( a# g7 E; Q0 k! N                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# d+ {: ^: h' }                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
, s" N2 {, b$ n( W2 O        }
: m: H; h) L' |/ [% }* _0 Q}// end of class ProgramCompareMenu! y' ?: m9 j7 }% ]
+ S# [/ S7 W2 y; s8 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 R+ ^2 B% ]* m# u//          AuthorisedUsers.java          Provided by: DRS6 k. ~+ ~* [; L+ Y7 Y+ I3 S
//                & [7 i; \& F) D( ]  U" \% P
//         Program shell for Assignment 2) O4 `+ d7 j" d! s* [, p
//
2 ]% K+ Z# s7 I5 ]& L7 z& m; e" `//         Represents facts about an AuthorisedUser2 _+ H6 s7 G4 E6 D" ~- ?2 S% T5 ^
//********************************************************************
( c: U, B* I+ I, B9 n9 B
9 @. R) R& U& Epublic class AuthorisedUsers$ Q& V$ b! z4 G, Q4 ^% O! N. Y
    {
6 R8 d7 d# L1 d+ D0 n) R& s
% ~5 Z+ j% a3 V- n7 l: F1 g0 X        //-----------------------------------------------------------------
9 T8 t- Q7 F1 K8 V4 \        // Constructor+ b- P( m9 U3 U
        //-----------------------------------------------------------------
4 ^, S' P) K( T$ v: F; B, v6 W( V! \, F/ ]- y3 y# A# W, s
        public AuthorisedUsers(): L  e( K& Z5 T7 u
                {: {$ F4 Z& b! t5 M; @- o
                }; g# e" E( W$ K/ f
! S9 {% \1 H7 B8 w" P6 k  e5 l* j
        //-----------------------------------------------------------------" @6 Q: I( i5 Y7 {" {) a4 S& e
        // Method for testing that class has been reached7 _" r1 I/ h6 L
        //-----------------------------------------------------------------       
8 o5 s) S# a' c! J3 f3 ?        public boolean AuthorisedUsersReached()2 y: f5 g( n0 d$ b( e) N
                {
5 K" }7 ^0 p# p                        return true;                        # b& f/ S# L# B+ A
                }/ h& R. K4 C9 F: K
                # j2 U: Z" ~9 ^, a0 ~- d
    } // end of class AuthorisedUsers
" {2 i! X; o9 i7 G7 l6 W. j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" Q( Y1 P6 \! H3 T  WShanghai - 2007; `. q& r$ X; F* i
Assignment 2$ m- Z7 I7 z8 J
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)! t- X6 ^( S$ v: b
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.
& X, \0 i* N' n/ L8 |1 X6 I) ~The staff must be able to:- N3 k: O7 M" M
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# W5 D/ y/ b3 L8 S/ i1. 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.( S7 Y& M0 r0 W$ M. I6 m$ T: G
 The interface should provide a menu so that the staff can:
9 L- N9 g# B1 N+ ^! Ta) Enter the names of the two Java program files to be compared2 e9 G5 j+ y  x
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( [; s5 ^) b% N7 \- @
** 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).! T/ v- N& S, Q
BSA104 Business Programming – 2007: Assignment 2
& {2 W6 N" \) o1 b' ZPage 2 of 5
1 P! o% h- C" y( g/ t; Zb) Print out to the screen all the lines of code that are the same# m% X8 X* _- |) M) l
 Include the name of the file and the line number of the code being printed for each of the two files
* E) S! `: L, u& q. |- Fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
8 U' L; B: [- i+ }1 N the name, username and department of the user
& }7 v( O5 T  n/ ?: A the statistics of the comparison
; u' p8 G4 z" y  J# D- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 \6 V4 Z' ?) T, e
 the recommendation for further checking
* E8 f; ~5 D, Y) B6 ?- 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( Q4 E$ O( G. v; [( d- R
 the names of the two files compared/ V* M3 R; e. [& K
d) Leave the program (exit)
6 z7 M+ U0 Z& r1 V1 m7 @; E9 T' rThe ProgramCompare class: (Total maximum 20 marks available)7 S$ t. A# X* C" [( q
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)& h6 L4 t' D/ v/ W- o
a) provide an error message if the files are not found or there is a problem opening them) P. _% L7 e7 v( G& Z$ S* n
b) compare each line of code
* G  C0 o8 f# }" L6 _# _c) print out the lines that are the same
9 p' }8 [9 L( R. ]* @  R7 Ld) count the number of lines compared / lines the same+ f4 a3 C+ M. O; x/ U7 C
The AuthorisedUsers class: (Total maximum 20 marks available)
9 p6 a% R* w$ j  w( X6 l, r3. 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)/ b# P. C; p$ [6 [6 W5 Q) ]
4. Provide methods to:
# i/ Q& R& a2 H) u9 H6 W! h, X9 t& ha) 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
0 h" P* y+ @, L) E/ u' c' Bb) return the name of the authorised user
5 B% D$ Z; t2 A  P0 N% \: ^9 j! }0 Sc) return the name of the department of the authorised user+ z' k2 g) b. x; M; s
Individual Data (Maximum 20 marks available)
5 F0 @2 N7 T. y1 F5. 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.
5 O) Q& @9 M0 n; b; ~& x$ z! oDocumentation (Maximum 10 marks available)
  N2 G0 B/ M2 C7 D) p: Q" d/ q6. 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.
4 B, m( h8 l, a% I* hBSA104 Business Programming – 2007: Assignment 25 c: r5 {+ ^4 j7 V/ ^+ u
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ Z  i$ v) e  W7 y0 |不过你要翻JAVA的类库说明。你有下载没有?
; g2 U/ T( Z+ l* U* s: u- E查询关于对比的函数。貌似关键字是contrast,还有compare2 L, f0 p. R! Y" }2 S9 [, O+ r1 h8 `
0 U( @# j7 ^, O# w) O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 [, T+ e! y+ f: ^
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ k5 W' [& a% ^+ R0 O" y可以下载到的 是 jdk-1_X_0-doc2 F: A! ]& b; n0 ]) x% H$ L
& n. b3 s% Q/ S$ y4 {5 k' z9 ~
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-17 02:49

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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