找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1416|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 J* n6 \) P( Y1 {/ [9 N + N+ R: J _0 |: c3 f
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( a) P8 t/ f' }//  ProgramCompare.java         Provided by: DRS8 {7 s& x4 t' w! L/ r+ D" w+ \
//% U% d+ H9 N  ?5 b& ?, t
//  Program shell for Assignment 2
# @$ q  c- X/ y, _( g: |: t0 M//
$ l$ F0 `* f7 U7 n" }5 v+ u//  Compares two text files line by line
" f5 L8 G4 r5 p# B$ h% ~//*********************************************************************: i, \8 Y$ d" }5 q
4 e& ~: k. K4 d
import java.io.*;* t" k7 B: P: d& |; ~( ]9 S( h2 E# [/ J; M
' M' G$ J$ l" ~$ r5 @+ n" d3 J
public class ProgramCompare
" A$ Z& I+ @7 h3 e. R# m8 M2 x{! p2 j- D; P5 I$ _1 w4 U( K5 e
        //-----------------------------------------------------------------
% z+ }; z$ `) |# a& s% {        // Constructor
0 ~. C! v2 Y* |: I) |        //-----------------------------------------------------------------
& B. R" S* t9 w* K8 ~+ W! u        public ProgramCompare()! K9 f% `& ^5 K) u* z2 z' Z/ L9 `! d
        {1 G1 P+ [" ]8 |- j8 C2 `. h6 |% W0 i
        }
, D9 |! a; Q/ l. }3 ^/ y1 s( R# @" C9 a
        //------------------------------------------------------------------ ]6 }9 b3 n7 k$ J, `' s# a
        // Method for testing that class has been reached
3 F6 v' V! q  p* ]8 ]        //-----------------------------------------------------------------       
* M0 {9 K* [$ a. o6 O' f: X. r* o
        public boolean ProgramCompareReached()        
( D3 t7 p- e9 q+ A( ~4 [        {
, a' R0 }2 \! t8 y3 c7 z3 ?1 N      try
- {* q( Y" [; ]5 e) |, ?   {        
2 e% X/ c5 [- {3 H                        . J: u1 [9 c; A' G# V
                //********************************************************************
7 X( Y# ~' ~4 x6 k* h( E- S                // Try-Catch Statement is used to handle exceptions - such as file not found $ N1 P, ~/ x5 L; n+ W
                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ Z5 ?+ w# v7 a$ D) B; c
                // For more information see page 534 of the textbook
6 {4 G2 h# O2 j6 {' A                //********************************************************************
: T1 S% W* J# z1 o* M4 y                    
1 N" Q. p% Z0 F: ~5 b        }
( c1 `; T7 E9 ?2 M             catch (Exception ex) // Exception caught here and message displayed to the screen & ]* j$ u2 e9 F
          {
7 a' M: ]) i% I) k; y- o                    ex.printStackTrace (System.err);4 J3 k3 h+ z- ], }
           System.out.println ("Error message goes here"); // Replace this error message with your own          9 A4 C- B" e  d( N
        }& [$ Q; K" I! v) K: `) B" D% {1 F
                return true;, v& ~. n8 T4 T6 r+ Y5 {
        }1 ~8 n. T; y' m% K: ?

1 ~& x: E% d; I* O3 U/ o} // end of class ProgramCompare! f- `: [; n+ V  z6 D* z( j

' e2 w' Y3 c. \9 I! M/ _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
! R1 `8 ~" ~) \//  ProgramCompareMenu.java    Provided by: DRS
; n6 z, T" E/ m" j# z* a) i8 l//6 U0 @9 i( @8 N6 e# V
//  Calls AuthorisedUsers.java and ProgramCompare.java
. @" N% _; a$ e, Q! k, x3 k//
9 F  H- Q, B  R% p- r- m- ]* v( ?/ v//  Driver shell for Assignment 2.( \# {6 C+ G: L' {; J* e, P3 u  v6 o
//********************************************************************
; E, o8 Z9 V. H* j8 |3 N  m" o/ Y& @8 i8 u- W
class ProgramCompareMenu
# [3 k5 e5 u8 v2 K{
, i$ P5 ~" v* a" z2 W8 x: I    public static void main (String[] args)
/ R; V) v- L, Y! J            {
. e) w3 K4 Z  |; G" \/ Z0 k# O/ U                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% G7 X- }% R8 A& b  V! c                ProgramCompare reached1 = new ProgramCompare();
- t4 p0 u  [: U& X9 Z/ T                AuthorisedUsers reached2 = new AuthorisedUsers();       
( v: Q! ?% O# C3 C; h3 Z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 o. a) J9 R' u  ]5 a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        " U8 F! l; e- I' |" }) m
        }
; W! E* ^) d! Y& `}// end of class ProgramCompareMenu% F7 c* b5 }- {' q9 M% f3 H
: C7 \1 c) j2 Z. z4 Y+ ?( T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  y. x+ w0 l) y5 |; U  R
//          AuthorisedUsers.java          Provided by: DRS
& ]/ t8 [; l) N" R) z//               
( ?- l1 p9 s$ j* F5 S//         Program shell for Assignment 27 v  w" R1 Q# h6 ^* U/ j$ k
//- ]5 c/ e& Y) n; W3 m
//         Represents facts about an AuthorisedUser9 |- O. _  p  V' E
//********************************************************************
  Y0 r/ O! t! m7 @- Q2 G
* R- ^  z6 Y' u! _* f- A6 Q: bpublic class AuthorisedUsers
% T5 u3 a" [2 p- W( W    {
4 u% k* [, w$ c6 v
/ }" q9 h3 B- c        //-----------------------------------------------------------------$ l8 r0 J2 x3 R( t5 J
        // Constructor
' F" L; f* S- t  L& t        //-----------------------------------------------------------------
1 k& y  o; N9 H# n8 E( s9 J/ G; E# X7 A1 D9 D
        public AuthorisedUsers()
. [! i+ M; g& I* S; z! S  |                {" E7 @' G* m1 I/ Y/ t! c
                }! F% {- X$ v& i% ^% R& ~

. ?0 P# V. s% s2 x% c        //-----------------------------------------------------------------5 k% @; O; w' {2 J/ k) o& X' B& n/ d
        // Method for testing that class has been reached
2 r7 I0 ?  V% o* |, I6 O, A        //-----------------------------------------------------------------        / O4 g) P% c" [9 B% M5 D7 m/ _
        public boolean AuthorisedUsersReached()
. f, i( J7 ~3 X. |/ }4 Q$ ^                {
7 I2 h% ^6 z6 l1 Q) @, Q/ I                        return true;                        5 l3 F( H8 t9 Z8 ]$ x, l
                }7 y: B, L" K6 E* ?
               
% l% h- N' O' ]8 N    } // end of class AuthorisedUsers0 X9 e- g, a" s6 ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 v; `# t4 _) x/ ?; RShanghai - 2007
  P( b$ C( o" G6 B3 @1 W( Z$ bAssignment 2
9 i3 q" r7 Y# B% f7 n& W. Z5 lDeadline 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)
6 n5 o  a7 R# e% G- Z% L" P1. 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.- ~- \1 d. d, A: R1 z6 V
The staff must be able to:
' _' h7 u# \- y Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. s6 e  i  d; h5 A
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.
4 f0 @/ Y* h4 Q: x4 s The interface should provide a menu so that the staff can:- }0 c# I* V: I3 f2 o
a) Enter the names of the two Java program files to be compared
  y* H* x; J' m/ b For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 W- q$ k% K' a* H** 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).
5 w$ w3 {- _- [: x1 FBSA104 Business Programming – 2007: Assignment 2; b* I: V. v4 D: w" }1 }" l
Page 2 of 5/ m7 l9 H1 m7 {% ~- ~
b) Print out to the screen all the lines of code that are the same
$ U6 _# m, R- m1 S0 P) x Include the name of the file and the line number of the code being printed for each of the two files
9 m. p# ^' \; M1 s8 p4 x9 T, @1 H- \c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 Q3 [* F) {# o( A' q
 the name, username and department of the user  c! s% i, J3 F5 t5 w7 y. n
 the statistics of the comparison
" Z% O& x8 H% N- Y+ B% }- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different  ^$ m/ n5 P* B; T' ]
 the recommendation for further checking
% [8 J- W% d. k4 F1 u3 g- 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
, Z( k. _- N. C the names of the two files compared
5 w/ ~% s) ?" E- C3 o  v: n5 [1 ud) Leave the program (exit)5 h0 S7 p2 F$ ]# f- j* h
The ProgramCompare class: (Total maximum 20 marks available)# O' V' \$ g7 B9 O* p
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)) X3 v6 S8 n4 v: i8 I
a) provide an error message if the files are not found or there is a problem opening them
6 A* b  V# R# {; Db) compare each line of code" C' |! o" I5 s: U
c) print out the lines that are the same9 J: I( M6 X: R' u( s. l
d) count the number of lines compared / lines the same
$ f0 F. u! Q0 q0 ~' V) X; jThe AuthorisedUsers class: (Total maximum 20 marks available)
' b1 z! E/ @$ Z2 b" m$ g- M0 P3. 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)
1 e* A. _! N5 X$ S( \4. Provide methods to:' p, T# |( v; v5 W4 I2 |3 v: S
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
/ y# o( `, c0 |1 o9 h2 Ib) return the name of the authorised user
: h3 `/ B5 d0 S. l( Dc) return the name of the department of the authorised user
* V1 ^/ N% P9 F. x) VIndividual Data (Maximum 20 marks available)
% U( X1 F0 Q9 ~' o8 X6 Z5. 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.
9 e9 R! X7 B, A. e( K, B; nDocumentation (Maximum 10 marks available)9 L: x4 o  v9 ]: K& K
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.% w0 a8 m  u: ], t, A: H
BSA104 Business Programming – 2007: Assignment 20 t# M- u4 H4 v. r* F
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 l& b' t0 x" ~7 @% Z" q
不过你要翻JAVA的类库说明。你有下载没有?5 M( [* d; |: ~
查询关于对比的函数。貌似关键字是contrast,还有compare
: z2 A" C* V9 l/ [6 O1 ?, ?; R$ [6 l6 M$ J2 l- s
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 B1 i9 T* t) g: i+ h痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: J, i. H9 }% e" l, b. m可以下载到的 是 jdk-1_X_0-doc; u$ L  G# o) O0 W
' A# V2 M! U% ^6 I/ d8 b7 Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-26 01:41

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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