找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1309|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) A( R/ U$ R8 g/ e . `5 D d- e. Z6 z
回复

使用道具 举报

 楼主| 发表于 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 {$ z* A+ w$ Y# v  @/ f//  ProgramCompare.java         Provided by: DRS: {' z% [$ O- Z- S
//
2 t" H# g$ K; o9 D7 @, I/ R//  Program shell for Assignment 2
; b0 ]3 e9 F; M4 S4 o* Y//
7 ^  Y. k. x1 T' k//  Compares two text files line by line
- \& q# ?0 |$ K! U  O//*********************************************************************5 V. l) w1 r3 M6 l; @0 {

4 t4 {0 ]2 f, O0 f2 z1 x) simport java.io.*;
/ H8 f, I, L6 \  D. Z: ]  g/ T1 F" A1 D, {0 U1 |8 J- g8 r7 k, Z5 A
public class ProgramCompare
5 r4 C5 d; j4 d" T3 k2 E; S$ C* T{
: n! q7 M9 e5 b6 T  u0 G        //-----------------------------------------------------------------+ b' v) t4 o2 N5 F, W. Y( N
        // Constructor. ?' F0 L3 g# q" X: d0 U5 q2 s
        //-----------------------------------------------------------------
2 Q5 C, I/ u. p" f; Q        public ProgramCompare()  `. d+ r' L0 ?9 e
        {, E% H  f* X! v3 `% U
        }# `6 K8 e2 E  l

* e# F. b8 Y: J5 S" F        //-----------------------------------------------------------------
( l/ U% J3 r! s' l! v& W- ^0 ]8 m9 N        // Method for testing that class has been reached1 I1 V% ]5 s4 {2 A  T) H
        //-----------------------------------------------------------------        ; \0 Y1 V7 @, p9 r

& ]4 e3 V0 c0 P! y0 M        public boolean ProgramCompareReached()        
& I1 ^8 R) g# [. u2 [, B" v0 J3 N        {4 v! v, X# G1 {" }) N
      try 9 I* W( _  _$ J. J4 D9 F, V9 e
   {         - _& M+ F% W& L3 C6 N' s
                       
) B7 B) A5 I% n7 L. ?                //********************************************************************
7 q: W% i7 j* P* l' ?- }                // Try-Catch Statement is used to handle exceptions - such as file not found
. }$ O" Q  ~, X                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ G( a8 V& O/ P( i" f
                // For more information see page 534 of the textbook1 g6 k1 q9 A5 u8 W
                //********************************************************************
% f: l& }4 ^" x5 a. }                     1 h: L0 U7 r: X' ]3 }
        }
3 r, ^- Z: y, s5 B. X             catch (Exception ex) // Exception caught here and message displayed to the screen & _3 L. K, f# e4 f) Q# `+ J2 w- _9 v
          {
2 h3 N. g; A3 X                    ex.printStackTrace (System.err);
& f- c3 `( T8 y% q7 [, ^, V2 `           System.out.println ("Error message goes here"); // Replace this error message with your own         
3 ~) y6 v7 }2 P; M        }
/ h, D5 _8 \: m                return true;0 H( U7 t# n9 H4 @# l
        }+ K- f$ T* f( D: A. l- v) Z
% a5 G9 w+ B  w$ V
} // end of class ProgramCompare% P) e) j* [) }* E: s

& p' h0 _) ?* W/ I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 h% p5 K% ?2 ?- H* p* B" H
//  ProgramCompareMenu.java    Provided by: DRS
6 g; t! C* L5 W+ z& E//
  d, |) }/ W4 u$ n//  Calls AuthorisedUsers.java and ProgramCompare.java
