找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1873|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 |1 p* K/ ]( B, X # [! @7 p# }% @$ r) c7 A+ [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
+ Y3 e& w! V% R! m//  ProgramCompare.java         Provided by: DRS: j2 P* ?6 a6 E9 w
//
. |0 _: A, r, t' {" p//  Program shell for Assignment 2' g8 n5 e- z( B0 N  d) Q
//
) O6 u; F7 L" J0 A+ {/ O6 i//  Compares two text files line by line
! G$ [' b& Q6 K) w6 L  y( W//*********************************************************************
6 X$ X9 O6 c+ s* B7 u5 w' q2 i& O; J9 s3 a9 @4 Q+ ?4 N
import java.io.*;; b& D! C- |3 S) u* ?0 d: I4 Z
, ?$ z' e  j% _6 ^- a$ z/ A- i
public class ProgramCompare
- w* g" X! `5 I5 ]9 O{. \3 q8 Y, L) `. t
        //-----------------------------------------------------------------) H- n) @1 m2 F% ^7 s# i7 U3 R
        // Constructor, _( H' j) C7 V" {) b0 [
        //-----------------------------------------------------------------
% I) k) O2 ]9 Q: a0 V        public ProgramCompare()
5 R& a7 P, y+ ?; ^4 w% o        {
/ ?: e+ a7 g# h5 A5 D! f        }
$ a# g! i3 ^. X; j/ N7 ]3 l0 E# {8 w# L- j0 x' l' G
        //-----------------------------------------------------------------1 t2 |/ i+ R1 s* Y( N
        // Method for testing that class has been reached5 g: U+ F1 I$ d$ p- }0 Y$ E9 t
        //-----------------------------------------------------------------        6 o" _5 \0 h1 ]3 P- P* p! h
+ C+ }& g! \/ l: N7 }! x! k
        public boolean ProgramCompareReached()         : j* U+ X4 H2 D! i5 a
        {
: e2 z$ p% A( P% ]' x      try   |1 ~- s, W2 r  C+ W
   {         # Z) \, H5 D: Z  K6 O
                        , @0 q7 d$ t0 v* |8 P1 Y: Y
                //********************************************************************
- |. Y4 o! {+ q& R                // Try-Catch Statement is used to handle exceptions - such as file not found 8 P& W' }) A) a+ j, R5 r) r/ B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
7 I; D* S' L" H                // For more information see page 534 of the textbook' H# n3 L1 P3 K. ?; p( y  s
                //********************************************************************
5 N; X& F) u% D& [' Y                    
. `' H  M9 l# w6 ^; [6 @6 w; @        }
! J: m) Q, l  J6 \& P             catch (Exception ex) // Exception caught here and message displayed to the screen , A7 r6 N) G$ V& }, t/ @9 r
          {2 L- C$ p) c# C6 k
                    ex.printStackTrace (System.err);
- c* O. J7 N; V6 N           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 Q( R! i& q/ i% ]0 K/ u, q        }
7 A, |* u4 A7 i+ y" a                return true;
# t, J- i! u& z+ `2 Y        }
) H/ \* Z) y2 W" G- k7 h
- e1 s+ J7 @6 j% c} // end of class ProgramCompare1 F- k% t: I9 w
8 K4 h: j  d  ]6 }, @
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  x* d5 b( {0 R$ [/ Y/ R; e& x
//  ProgramCompareMenu.java    Provided by: DRS! R% x7 d/ _" ]5 v5 W% s$ Z
//. S4 A: f( i; L
//  Calls AuthorisedUsers.java and ProgramCompare.java
. \2 E5 }5 o6 D0 {% @//
) A9 g) H7 e# G; f0 @, u//  Driver shell for Assignment 2.- u; m% z, o4 M0 B. [7 _
//********************************************************************) A6 Q. ^  W9 K6 y$ S4 J
" V- E7 h; W  R, i8 y  p( c, b
class ProgramCompareMenu4 D, Q  i6 ?" B
{# \: g& K/ P" `8 g
    public static void main (String[] args)
8 O, `1 g$ f9 Y9 `3 H; e            {3 U1 L% B( h" ?& @2 b! y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable, ?! x  ?/ ~0 m0 Q
                ProgramCompare reached1 = new ProgramCompare();
, F9 }8 S5 V  P; i% Q1 w' t                AuthorisedUsers reached2 = new AuthorisedUsers();        2 V& o% C$ C" h# N4 p0 w8 T8 e5 w
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
( n, ^! z3 d: p; o+ y0 c( O                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        - G4 ~# z7 w. l, F* o" i
        }" t0 {0 o0 t' a: h1 s2 r
}// end of class ProgramCompareMenu
' P5 ^6 v( X) ^: ~' I3 h4 t3 f6 }( \1 y0 |3 B3 ?. r% V) o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, j  X: z# K' `/ f//          AuthorisedUsers.java          Provided by: DRS  O, y4 \, q; o9 Y& t
//               
/ b& b' ~" L( P4 U0 O! D//         Program shell for Assignment 2
0 j2 d% k% w! m" W//. y$ @5 X( `( j! {
//         Represents facts about an AuthorisedUser
# L, |  f. d0 ]" r* E$ J8 U; u; z) {7 }//********************************************************************5 l( w& [( f# z1 }4 d$ G5 e

1 W4 P% r" W: L: n& s" r: Mpublic class AuthorisedUsers
# c. F4 I! V9 `4 U    {! Z0 w) O- T# c* X# d

8 F, T, M) v- \1 a' K        //-----------------------------------------------------------------: r# \( L- j8 ~7 j9 I
        // Constructor
/ e* A) q' _) f# S! _3 N- @        //-----------------------------------------------------------------1 y, J" f, X! j2 L5 r# m

