找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1836|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急; `6 H4 R0 [- t f* c 4 x% T9 u7 e& i l5 [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
3 L: r& ~! U; b8 J9 n' H  `9 i9 R3 x//  ProgramCompare.java         Provided by: DRS2 X. A8 X6 e4 L
//7 [" Q8 q! d+ D0 W4 s
//  Program shell for Assignment 2; }7 V( [3 [; `5 m7 `9 ~
//* T) f  V$ X; p7 ^, [; J# L! w! C
//  Compares two text files line by line
' D: u3 m& u  m& e2 i& Z% s! B3 A: S7 ]//*********************************************************************) B6 t0 @- ?6 O0 a& g, C7 P
6 B* b6 b. {" [: K* U: f6 [  [
import java.io.*;( H( a9 X. c7 [/ l3 X0 P# c$ |
7 {% B8 S3 U7 u. R9 ^, P: f. \, T$ w
public class ProgramCompare" j) z" V0 Q2 v' k6 V2 M" d
{
4 j& z7 q! s! ~8 V        //-----------------------------------------------------------------: Y1 N* L5 P* x7 j' a; l
        // Constructor
9 ~. u  m. ]% E" u0 \        //-----------------------------------------------------------------/ w9 `8 G0 T7 H. T& Q
        public ProgramCompare()
/ m7 f. O# W' h+ m6 i        {% m7 v: p( r& l. g. J$ q) O
        }
; T, @! Z; S; Y% h1 M/ r' r4 f# [1 ?% B% N1 M! N8 j
        //-----------------------------------------------------------------
+ f- A9 ^8 |$ K; U        // Method for testing that class has been reached% m  F: {% p5 v0 |1 k
        //-----------------------------------------------------------------       
" B% }/ |" t  v/ |2 R9 p1 y
2 ?9 T& j' \' E        public boolean ProgramCompareReached()        
* z7 X2 q% G% k3 C5 I) ^        {
/ T0 f) W) e# E$ }- S$ ?      try
; p7 s! }- S6 t9 A3 `+ m0 @   {         - E0 f( ]/ [% \, H
                       
9 ^6 c8 T' Q! y7 G5 \2 G$ T. v                //********************************************************************" _1 R: r# d3 X
                // Try-Catch Statement is used to handle exceptions - such as file not found
& \* ~) d+ x; v4 J                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- [2 c; ]  C. ]+ f9 C- a/ m- {                // For more information see page 534 of the textbook- R9 R6 C( S1 G2 Y- I( n* i
                //********************************************************************
3 N7 z. n+ ?) `* B9 o5 v- H& c                     % g7 j7 r" I; B& b3 q, W7 W
        }
8 I. N/ X7 t* o0 L" I# d5 O             catch (Exception ex) // Exception caught here and message displayed to the screen
2 H4 |( ]) J6 t2 `3 }          {- O6 T0 ?  n; W2 A  G4 f% l& l. C
                    ex.printStackTrace (System.err);
6 h: ?7 V0 V; j4 w3 L, ], x           System.out.println ("Error message goes here"); // Replace this error message with your own          7 l* @! A4 H# r) b
        }
! j$ P6 B# g7 r4 D- Q  s$ R                return true;
$ n) B5 T' A! y  _        }
/ v! p  S  h8 o0 m0 l7 p. _5 E
6 C, [4 a4 |3 o; h4 m. E} // end of class ProgramCompare  B: Z2 `# Q; g7 k8 G3 B

0 t; D3 q' B3 ~' V9 }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
6 J( [# y" x; j2 p1 ^//  ProgramCompareMenu.java    Provided by: DRS
' q6 f  T; z" P% m% j% O& ~! Z5 e8 V//
% E, z) K5 ^7 t( X//  Calls AuthorisedUsers.java and ProgramCompare.java
- J3 ^2 X- P1 @- ?& F//
/ K) l/ r5 G6 ^1 d9 e! Z9 Y//  Driver shell for Assignment 2./ Q# t( M, t' d; I5 ]9 v3 P* h4 e* X- f! ^
//********************************************************************; M* |# ^7 a+ o. B. z# L

+ q5 X1 o, u$ t1 F$ u8 Tclass ProgramCompareMenu
) N% A  C( H1 z: t{; U: @) J! z  A: b; r
    public static void main (String[] args)& ^6 b+ `. ^4 B9 j1 R! ]4 @
            {2 M! y" h5 }" o& D& w1 |) O3 I
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 {9 w$ F" z* Z/ n+ {  S4 A                ProgramCompare reached1 = new ProgramCompare();
% z) Q+ ^& Y4 {: V( I" N. Y$ Z                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ I) g7 l: J1 w                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 q( L; g0 r6 B) S' J4 J9 O
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , h) l2 P6 ~) P  U: _2 Q
        }
, r1 O* p' m# ^: X5 L( J6 o# x( W}// end of class ProgramCompareMenu
* ^) g3 t& u1 G# a/ Q0 Y7 B( d6 ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ n& T. @4 m1 j3 d2 c! D//          AuthorisedUsers.java          Provided by: DRS
0 |7 T7 B/ R) D7 h, s6 N, F  X  t//                - g2 [8 g: k3 F, a
//         Program shell for Assignment 2
: l0 W1 G3 V3 P3 z# n7 }5 K0 l8 r//. z$ H3 y( N! j) D0 n9 B' b+ s
//         Represents facts about an AuthorisedUser/ e( g2 G. K+ ]% ~8 X
//********************************************************************
& M. y; N* ^2 J8 Q7 s
: c9 `, W5 N3 t2 spublic class AuthorisedUsers% G$ V, W3 n# ^7 @' b# q
    {
6 @$ w6 [) P" F) z
6 _5 N+ j' q3 h/ o/ Y        //-----------------------------------------------------------------
( G) J' n, L8 M- h4 A! {5 D+ Z        // Constructor4 N: M5 N; U1 J+ ]  d0 Z0 w
        //-----------------------------------------------------------------
& j, ~( U5 g* l$ ]' t* j2 o- z8 W4 a; I* Q) ]
        public AuthorisedUsers()1 U+ Z" X  s. j" v2 }. h0 a6 D
                {
* G) j0 `0 z% e) T/ y                }
2 W6 {0 H3 b: m8 d
0 F  {! F7 Y& T% i        //-----------------------------------------------------------------3 E0 f8 Y/ I1 n
        // Method for testing that class has been reached
! g- ^! T8 c) `- r9 r& J5 ?        //-----------------------------------------------------------------        2 {% L3 F+ M6 F* Z2 K- K
        public boolean AuthorisedUsersReached()
0 F# o) g, O+ o/ d                {+ }, v$ z8 o- ~* d
                        return true;                        4 y/ f/ H# T; ]. v! |
                }
