找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1422|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急' b# M. u! n1 b 7 I+ z) Q$ M( [/ U/ C1 u# k4 o# y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 }! D/ s& `8 ]1 }" y
//  ProgramCompare.java         Provided by: DRS) ]5 `" p# _: W: m! y+ _
//4 V+ j2 e, q% E  Y5 {
//  Program shell for Assignment 2
$ d; G$ P8 M5 e) I; |3 K0 @//
) }+ _; V' b2 j* `1 v: C1 e//  Compares two text files line by line
! A8 h% w+ [) G9 y$ X//*********************************************************************
; k5 c8 E- S* g# X! \1 C2 e6 i+ h2 A" d1 ]7 E$ D! e, Y; v/ N: o6 J
import java.io.*;
  O& n8 r) q  G- g3 G% s5 w
- |0 @& o8 ^0 |, W. I2 L( opublic class ProgramCompare
+ [: s7 r# H9 r" m* ?{4 d( t! J7 s1 d. M- M3 v
        //-----------------------------------------------------------------
* m! F6 k3 i" }3 j8 t) @, U        // Constructor
2 X+ w6 A* s+ Q. s* _" W        //-----------------------------------------------------------------; c9 ]4 X5 ^) Y+ g2 h# H
        public ProgramCompare()( {& G3 ?* r9 K+ i7 c9 g' I
        {* F  D" w) v! H: [% p) n/ M
        }
3 ^- o8 G" D/ x& n; ]9 z" S
  P7 j; a: q$ Z' R; o  l        //-----------------------------------------------------------------
% x- g5 U) y. @1 r. X1 O* U" R        // Method for testing that class has been reached
: _7 D: f, ^4 u" @, L+ f" s- P9 W3 V        //-----------------------------------------------------------------       
9 N" r5 K0 u2 v2 g7 X7 r1 ]2 J, u4 F/ A: Q: i8 J
        public boolean ProgramCompareReached()        
1 ?5 ]) `9 p( K' x        {% \3 |+ o6 u: ]) L
      try - K! |+ G: V, f9 p
   {         0 Y9 O: Y8 L: u. E
                       
0 T5 r3 d4 R6 z8 P3 @                //********************************************************************8 i6 ]; x% A' R, S& X: x. g# k- M
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 ?! ?. i8 }2 B: q$ Q  P+ y! e                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 m' c& b* M* s% }( k3 O
                // For more information see page 534 of the textbook
0 @+ ~3 |- w* c6 I- R                //********************************************************************0 l9 J  m% h) p. \' U
                     $ g+ P- K. {  R% s% e1 I' }; Z
        }
: E9 J! `& B, F4 a0 T             catch (Exception ex) // Exception caught here and message displayed to the screen
! Z, L- E4 ^3 `! {# l9 F          {
$ t5 X6 F# ~, c, s                    ex.printStackTrace (System.err);
3 a9 r# b/ t  k- U1 V; F) n+ T           System.out.println ("Error message goes here"); // Replace this error message with your own          ) _" s3 V% ]% U8 L8 j" K: k
        }* b/ F1 Z0 v" M( s6 r6 {
                return true;# P0 @& X% J& H+ D
        }
1 [) d( w4 k* F% H; p" c- ], e% E0 q+ W  v* R
} // end of class ProgramCompare
' a2 T3 @* v; i8 U: l9 G6 f3 R2 _) I2 n- a3 ^% v
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
8 ^( i* t: U0 |% x//  ProgramCompareMenu.java    Provided by: DRS
! a% l1 m6 S' S. {7 O//. B5 p& _% Q6 U; ^
//  Calls AuthorisedUsers.java and ProgramCompare.java$ k7 ?" J; P3 A3 A, ]
//8 A+ g0 ?4 d9 o' `
//  Driver shell for Assignment 2.
  E% ?# q. g* W% Q//********************************************************************) p2 D$ s2 L6 D" F5 W

6 |1 d3 y* y3 O. q  U8 wclass ProgramCompareMenu
  e+ q# `- e  v- J{
3 f9 q, m2 I1 C+ M: k    public static void main (String[] args)) W( o. g% d& u$ n# Y5 y
            {# d$ m7 e. e% G, x, M+ k
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: W6 ]# W0 G7 Q: C% |+ l4 P: D/ n
                ProgramCompare reached1 = new ProgramCompare();
' a/ s5 O% ?0 D% U: X* \- u4 S; q                AuthorisedUsers reached2 = new AuthorisedUsers();        9 B& {; _( W  N: C& w# _5 n" X
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
* q9 y) h, ~2 j4 P) i2 O) g# [                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        - q& O4 V" x0 d* h' B  Z& T5 a0 `
        }
. G) C, j; J3 @6 _; j2 d, j4 T& E}// end of class ProgramCompareMenu* l# @7 E3 Z- e' p2 U# H' @

