找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1532|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 f% ~1 F$ o& s- U, U4 N8 ~6 r ' L; R; t# c9 P: T
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
+ g+ m, U: a3 }6 r//  ProgramCompare.java         Provided by: DRS
4 ~8 P% a4 u1 U, l% P1 j5 [7 y//2 [5 C4 U8 k: l8 q8 P9 p" j: \1 u9 S2 @
//  Program shell for Assignment 2
+ b; _6 y" e7 Y//
7 s, b2 `7 l. i  R1 C/ m' ]//  Compares two text files line by line
7 x  ^2 o' S- d; M; {//*********************************************************************8 E$ C1 p; V7 `- T% f
& e9 S0 N: m1 e. c
import java.io.*;
- U* [, c6 |7 K1 R
' l) A+ W" |7 v6 L! b' ]public class ProgramCompare$ A9 l+ H6 E  I5 e: K/ Q1 [$ Z- e
{
7 U! C( a/ |+ x4 r# B  ~        //-----------------------------------------------------------------
: `: M$ o+ I" P% |% J2 @  x# |        // Constructor4 A$ p4 m! }/ w5 }
        //-----------------------------------------------------------------4 M7 J& ]) G6 v: g5 l5 g
        public ProgramCompare()
% f2 a' g+ t8 f  R$ V( [/ Y        {, e# o- y" [6 @7 r2 y* Q
        }2 c  s1 C$ ^  X6 r

' }5 ~1 w$ A5 m- M        //-----------------------------------------------------------------( E# y/ s- u5 w& P* F8 _9 E/ d, z
        // Method for testing that class has been reached1 U+ c+ E  X( X' f, k
        //-----------------------------------------------------------------        9 z9 L" ~) d' o4 p7 B: H
! m+ ^' R8 W6 l# ^6 B% b9 x( |- I
        public boolean ProgramCompareReached()        
6 N' q9 p9 J: |. h8 U' W        {. L, k* G9 H6 y7 F% O; Y
      try : G0 F2 _4 ~/ Y+ w( w1 s
   {        
* N: n$ u/ m! g' ?                       
9 G- ]3 q9 {. r' k                //********************************************************************& `/ v0 z# \& s2 T, z9 ]  J) h1 k
                // Try-Catch Statement is used to handle exceptions - such as file not found
( z- _2 e6 H& C* w5 h# q* `$ V                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 g+ \, o: \8 D; Z! S5 x) \0 ~1 l                // For more information see page 534 of the textbook9 l; g4 k& M! e+ U% E$ B6 ?
                //********************************************************************
7 X: J& y" [. L5 w3 @+ s                    
1 M  @) ]* u" w& \' @, D' c        }. @, g. P$ _9 M2 c& m6 |
             catch (Exception ex) // Exception caught here and message displayed to the screen
9 C+ B4 m( V, p1 @. m$ t) _: l          {4 J% Q8 P1 X* z
                    ex.printStackTrace (System.err);# `6 H  Y3 O7 o: p, Z& x
           System.out.println ("Error message goes here"); // Replace this error message with your own          4 {! _* _: w0 B  l1 r% _
        }* A7 h  Y' c2 s
                return true;
" R6 i1 p4 z4 g) W7 C& j2 f& A& P        }
+ a! Y$ F2 ?/ y/ m" g) [3 V; c# ?- L% t9 R
} // end of class ProgramCompare5 n0 }( @: T0 c, S3 g% Z+ Z! F7 Y. P

7 K8 h, Y0 R/ R: K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* ^/ _; U2 y$ T" B//  ProgramCompareMenu.java    Provided by: DRS. z; C+ p, d: t7 S' C8 a: C- Q
//5 m# ]$ E5 i8 |+ i! U; L0 G  h
//  Calls AuthorisedUsers.java and ProgramCompare.java
) e: U' W4 ~& ~. G9 w) p//
% A9 r& d$ P% r. f* G- S# ~0 Z5 h//  Driver shell for Assignment 2.% m9 v" X: C# i4 {$ _3 c4 u" G
//********************************************************************
$ [0 X2 F6 ?; n7 C$ s
: c" I" I: `. l6 S. yclass ProgramCompareMenu4 C/ {$ `2 Q! a. A1 n- q% @
{# N* {  U  o' W: E# T
    public static void main (String[] args)6 P2 e- M8 c2 a- x$ _
            {" c! P: G; l" F5 b1 g
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! M  }" i9 Q" r- a% b) ^                ProgramCompare reached1 = new ProgramCompare(); & H7 n1 G& t( Q& ]% K
                AuthorisedUsers reached2 = new AuthorisedUsers();        # s. m1 C. I/ m' s9 t7 ?0 e; A
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 f! [4 }  X- u- D                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ' p9 f* F0 A6 s* u0 G9 @
        }
: ~& s& b& |, V6 q1 @! j}// end of class ProgramCompareMenu
) i2 c" r9 @( U2 \3 q9 M" _- b. Q
# ^- x2 A* X- A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************& p* o( {) Y7 D. Z3 b+ D
//          AuthorisedUsers.java          Provided by: DRS# p1 _8 N# J. h$ r! k" ~6 i1 P
//                * J2 X! ~/ O$ {9 |8 k
//         Program shell for Assignment 2' L( A  i/ U& |$ b3 L8 i
//
# U5 n4 n1 u- l1 [2 o: _//         Represents facts about an AuthorisedUser
+ i- Y9 K& s; i, i  H5 n' G- S//********************************************************************
. }6 e0 I" g2 P" r8 d+ l9 f5 }0 H$ a% P# E8 x# `
public class AuthorisedUsers
* T; H& ?7 G/ r, v    {
1 f5 X! p6 P1 Q0 E- i; `% C8 Y- _0 q  O. F7 U& [# n
        //-----------------------------------------------------------------! t  h# \6 l) |, J% ~
        // Constructor) S! H! v0 c1 V$ N+ |- q0 W
        //-----------------------------------------------------------------: @' M8 \: D# V

: `& [6 [6 F2 V7 I& ?  A        public AuthorisedUsers()
* n* Q# y6 C/ |+ }& m                {
% a  U& r+ _. g1 W                }8 e: P* S3 i: N7 }3 @

2 ?0 ~+ q( ]  E! g9 r. w2 K$ @: {2 G        //-----------------------------------------------------------------
, j* H0 ^) a+ B( z        // Method for testing that class has been reached
4 v7 @  r2 d" _9 s        //-----------------------------------------------------------------       
& ^8 o3 |. X& U9 s( e8 ?* s        public boolean AuthorisedUsersReached()* J$ @- h+ Y' k" n: ?) z
                {
4 n3 U+ V( E& M, ^1 C6 I% C                        return true;                        ' W. z9 |, c  x, p! u6 G$ [
                }
8 q; f1 z# l" B1 a7 E                2 n$ D2 _7 \) b/ Q' j5 B; Y
    } // end of class AuthorisedUsers
' L0 D( @: Z3 Y( C- H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 c0 m. f0 B9 j6 J  I
Shanghai - 2007
* c# \1 B  K" D  W) TAssignment 2+ [0 ]/ J3 y' U( c9 O
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)" \* A/ N6 F! q9 J9 H8 l
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., ~0 r: _' k8 v7 V% {3 S
The staff must be able to:
: A3 K5 t: G- p  G5 B: F$ [ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* {, Q& P- H2 L" r4 @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.! s1 |! y! z* K' [) F
 The interface should provide a menu so that the staff can:
2 P0 L* F" [1 x# |- p8 [a) Enter the names of the two Java program files to be compared
0 y  b: J( }9 D For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  V) s$ m1 D2 z/ E4 S0 \  s& z
** 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).& L6 ]- J8 l( G' X1 m3 u5 @
BSA104 Business Programming – 2007: Assignment 2- y* L. v7 ~: K; p
Page 2 of 59 J8 B0 u' {$ I! v
b) Print out to the screen all the lines of code that are the same7 u' W+ z, E2 K- Y( P
 Include the name of the file and the line number of the code being printed for each of the two files4 H1 \9 [, q. b+ J
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 n2 R7 W. f) a# L! P
 the name, username and department of the user5 d, x+ l  V% o  c; T: e2 T" v3 g
 the statistics of the comparison
& ~/ f% ]! Z* I; \" j' r/ c- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different$ [1 F5 @, z$ Y" ?' S: U/ Z4 u
 the recommendation for further checking; S2 x* N$ [5 ?5 [
- 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  K8 n% r* q, q, t. Z" V6 y
 the names of the two files compared9 o6 R4 I& |0 d
d) Leave the program (exit)
0 ?+ ]! L) d& I! X0 s% xThe ProgramCompare class: (Total maximum 20 marks available). l+ e3 U- y; L0 |" x
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)
2 e7 Z  ^2 s; Q8 |/ v% Ja) provide an error message if the files are not found or there is a problem opening them( z: ~+ i- h% H- n1 K7 E
b) compare each line of code
0 ?, `, E/ @. f) x+ Dc) print out the lines that are the same
3 {& [" @7 V+ J$ F& {% x( ud) count the number of lines compared / lines the same
* G9 [6 y1 B" ~* F' P" d( N4 b& ]The AuthorisedUsers class: (Total maximum 20 marks available)- P2 \! }% Z/ ^
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 B' Z/ J: A3 k4. Provide methods to:: a* R4 k6 N" \- `0 N7 z
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: ^8 G: `8 }( E: L' `" \
b) return the name of the authorised user0 V6 r* X$ z* I  C: O5 I$ L: B$ H1 X
c) return the name of the department of the authorised user
6 }" X9 a3 p6 f0 H& iIndividual Data (Maximum 20 marks available)
2 s( M8 m4 S% K6 o( {9 f( g5. 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.* Z6 ?1 }4 `& S, B# K
Documentation (Maximum 10 marks available)
! R6 L6 P; J# B- d' r6. 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.
$ O* K4 P9 q7 r/ |/ R$ ZBSA104 Business Programming – 2007: Assignment 2: z8 X  F% F" K& g& j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
; |- Y9 b: {! E! d; d不过你要翻JAVA的类库说明。你有下载没有?+ m  v3 \+ |7 x1 V
查询关于对比的函数。貌似关键字是contrast,还有compare
8 Q, C) R& S& o% d% y- v7 g- V; i1 K9 \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
& Y% `6 g. u- t$ i痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ {% |" {7 L# y4 L6 f
可以下载到的 是 jdk-1_X_0-doc
( a- o4 k2 D2 d8 ^' q$ h+ f
+ B( U, ^2 d9 O: ?# {! }8 B, i0 t- q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-11 09:48

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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