找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1782|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急, U4 E0 c( M, k/ H) L 3 f( U8 j' J& Z: o
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************" ^/ |& V8 J; B3 ~9 b2 ]
//  ProgramCompare.java         Provided by: DRS
; }- l! N2 d, e. K//4 _* K; @" ]. c' X. t
//  Program shell for Assignment 23 v& p! j4 z. |( l+ }; {
//
5 S2 d( u' _0 \. g  f. e//  Compares two text files line by line* C' ?& d  ^+ S- n; R) J4 [
//*********************************************************************5 v# u6 s+ }  ]0 M
0 v! T' a9 r# {
import java.io.*;
: C5 H) }, r% {$ |0 t
, B4 A- u, H/ Z% N+ A6 spublic class ProgramCompare
; Z1 _- \- b; m/ H, p{7 h& t; q6 D' V( T" n. f% Y
        //-----------------------------------------------------------------5 ^( y- K' P+ r8 @, z# m4 t9 |
        // Constructor
/ @8 N% ~# h( `9 f- K5 h9 y        //-----------------------------------------------------------------
( C3 Z! I5 U7 I) }/ c! s        public ProgramCompare()
% {9 Q- }# h/ {& s! `% D' }* I9 Z7 z        {$ |6 z, @+ h- ~: \" X
        }) a+ X! C$ L  w, V+ P
4 x, U# I0 |( v$ X. \; O7 F6 P* v# E
        //-----------------------------------------------------------------' {$ g- P) Z0 M' U* i( A: s( p2 ~( R8 |1 N
        // Method for testing that class has been reached
, x4 m6 c, p8 x$ _5 J' `: ]& {        //-----------------------------------------------------------------       
- X3 L. f; Q& f. j* l9 d8 o; v" J* b( K5 R8 p3 A
        public boolean ProgramCompareReached()         , G- O% h% ^: k1 T
        {- j. ^2 a* }1 J% V) U% l' Q
      try $ z" _/ w6 ^' \$ R" a5 A, p3 w7 x+ l
   {        
6 z" g( V5 j$ n1 Y! j                        : E' O# @4 V+ s2 G) R+ F! k( T
                //********************************************************************( _9 d$ I/ {/ p, k2 ~
                // Try-Catch Statement is used to handle exceptions - such as file not found
: u& ]& ?" T( Z                // Reading the files will need to be placed inside a Try-Catch - just like this one!: n- c0 N7 `* \; R+ l" w
                // For more information see page 534 of the textbook" n& f# ~8 D: l
                //********************************************************************
$ V5 U; l* n; O) H3 V& _$ s  F! z                    
$ ~" h5 L$ v1 P/ A. T! n        }/ g: t+ Z4 D1 M# U; B
             catch (Exception ex) // Exception caught here and message displayed to the screen   H# G! C9 q: F9 S' g. t& s" ]
          {* g% i9 G: }" T
                    ex.printStackTrace (System.err);
( I; u; L. b# I8 q/ f           System.out.println ("Error message goes here"); // Replace this error message with your own         
) m; X+ U# A' r( ^4 k7 n7 H% u  {        }' p7 N3 Q" u# H" j
                return true;
5 u( u, a8 }# V6 T4 P        }; S  H& ?# Z( j" b1 T3 o/ w

: c9 ?2 ?7 O- G2 p; v1 n} // end of class ProgramCompare9 z4 ^/ z$ @; K/ w
3 r6 y, Y- n  ~# u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ M+ z# x' t7 _//  ProgramCompareMenu.java    Provided by: DRS
1 h! i) H8 N# @" ?8 A, z//
7 n% s/ v( T0 M. \//  Calls AuthorisedUsers.java and ProgramCompare.java
8 Y6 O5 m0 I. Q  F1 w, w+ b& ^6 M1 a//
+ ^; {; o( }1 G! ^" M. v//  Driver shell for Assignment 2.
! {. J, A% G. T" _, [; X5 o//********************************************************************# J  {; l; w- q: h& z+ F. b5 h

* L; d1 W) o/ \; {5 |  c, \class ProgramCompareMenu% r- h  Z3 j$ O1 w6 p. |
{
8 }0 V, J: g$ o& V+ F0 l    public static void main (String[] args)  x* F$ D( X6 Y9 m; j3 S. h6 M( `& K) W
            {6 a" j* n. x/ q1 F4 @8 y7 h9 F
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 y' s5 Y' H: ^9 ~- K, v( W! {
                ProgramCompare reached1 = new ProgramCompare(); 5 o1 L/ P) b: Y' [! A
                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 a7 k% t( Y9 P% A2 U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ e$ M' @. ~- q2 P& ^# f                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        2 N* j* m/ J- J. A) j& y8 M
        }. f  o! C' y8 t- k  O! y( _
}// end of class ProgramCompareMenu& K9 n$ _5 v8 e/ _
+ Y* x! x( {$ C9 w+ J- Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 i1 B8 \# E- `4 F- x3 H8 O% G//          AuthorisedUsers.java          Provided by: DRS
3 z; r, D9 P: ?; T( V% T//                8 J; N: {9 R* e- C7 R2 E
//         Program shell for Assignment 2' s8 _! c! a$ u  e
//
, ]2 B  ]) A6 c" V4 G) c0 }//         Represents facts about an AuthorisedUser: }7 K; T1 x2 b2 f; r$ ~0 h3 j
//********************************************************************
2 P) u" @4 s6 A2 Q8 j: M) E0 _% K" j! \; f
public class AuthorisedUsers
9 X* j- B0 o( r9 ?    {
# U. b6 I0 `2 w- ^: e, g+ c  }) Q2 d, }: v
        //-----------------------------------------------------------------2 M8 f$ x! {6 M6 w# O, S
        // Constructor( [9 A9 F# i* o2 m% m1 ~0 p
        //-----------------------------------------------------------------
7 L4 y6 n6 }! s# M6 Y- Q8 ?* `1 P( [" x
        public AuthorisedUsers()5 f' A# m' X+ Z4 H! u* _* W
                {, a1 ^. t4 q6 E6 Q. }
                }5 o6 ], e' S5 K% ]# h

& o: r% q8 I* ]" D  `        //-----------------------------------------------------------------3 j  D8 f8 K6 m" S: i) J
        // Method for testing that class has been reached7 i- _) v; y% p
        //-----------------------------------------------------------------       