! e0 ^! R7 p! v5 v; N* a; ?; K//
7 e" F6 C$ e' J6 Q1 z7 I2 N//  Driver shell for Assignment 2.5 g: l, p, Z0 H% b2 N0 i$ A/ D% w3 B
//********************************************************************
6 s+ T% `! e4 s% w4 r$ S3 z" a& X/ N
. d9 i& {# _6 D( _* `6 F" J: }$ Tclass ProgramCompareMenu. c% I, c' @3 b; _8 B- ]# s. X
{6 F& [' |# a, c7 }, T
    public static void main (String[] args)+ i: M5 ^3 S/ v# `& X
            {
4 o$ h, P! o4 S. L4 r+ y                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
/ c. z/ h. z  R9 N! ~& v* @                ProgramCompare reached1 = new ProgramCompare(); - N2 c1 N! A& q* y# j" n
                AuthorisedUsers reached2 = new AuthorisedUsers();       
. ?4 T3 \- N5 y* H9 a) ?4 J                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 b% n9 t+ q( Q5 p
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        - R3 B6 K, o( O6 @! p/ U3 I3 Q% f
        }
& T7 E6 v$ b. L$ A' B: u}// end of class ProgramCompareMenu
  {+ k' [/ A# s5 o  L, s2 _
2 a! b0 m1 L. B4 O# r( D/ b6 N8 F7 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************; j3 S/ _1 [4 U
//          AuthorisedUsers.java          Provided by: DRS9 y+ O5 n+ h- W0 I+ u
//               
. P1 T+ a3 @8 V+ O  S//         Program shell for Assignment 2
# x7 E4 z' p4 B* V  `  q5 a//
- I/ E; H0 ~" q7 f7 D3 {. g//         Represents facts about an AuthorisedUser3 A9 C5 x. \6 O0 P& Y
//********************************************************************
- K$ Z/ E- d2 i1 l% f! l8 D# |- T
public class AuthorisedUsers  g* Q4 a8 \2 X  w
    {
# k- _3 U) M4 A% z: A' ^& H8 H7 b* s& m6 F
        //-----------------------------------------------------------------
- v# x1 a' A4 y/ N" l' _  t# f4 }  m$ R        // Constructor
- s5 d* B% {0 o4 r# q0 y8 g        //-----------------------------------------------------------------9 c/ v! P1 H" k7 C* n
! V2 L. a" }, [' D; R
        public AuthorisedUsers()' [- E( h2 q% q0 K) q1 p
                {
/ h! {4 ~0 _! Q                }
- `! ]! p$ [) y$ t7 G4 q2 x' [- N& B7 X: v& c
        //-----------------------------------------------------------------8 f, W( P2 @7 l0 n1 e
        // Method for testing that class has been reached3 B' `6 b& [. K! u  `. }, e9 c
        //-----------------------------------------------------------------        ) }1 G3 e; x. C) E/ r
        public boolean AuthorisedUsersReached(), q5 G7 T2 E; I. v
                {9 X% L4 }3 \, ?( B% e- s
                        return true;                        " H: a) C2 _) r; K, H4 L. F
                }" T0 a2 Y8 e2 {# r1 K2 N
               
# P& x9 c& e6 _    } // end of class AuthorisedUsers9 i. @0 P( {  R+ h9 Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
% M6 O5 q2 g" e5 nShanghai - 2007( Z+ B# y5 K- [# r
Assignment 2, Y* y" v! Y+ Q* @) h
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)& P% i  t0 c* G/ f: _4 Y0 k
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.6 J; D6 a5 d# n7 M1 K
The staff must be able to:, b5 T& K6 S, |& Q1 d' k6 f
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' K1 ~; A; y" I7 n7 K3 A% S1 ~4 K+ }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.
6 D4 k: n5 \  F+ o, H9 n The interface should provide a menu so that the staff can:8 w. P! o0 M) ^) b, W# z: Z4 F' G
a) Enter the names of the two Java program files to be compared/ p! O2 K. y! O6 b, d8 |
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' e  C0 s) s9 p' c& D
** 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).
; A' |# U9 t- H/ S7 WBSA104 Business Programming – 2007: Assignment 2
* k; g: f0 W" \, D) f+ ~Page 2 of 5- R" \* f, k; [) d
b) Print out to the screen all the lines of code that are the same! Y5 P5 K9 U4 k3 G/ x
 Include the name of the file and the line number of the code being printed for each of the two files6 ?) h6 P' J; q: Y' ], q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ u6 r8 ]& d8 Y. U" q9 G/ I; Q6 f
 the name, username and department of the user
6 S  |) V6 U" C3 u: P6 A- j. n6 i the statistics of the comparison' i, R( w, b( a8 \$ ~4 k7 W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ N- }# E/ H/ M' k. o the recommendation for further checking
8 ^& [$ c- C3 H; Q- 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
; W) A2 D$ I: `" L; u! A9 q the names of the two files compared
/ l0 @& d& X" |* n* Bd) Leave the program (exit)- Z: M1 x) V! f1 c3 q
The ProgramCompare class: (Total maximum 20 marks available)
# P7 {  _% w& z& k0 B4 }. V2. 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)
. z3 U- @/ f  O; W+ da) provide an error message if the files are not found or there is a problem opening them
  i0 ]+ M/ l+ c! r7 @b) compare each line of code! ~1 J+ a! D; S# y& X
c) print out the lines that are the same
4 N5 E0 B! j8 ~d) count the number of lines compared / lines the same1 L% C5 r5 l% |1 _# g% ~" ~! \) G
The AuthorisedUsers class: (Total maximum 20 marks available)
# ~6 I9 Q6 T& U8 d4 Z3 d" H3. 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)
& o5 q/ K" a; |+ O) k7 k2 x7 J$ S* u4. Provide methods to:
& {3 i+ M0 _; [0 a$ W, @6 [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 {+ s9 B. g: @( w
b) return the name of the authorised user- C1 J6 M$ [2 p7 k
c) return the name of the department of the authorised user
% w- w9 t, g* s: Q$ @Individual Data (Maximum 20 marks available)8 e5 b2 u4 \4 K# y6 Y! p
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.
! t1 a* P# U) r& `; gDocumentation (Maximum 10 marks available)% R: p9 g4 a3 i) T% E" t5 g* 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.
7 W( f$ b9 y$ Y! r3 `BSA104 Business Programming – 2007: Assignment 2
" K1 A' f7 K2 \# E9 }0 Q8 pPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 j. R$ X8 @+ Z: W9 @. j不过你要翻JAVA的类库说明。你有下载没有?: G  y* t/ ~& _9 b8 @- L% X: m
查询关于对比的函数。貌似关键字是contrast,还有compare+ e" p/ p# b+ x2 P% D

( e$ I# L$ ~0 U1 p( ]4 @[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
+ F+ N4 c% b  e) _痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。* Q% L- F* k2 Q
可以下载到的 是 jdk-1_X_0-doc
' d6 v: @$ X/ L* f0 @5 N; m; M. Q/ }! u5 F- a: n; }% K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-23 23:24

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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