( W) W& A* C! F. N0 x& ?, E+ x" Q        public AuthorisedUsers()
* e6 R" z* k. h                {
" y2 ]4 h1 a# i; t( K                }
2 J$ b  C9 L6 S. ~: D! S
5 @1 K6 e6 E. L$ h7 t. ~        //-----------------------------------------------------------------% X: A  S5 O# l( z
        // Method for testing that class has been reached
/ s* o4 X& ~# }$ A" p( W$ t        //-----------------------------------------------------------------       
$ D( w3 C2 X, a. j$ B" c  V) n6 V        public boolean AuthorisedUsersReached()
4 C6 g/ h4 q: O  \0 h                {
8 O5 U2 g: \9 }+ u                        return true;                        ! L7 k& Y/ R: x! r; J, N5 ?" p
                }9 |6 @- c5 s0 ]1 E
                9 H! V+ l# E0 u! d) A- u7 G" k
    } // end of class AuthorisedUsers( R2 k% P- L9 _9 [3 V4 Z# ~7 x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
- a+ h- L2 J# Y, X2 T% _Shanghai - 2007
0 p7 J2 H% K) @+ mAssignment 23 K& V9 x" J% k/ 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)
  F0 r7 b7 ^0 E9 |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.
: ~* r1 y' F! f& P; K4 oThe staff must be able to:
5 y  }5 U, o2 z& ?  P Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
; [8 e( m* G; F" T1. 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.% J! d/ I0 `2 w1 W) i9 F
 The interface should provide a menu so that the staff can:
) u* Y! ^! s, a5 G0 M' X& I( ma) Enter the names of the two Java program files to be compared& h4 m2 e% x6 }! U
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% i/ U* w$ C' u4 s1 c4 C% \
** 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 F" E, ]0 Y5 ]BSA104 Business Programming – 2007: Assignment 2
2 B9 N1 F1 s! b" o1 @Page 2 of 5; q0 P1 B1 ?+ H9 p+ l
b) Print out to the screen all the lines of code that are the same/ P$ B' k2 S1 H; T5 s
 Include the name of the file and the line number of the code being printed for each of the two files0 J2 }! [, [% U% G% j
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
, ^9 D. v" d, X4 A6 |; m2 q& y& I the name, username and department of the user
( M% i. c7 t; l* E% A the statistics of the comparison$ x/ A* E4 X* f. B1 X0 \8 o8 |
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* H' I% C7 ]; G0 V0 I the recommendation for further checking, b  Z3 y6 ~6 q  f% 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* N. K: m( o( i8 [- N: G) ^5 i  _
 the names of the two files compared
# d9 u' [' {0 B9 ^% e0 Rd) Leave the program (exit)+ M! B  B1 m  y: C# m2 R7 q* \3 N
The ProgramCompare class: (Total maximum 20 marks available). f$ r' w) |9 i3 H* S
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)6 d# Z. \) a, [# @) Q4 c5 o7 E% T2 i
a) provide an error message if the files are not found or there is a problem opening them2 }" x* k$ Z6 D9 l9 v8 H' d" F5 o
b) compare each line of code
! z5 I7 j, }/ Z9 U( @* ic) print out the lines that are the same
$ d7 g2 p$ W; q! K4 kd) count the number of lines compared / lines the same7 e+ C/ t& [5 R
The AuthorisedUsers class: (Total maximum 20 marks available)  q* f! U1 s7 Z8 \, w
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)" a2 |9 _( h: Y+ ~$ q; k& ~
4. Provide methods to:
& a# p' Y$ e$ k9 S7 Z1 Ca) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match7 U9 l! o8 r' d
b) return the name of the authorised user
5 e0 @0 c1 X" f8 d! oc) return the name of the department of the authorised user
) A/ U2 b/ c/ sIndividual Data (Maximum 20 marks available)
" \( |% v# n$ {1 n5. 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.2 g7 d) |8 _' Q8 H8 a" S! e9 [
Documentation (Maximum 10 marks available)
/ O) z  J; `. U0 f: b4 S7 S+ `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.
* S8 d6 P/ ]& g+ ]" t+ J7 rBSA104 Business Programming – 2007: Assignment 2
, l' S, b8 p8 I$ K+ o6 o8 j+ bPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了- X0 \1 O1 R: D. q% T
不过你要翻JAVA的类库说明。你有下载没有?
2 f- G5 r2 }7 O7 V  ~7 X查询关于对比的函数。貌似关键字是contrast,还有compare) z3 A1 ]6 B- u. d6 P" D

( O) R. `' T# a9 D[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) _( J% p1 U# t- @痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, @! W2 P) X7 w  d: f可以下载到的 是 jdk-1_X_0-doc# _/ H% M: c$ ?& ?% ?% d" V
! V7 t  |! f6 d+ [
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-12-4 10:14

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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