找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1299|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 + E, t! ?( u* A2 o7 K: I 3 ?* {- q7 N( z/ v1 D
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
2 P8 n8 a( s! I+ L3 n//  ProgramCompare.java         Provided by: DRS
0 I3 `- ]- l# p, R' f# [//- W) S7 P/ B* g) m; [: Z
//  Program shell for Assignment 2' K) D* [8 ~7 ]) _
/// B* P! ]6 `/ h8 _( V' ^: o! k2 H: Z
//  Compares two text files line by line5 v8 G. \. r5 y( g* Q, I  D
//*********************************************************************4 c/ X6 e: `1 Q) d% S/ a- z$ N

/ |; O- [: r9 z) s, G6 {import java.io.*;9 M: P0 l" n4 p  y

7 W% `$ x- e* k. b, [' z  qpublic class ProgramCompare6 [: V# h, w  U6 t
{
& w- W+ G1 Q' h: I! S8 W: m        //-----------------------------------------------------------------
: D1 [* v( ~2 M0 S6 h        // Constructor+ a" e5 ]+ x( l. V) W, F  r" I4 b) [
        //-----------------------------------------------------------------$ o; U" }5 l3 z
        public ProgramCompare()1 H1 B3 u; A& d8 J
        {1 L# }0 x1 @9 D) H( G
        }
  r4 \* z) U. ~$ H7 L  c0 ?, T6 X+ {( T% p7 Q
        //-----------------------------------------------------------------  L' H( [: a  [8 [( H
        // Method for testing that class has been reached) g, ~1 t0 @  o0 t0 {, k
        //-----------------------------------------------------------------       
5 g0 i. U3 L) i5 E0 h6 P' f+ J# \7 d4 d8 j9 [& x4 ]
        public boolean ProgramCompareReached()         8 }& I5 G, G+ x' R' a
        {8 k9 k9 R+ c- _' u/ g
      try 8 F  V, m9 O1 Q
   {         % O9 }3 F* i* D' n2 ^- h
                        1 y: b/ A2 @% w0 ]0 H
                //********************************************************************* Y  P1 c0 F7 V& y5 T
                // Try-Catch Statement is used to handle exceptions - such as file not found
( X  y# C6 P2 z8 w  h9 U                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 o" q$ J; ]! W                // For more information see page 534 of the textbook- X( a6 j. l# e& H$ e3 i$ c
                //********************************************************************
, {7 f" I: i7 m$ x3 E                    
* d7 O: U: [0 B# ~  ^        }
" U, i# t2 h' l) i, ^* C             catch (Exception ex) // Exception caught here and message displayed to the screen ( C3 i( U: v6 c- G( P% w
          {
5 n- w1 M* H7 M; g* P# Q8 s                    ex.printStackTrace (System.err);" F, z* ^  o" }$ |9 T# U5 Q: ]
           System.out.println ("Error message goes here"); // Replace this error message with your own         
! L& g2 |% |" s        }
. g9 r5 i4 d: W) G$ p. u                return true;
* m8 H6 }: S4 V8 M        }" ?- G( K4 v- `9 `' O2 {
: M3 D2 c9 L1 W1 o
} // end of class ProgramCompare1 E! U) r- T+ z: J7 ^# {/ x: [

0 [% X8 i5 l& B  f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
! u# {  o0 Y; V% i- Y: b//  ProgramCompareMenu.java    Provided by: DRS# D1 @# W. T' F6 s( g& h
//
4 ]: G7 S( D( x4 r6 K/ [( i! w//  Calls AuthorisedUsers.java and ProgramCompare.java# `% B- R6 ]& p( L  H5 g& W8 W- H' r
//
! B3 P" M# ~* m1 b  P7 x//  Driver shell for Assignment 2.
. f9 R) _, w+ U" I9 i2 ?9 X8 e//********************************************************************
* {0 q6 _' j- g' r( K  Y0 {  O  H' d3 s( ]$ i
class ProgramCompareMenu
6 a4 i9 N  ^9 k  w/ a{
4 F( u* w6 u8 f) r4 S0 a1 e    public static void main (String[] args)
' n3 [3 k0 V* Q4 p/ h            {6 C0 S  t2 p* {6 O4 m& S4 p# Z
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 n& s3 P( ~9 t$ s; `. [
                ProgramCompare reached1 = new ProgramCompare(); $ F+ P, T0 `8 j# K( N
                AuthorisedUsers reached2 = new AuthorisedUsers();       
, W' n5 E  _- {6 L. g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! j, f$ X2 Q% C4 e9 [' @0 v                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 `7 g' f! ~6 i) a2 j
        }, W; x2 }9 K7 m* h; b: s  g
}// end of class ProgramCompareMenu% g6 Y& x: ]) d; h2 S4 I( K& {( a

& Y0 ^! f" U+ r$ B! }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! @3 S3 F# E) c, k( u//          AuthorisedUsers.java          Provided by: DRS
8 @& R7 s8 T; r7 {0 {//               
( H0 [' c* }" a//         Program shell for Assignment 2) Q5 A  s. d/ ~" T
//& ^2 s% U$ |9 k
//         Represents facts about an AuthorisedUser
  C* T- D8 l( L* s. E1 \2 A9 c//********************************************************************
" y! L1 \/ g$ q! ~8 h/ }5 K( s% P7 P* J
public class AuthorisedUsers
' k/ |0 ]) k' j  [    {
7 N5 Z' S) f2 \2 T3 J1 h
$ P" V6 A, ]; u9 O& S        //-----------------------------------------------------------------
& T0 ^% g" h/ \) x, Z5 B) G' e8 U        // Constructor8 Q" ~& t" m, |" H6 S
        //-----------------------------------------------------------------
8 r3 {' ~- l( ~8 o7 ?9 `* y9 `2 |4 d9 D
        public AuthorisedUsers()) F+ A$ N5 ^" }. v
                {; s( b- P6 \% D# T5 }0 f5 h
                }
# n4 ^% B, u6 b9 k$ {" {, a
; a, m) O1 C* \2 R& ]9 [        //-----------------------------------------------------------------
2 x% ]' J% [  E        // Method for testing that class has been reached+ E0 r6 ]3 B7 O, [
        //-----------------------------------------------------------------       
; Y/ K0 l! Z6 G        public boolean AuthorisedUsersReached()7 ^; ^) P' N3 v* h
                {
% W# j0 w2 B; ?0 L1 ~                        return true;                       
6 e" G* _+ K* p) ?* V, }                }
. |5 \+ Q0 z  J2 ~                * @6 }( o/ `0 u" y( }7 i: u
    } // end of class AuthorisedUsers
$ `* z* u. R) K8 ]2 b6 ^1 V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming7 h+ ^( T+ L% m7 T7 F
Shanghai - 2007" o5 j) {& l& |
Assignment 2' C; U' y& c* x2 P1 _; i' `) a
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)4 w# B0 e. I! {  \  |
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.
3 G4 D1 l* F5 J4 d2 K4 ^The staff must be able to:7 w3 Z9 S1 M9 `! w. r4 v
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 h( X; M. }% D4 J- L* d
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.
2 o. [8 Q3 G6 e* J7 |! E/ w& K The interface should provide a menu so that the staff can:" E0 o! q/ L# r) q
a) Enter the names of the two Java program files to be compared
2 C1 g! g% k) s% ^- G; d For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
! N3 {5 k* G  H# |( d, v; W) r** 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).
) Q' L0 m, X" e# a$ i- q4 l& s) wBSA104 Business Programming – 2007: Assignment 21 D0 ?0 a9 N  h: B
Page 2 of 5) \+ U* g8 l/ a2 U0 I1 @+ m
b) Print out to the screen all the lines of code that are the same
' N  `: z5 ~. N5 @8 I Include the name of the file and the line number of the code being printed for each of the two files1 T6 ?9 o% M- [2 R1 }7 R' `
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 _, y- f9 ~6 l; D
 the name, username and department of the user* u& ~- |# C) M3 ?
 the statistics of the comparison
0 w. y1 }, C  N- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 e$ o, a; d8 p the recommendation for further checking
; Y! A, `! i) D! h# `- 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 closely7 O& e% G. o7 ]3 H
 the names of the two files compared
* F& i, o3 f. bd) Leave the program (exit)
3 W" X5 z/ z. w. eThe ProgramCompare class: (Total maximum 20 marks available)
# v* k% z" I4 _% c( C2. 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)
$ N1 e% u7 F# X4 ?a) provide an error message if the files are not found or there is a problem opening them2 N' d4 P; P3 S( a& S9 P1 J
b) compare each line of code9 u& R4 V' j) S" n- @" \' z9 I( M4 X
c) print out the lines that are the same9 u) `9 O7 ]; G5 J- w
d) count the number of lines compared / lines the same' b  t4 O; f5 w, g* |
The AuthorisedUsers class: (Total maximum 20 marks available)
" b5 Z6 g5 R. z2 J3 \/ W3. 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)
$ U/ X) X0 G8 x2 `$ M. y) D# A4. Provide methods to:: `# U0 C6 A4 C3 X0 n! A# H9 F( k
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
5 t# p8 B0 d# j0 a9 F, X7 Ub) return the name of the authorised user+ J, Y& ]$ Q& J
c) return the name of the department of the authorised user
0 j& i# S" f5 yIndividual Data (Maximum 20 marks available)( x3 ?5 W) ?" N- E8 ]9 }$ v
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.6 N- x, p/ k* Z" U+ X3 y
Documentation (Maximum 10 marks available)
* A+ ~( v/ J% Z5 ]( a6. 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.6 E5 J! V+ h! X5 \) i
BSA104 Business Programming – 2007: Assignment 2
" W6 W# I, Z' J( i  {Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
7 s9 m/ O4 j/ g不过你要翻JAVA的类库说明。你有下载没有?8 @, _9 b9 Y' C* X
查询关于对比的函数。貌似关键字是contrast,还有compare
" b( |. Q- g) @9 N) s
: |; O4 }+ j# \9 h- p- _' G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% z5 O' T5 a: t1 a: D" @
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。- w5 `, O7 W7 {3 `4 K! r( K, R
可以下载到的 是 jdk-1_X_0-doc
( b5 w# `  d. X* t, u4 O
) j0 U6 F, n6 S6 M[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-20 17:56

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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