6 P1 n! L5 H1 U- |2 ?2 \) K; o) ~        public boolean AuthorisedUsersReached()# U' m- K5 J; Y* k; H$ J
                {
* b& \5 O- `; Y  j7 B( ?' X                        return true;                       
. g/ Y, ?5 r' I& T; D" H1 a4 d4 y                }. m9 x5 T; C2 L' b( i4 h* E
                1 i8 E* e# j9 G4 O
    } // end of class AuthorisedUsers
0 r6 y" u7 I: W3 W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: H' q( g* F/ T; B+ X, U: _% e7 C
Shanghai - 20072 D3 U3 L; U. Y0 B
Assignment 2; {6 p0 N% k" \& h! y3 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)
$ M. c% v4 \, y$ ^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.
. {! A, a6 \, {# r# _The staff must be able to:4 ?$ P; d: E* {' n$ H. O
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! m) }/ E& a, w8 b5 c1. 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.
. d  h! B$ U1 I% ^4 |8 D The interface should provide a menu so that the staff can:
1 d/ z% I4 |; g$ aa) Enter the names of the two Java program files to be compared
& G5 R( F) z1 m" z# e" \ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
  _# n& |; Q7 G7 j! t** 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).
% k% g# t5 b! R' Z8 r: PBSA104 Business Programming – 2007: Assignment 22 v8 C/ X8 J) O; e  m$ L: M
Page 2 of 5; r" ?* n( M1 l) H* _% i: n; z
b) Print out to the screen all the lines of code that are the same, f1 k3 K. F, p
 Include the name of the file and the line number of the code being printed for each of the two files$ G# \8 t) |0 u
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 k" [% }; l9 r$ |" Q' }  Q. Y
 the name, username and department of the user
8 j8 }& m- A# a4 o: f the statistics of the comparison
$ @/ r+ ~% v- [4 ?- T- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 C5 i/ Y# y, M# |6 _' ]$ W1 g8 H
 the recommendation for further checking3 _. x- H7 N' ^( C; g% K! p9 T+ P
- 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
) T/ @: K# a3 O& ]' i5 ` the names of the two files compared
# A; {% R' S+ B# J: ^! ~; R' }d) Leave the program (exit)$ D0 l" A0 k- Y* [* C" X3 F
The ProgramCompare class: (Total maximum 20 marks available)- f1 w3 ^! w& h7 S" t8 V$ L: ^
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). i6 d: p2 R6 D, W
a) provide an error message if the files are not found or there is a problem opening them
: `" q) A# Z2 hb) compare each line of code
7 V) j8 L% D3 ]; }c) print out the lines that are the same  l5 Y. V+ v  u* m3 b
d) count the number of lines compared / lines the same
1 V8 a7 W! c; kThe AuthorisedUsers class: (Total maximum 20 marks available)1 g+ a3 V% ]4 A% P+ P* d! \
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)
5 p4 @% a2 \3 ^- u4. Provide methods to:. T  q4 k5 _2 O; ]
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
/ r, R7 j6 S. K# Ub) return the name of the authorised user" x2 E/ r- E) J& `- m% E
c) return the name of the department of the authorised user. V7 g% Y0 A- H) p. @7 q
Individual Data (Maximum 20 marks available)# R# B4 v  r5 e' p; r7 L" k: ]
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.
% i. C+ w8 J" f  j+ P/ @Documentation (Maximum 10 marks available)3 ^; N: R6 \7 v% ?7 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.# @# i$ }/ }- A5 }) F6 p$ V+ [
BSA104 Business Programming – 2007: Assignment 2) G9 p% {) F5 {$ d
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了9 ~9 q: U& |' r; V( s, A. I/ _  c  R
不过你要翻JAVA的类库说明。你有下载没有?" _: P+ x, }3 M  V* m' ?7 X; M
查询关于对比的函数。貌似关键字是contrast,还有compare8 Q- C" T7 h3 }
2 q. u" w. t/ e0 E+ r
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 ?3 o/ P# \/ Z7 V5 |- ?) D/ D
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。* z# B$ `$ }0 M/ ]8 x9 V/ L
可以下载到的 是 jdk-1_X_0-doc
; `- U6 I! q' m  n$ z$ s
4 S& K6 n# C" d5 |  X1 Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-29 13:46

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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