4 I' u! z- l3 s- }, ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************: |5 r. y5 {/ R+ j
//          AuthorisedUsers.java          Provided by: DRS, v9 y& }# d- H- V" _  A
//               
5 [2 E3 H: g  E# e//         Program shell for Assignment 2+ q) H2 ^0 T. \, }. B
//
' f  ~& _. f3 m1 h//         Represents facts about an AuthorisedUser
7 x( A$ y1 R; r4 B# H1 t//********************************************************************; a1 l$ f+ N) V3 b1 v1 ~

4 @- i# w8 p( N! I. vpublic class AuthorisedUsers% y4 i+ X+ P+ u$ F$ c4 i
    {9 F) B  e8 @. C0 g1 }4 z1 {8 N( q! N

- ^7 ]. I, q; }0 @9 Q& I        //-----------------------------------------------------------------7 c. D1 s$ ^! c* C% h
        // Constructor
( ^! q3 T: s6 W# Z3 T$ j& M: R, g        //-----------------------------------------------------------------
' v3 P: q7 P" G4 Z) n
) q, T' W& Q  y4 h/ R  j        public AuthorisedUsers()7 H4 ~$ v) {3 s, y9 w
                {0 M6 k0 W3 g9 D/ u- N: j. E9 p
                }- w  h9 M5 l' E) P' L

  Z) b) O( _( G# d1 I7 @# r        //-----------------------------------------------------------------
4 ~1 h; D0 m+ l. g        // Method for testing that class has been reached
$ f1 `% J' D2 F        //-----------------------------------------------------------------       
2 ?. B; R( Y: S* d; J4 v/ j4 S        public boolean AuthorisedUsersReached()
9 T% O4 R& M% F( |$ E( ?2 c3 o; U! t                {, S) j- v1 y* ^: I: i# W
                        return true;                        $ R4 R0 O' x# Q  \
                }
# V8 q8 `- w- X5 L- l$ a                4 |& b; `* z3 f2 ^6 B. j) D- l& h
    } // end of class AuthorisedUsers$ ^, T! {( T& i" F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 {6 K/ H& b. Z. s) O/ `5 X4 h
Shanghai - 2007. {1 N+ o8 T" v
Assignment 2. x3 Z  L& n1 q  [3 U
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)
9 C& r4 |, O2 H1. 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.% g1 X: _- X* \* P, W% l
The staff must be able to:
2 x( }2 v) v' J/ m* \% b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.( A# Y8 q7 |+ G+ L. E
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.5 r: ^1 T2 ^- S: E
 The interface should provide a menu so that the staff can:2 |- T0 S7 V8 l6 n- Q  N" S
a) Enter the names of the two Java program files to be compared
+ U( H$ e6 h$ i, f9 M* u/ R/ x For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
! \) {$ _( ^: A' C: W** 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).; ~: B, E9 i; z) e" l
BSA104 Business Programming – 2007: Assignment 2, k* i/ n" F2 q1 Y; t0 W& v2 k
Page 2 of 57 W3 v; w& B/ Q0 e! z, v
b) Print out to the screen all the lines of code that are the same
5 _# q4 C" R& @, H3 p% S Include the name of the file and the line number of the code being printed for each of the two files
- H) B* B0 y" u7 i8 L/ Zc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& |; @- v1 l3 W! A" W& N/ s the name, username and department of the user
% T, K1 S: }8 f! {/ Q$ \: h the statistics of the comparison
6 e- [1 z, l- I$ E0 c4 v- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
: R1 |5 {5 @! p3 l the recommendation for further checking
$ Y3 r# p( L. [- 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: Q, B+ R9 w2 k* j5 M
 the names of the two files compared
- R+ s; a2 q# u5 J' wd) Leave the program (exit)
; L  B4 d4 {% j) cThe ProgramCompare class: (Total maximum 20 marks available)8 e1 d* k' M, n5 t8 u1 ]2 h! u  G
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)% Y+ H+ F+ X4 s$ A
a) provide an error message if the files are not found or there is a problem opening them" N# T( b. _0 B3 N$ {) P
b) compare each line of code
5 d1 q8 @  H5 C# rc) print out the lines that are the same
' d* @$ Q$ p6 x$ fd) count the number of lines compared / lines the same
' j# H/ q' P* T8 W$ n) c. `* cThe AuthorisedUsers class: (Total maximum 20 marks available)& \8 v4 H4 D3 r5 B
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)
2 Q$ h8 U: c  a. k5 F8 I1 h4. Provide methods to:; o, v, o5 k* b! o- v* D8 H+ [
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' R8 H; A& N) a& K3 Q
b) return the name of the authorised user( J" `; `' y) }6 F. {8 l
c) return the name of the department of the authorised user
" E. g  R7 q$ r0 Y  g3 SIndividual Data (Maximum 20 marks available)
/ }5 d8 T, U! r& R  m5. 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.
" w7 J8 O. l$ P4 zDocumentation (Maximum 10 marks available)
  T* [  L/ D, o  ?. j, X! S# B/ e/ e2 w6. 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.
3 n. J* R$ H% }  N5 ~BSA104 Business Programming – 2007: Assignment 2
$ I6 }+ ~& R3 K+ K, CPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. x7 Y' I3 N# f7 \8 E5 O: c1 s, v& Y
不过你要翻JAVA的类库说明。你有下载没有?
0 [% Y) i9 M3 q+ J2 X+ s1 |查询关于对比的函数。貌似关键字是contrast,还有compare
, N& m, T3 y# C* `! S  L2 E/ z, O; e& V$ d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; ^- c" K& K; v; d痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 ~: R$ W/ m* e& \# ~0 V( d% B. N
可以下载到的 是 jdk-1_X_0-doc, S( V3 h5 {; T" u" B/ S

8 ?% D, Z8 j* ?0 f9 z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-29 05:08

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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