! V1 w6 N' v# ?0 v, k                4 p2 Z) X# O$ i9 l7 U' z% f. j
    } // end of class AuthorisedUsers: r4 q, ?0 B  C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( d% k2 Y. T5 j; r# @; ~Shanghai - 2007* [" B" F8 q, {3 ~# v: l4 ]
Assignment 2/ K+ k2 x* `0 F
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)
0 m& {4 |5 g+ a6 ?9 R9 B2 `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./ [# V0 A" b( W1 F* X  H" C/ E$ C
The staff must be able to:
5 `5 ^9 y7 G) l8 B! U Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 R; D, e3 e; Z5 m
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.$ ], J4 T3 S" q
 The interface should provide a menu so that the staff can:7 E; j0 O3 E7 s. f9 S
a) Enter the names of the two Java program files to be compared
6 i6 R2 R  b8 {, c- g+ r For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
8 g4 c( D7 D( U1 q** 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).
7 U- ?  @7 t5 z; F6 YBSA104 Business Programming – 2007: Assignment 29 A* k( ?$ v) G1 Y0 t; S, o( g
Page 2 of 5
" W7 ?' X5 U: d- r  M5 m6 u2 kb) Print out to the screen all the lines of code that are the same
0 ?0 [; U! A7 d, G& Y' R Include the name of the file and the line number of the code being printed for each of the two files0 ~: _& n5 u3 X7 A: [# i  Z' }
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 E7 }9 n/ x9 W: R$ p
 the name, username and department of the user
5 O1 M, w4 Y) C  a- [) p5 E) L the statistics of the comparison7 C# i4 O; _, s( |- [* L3 T0 m
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 ?5 |# e% [$ A( H( B6 y2 {) i
 the recommendation for further checking& f: y* ]  _8 @+ N; i; ~9 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
2 [9 j3 a: L, I7 b  C the names of the two files compared
& h9 u( ?' ]  ^' k6 r- @, zd) Leave the program (exit)& o! m5 w; h3 W& r$ Q* Y
The ProgramCompare class: (Total maximum 20 marks available)
& O6 G. v/ v8 H1 t' P4 ~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)* W" h* f. {  B; m6 Z# z
a) provide an error message if the files are not found or there is a problem opening them
; O  y% w/ I( Y! o8 ~' Ib) compare each line of code
5 R; B/ x! J; u/ `5 O- Bc) print out the lines that are the same8 s: w$ _  l/ m! a) s$ Y$ o( f3 ^
d) count the number of lines compared / lines the same+ l6 t+ `; y: }; m7 p
The AuthorisedUsers class: (Total maximum 20 marks available)
! M3 w7 w- W8 a" t3. 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)
- G9 M6 j! g: P# h0 f. {4. Provide methods to:+ d& n# e& I( ~
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/ J$ J: M0 ?5 R# C; S
b) return the name of the authorised user5 A! S5 `: n4 g  J- e. I
c) return the name of the department of the authorised user
6 q" w* _% h' j" ?Individual Data (Maximum 20 marks available)4 I, Q, N) @* A4 u7 d% L1 v. ~- Y
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.
3 m( z; l- ?* f( d: s; bDocumentation (Maximum 10 marks available)
! J& l% T0 A) X# g1 K/ t+ G6. 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.
- ?- c$ v6 A" q: R5 _5 RBSA104 Business Programming – 2007: Assignment 2) @. n4 U8 N! x2 P
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
6 S7 f- a; u% i3 H. V' H不过你要翻JAVA的类库说明。你有下载没有?
3 j. z5 [, q' m; L6 G. {- j$ s查询关于对比的函数。貌似关键字是contrast,还有compare
% E6 r4 L# w7 o3 n9 d' E! n
: a  j9 D/ Q* F2 [* [% _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 R* P. z4 W! H0 x
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: ^) I/ G% ~0 w  v可以下载到的 是 jdk-1_X_0-doc
; f; D7 t+ G: q6 I! s4 k: s- |% s4 h7 ?' q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-17 09:03

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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