找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1637|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ y/ Y8 |9 \' p7 A C& s( P # F* W) R4 M5 H! l) \% \& 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 | 显示全部楼层
//*********************************************************************
/ N' `+ H) i* l7 l//  ProgramCompare.java         Provided by: DRS
6 M6 |9 x5 W" L9 f5 A) L4 o& D//
* _4 Q/ L+ J) `' C//  Program shell for Assignment 2
$ A3 `6 ~' ^8 ]& v//
  L" y( m1 e9 Z3 O9 z# T7 F//  Compares two text files line by line
; f% ?5 D% j2 ]  D7 p//*********************************************************************, S. ^' F; I: O! b* a! K

5 T2 o" t6 b+ Wimport java.io.*;
# B- b$ ]1 V( W( S
# c( `4 d, O' W0 ~8 d7 {: hpublic class ProgramCompare
: J; }% E$ a6 V% ?" S$ n{9 T) B3 t$ T6 y! [
        //-----------------------------------------------------------------
0 d/ p7 E3 T" y& h& j+ c. D" ^        // Constructor. @+ |% K5 g, x( m
        //-----------------------------------------------------------------
# d- m0 ~: C; I9 r        public ProgramCompare()
* P$ d5 |6 v; ~/ M, ~        {$ S% [) c, H- V4 N* b% {! q! P4 U5 \
        }# Y' H$ B* J( o6 \

' \8 Q) [& f( b8 y        //-----------------------------------------------------------------  S+ L) V8 N9 m* w: A4 h
        // Method for testing that class has been reached, V) _& c- J9 T! y7 W& q; X
        //-----------------------------------------------------------------        0 @: `5 W" _6 b3 X' Y* {
, W# e7 O2 c) g& S1 b
        public boolean ProgramCompareReached()         " o3 P6 R8 N- c/ X! d
        {
$ h* X4 b! p( N2 {$ C4 m# s      try $ Y. ~1 @3 \' \
   {         7 g0 a! a8 s  I% g: T
                       
/ g- y5 x# c- K! S, E  Y; A                //********************************************************************
8 s$ ^3 R6 x0 K! e- c' M                // Try-Catch Statement is used to handle exceptions - such as file not found * K( ]; f# F3 i0 }
                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ m& \! E4 P% T( P6 k' E. W& |% t# c6 V
                // For more information see page 534 of the textbook! \1 h+ i  O6 m, r1 F; Y0 a% G5 @
                //********************************************************************! @; `3 Z7 h! [: v  }! P7 l
                    
7 p2 J- p- m/ d. f$ ?        }
3 a* m7 v* T  @) x) ?6 `             catch (Exception ex) // Exception caught here and message displayed to the screen 3 c" L7 ]+ ^0 l& Y2 {/ y
          {3 F& t) k% _" @. a0 g
                    ex.printStackTrace (System.err);
. L1 G6 }2 s' X           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 P* z4 K# J4 t, O5 C* \1 a8 C        }3 Y' e' p4 D" y. _
                return true;
" i0 T1 {1 E1 i1 g% s        }
) m; H: _7 e8 d1 d9 f1 E4 \2 B, `7 P7 l2 r
} // end of class ProgramCompare
, J9 a) H2 M' A/ J$ n$ `/ D9 R5 J: S2 n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
& w* }0 b$ U& B+ M% \+ P! `3 }5 x//  ProgramCompareMenu.java    Provided by: DRS4 b+ b* n/ p) [8 z# J
//5 p% ?0 ?6 ~  C$ a& a
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 w2 M( s3 {# V( H//3 D0 z) v1 p: [; l. ~. W0 A
//  Driver shell for Assignment 2.
: I& g7 }" p7 k2 B9 Y! a0 H//********************************************************************
. |6 |8 q' R- o$ S/ e4 v5 E. R* Z/ E2 F: A5 b3 |& }' Z
class ProgramCompareMenu$ @) Q6 B7 ]9 T: m1 {
{
8 `4 b6 |( d  V3 F) e: o+ [    public static void main (String[] args)+ a" ~* e( e' w, t& ^9 F
            {
) F' F2 @# Q5 }$ u) ]2 U; ]- S                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& P4 A% R/ k8 ~% c/ ^) M& J' y                ProgramCompare reached1 = new ProgramCompare(); % J% q3 m" K  T5 i7 O8 \
                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 d2 s+ G+ b3 p+ R                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 h/ v8 [: O1 N                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ h. F. \% t6 U, F        }9 h7 c) k- \- U% l$ F
}// end of class ProgramCompareMenu
1 h3 _, R' ?( _$ m9 k) S9 V2 T) y3 t' e7 l' Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 h2 F, X7 @$ W8 O) Y//          AuthorisedUsers.java          Provided by: DRS
7 L; e# Z3 }2 x2 N, y//               
7 G( m% H4 k8 h4 J( Q$ G//         Program shell for Assignment 2
0 `% I8 H% n  O//
2 p% Z) F0 W( u; }//         Represents facts about an AuthorisedUser
3 H$ q9 c$ p& T9 Y//********************************************************************$ [* L$ Y. \4 F! U* B6 w# |
/ r9 B- h! r6 D" c4 q
public class AuthorisedUsers
  E1 A3 ]4 }. u3 r$ r! ~    {
2 G# ^) z" ~. h: G
9 S  ^% V6 f: L3 T  b        //-----------------------------------------------------------------5 U" r% F; U2 l. o& \  O
        // Constructor4 a# }3 l  F3 ]  L! A2 L# F
        //-----------------------------------------------------------------
0 k& B2 g4 ~4 b4 K! d3 t
, H/ z& j( K  t; e1 _, J) R; q        public AuthorisedUsers()9 z. |* \* B: Z( X
                {* n4 C! i# z' z& k
                }
; Z' R  v2 z1 a6 {  ]) E$ _  `6 V  X7 @( k3 y: _$ e. Z
        //-----------------------------------------------------------------  }3 W% B. w2 R8 ^0 \
        // Method for testing that class has been reached6 s' Q; Y- N# l$ Q0 o
        //-----------------------------------------------------------------        ) _  ^1 j1 Y# \- K
        public boolean AuthorisedUsersReached()
. V8 J* v5 ?- v: L& M                {
! k& z. ~; ~4 w  _/ @# u                        return true;                       
+ k. O" E( q) F5 x9 Z2 }3 C                }! [1 G: h$ I  |& Q! `. J8 n
               
5 R& ]) P6 o, p, w    } // end of class AuthorisedUsers" y/ J/ i- w; o' }$ U# `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( J: Z5 [& q! y6 L2 xShanghai - 2007
( V6 ]& V8 p+ Y6 k1 A$ g( r% OAssignment 2
& E" \# |) E  m, \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)
/ Z7 t' Z& |! k1 }& S6 V1. 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.
' L) T4 T4 a  l7 \2 ZThe staff must be able to:  z5 G: o% V- \% N/ q6 z3 M  ]
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! X# C8 v8 Q/ k8 U
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.9 [3 W% x9 b+ S3 Y8 u/ i$ E
 The interface should provide a menu so that the staff can:
0 w4 U3 }$ p$ `8 y4 C3 @4 m9 R4 Ma) Enter the names of the two Java program files to be compared' ^, f; G, Z( J
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: ^( p/ @& e4 W/ ~* Q  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).# R0 m/ `& W9 x( M, @; G% B
BSA104 Business Programming – 2007: Assignment 2  Z7 k! s3 X4 t- h
Page 2 of 5
& l1 w/ g- y$ hb) Print out to the screen all the lines of code that are the same9 P) |2 A9 g" L, E
 Include the name of the file and the line number of the code being printed for each of the two files% N4 S+ S' y( n3 e! d- O1 l
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ P6 E6 Y( ?. u" {8 a$ l( W5 n the name, username and department of the user; G3 x( I, Z, t- A& V
 the statistics of the comparison
* ~6 j9 f$ E1 E- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, ?9 N! t: H7 D- F
 the recommendation for further checking, v8 `1 E! j$ Z( F) n2 n
- 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- M( B# A& w/ F. I6 s4 R3 Y7 B
 the names of the two files compared
; `( r- I& P+ r8 Cd) Leave the program (exit)2 o, h8 g6 R* b8 t# V( K1 D. M
The ProgramCompare class: (Total maximum 20 marks available)
) S: v6 i" v) S: k2. 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)) c0 g+ ^0 F  k' v
a) provide an error message if the files are not found or there is a problem opening them1 c. \" }4 c, J) y4 j- c
b) compare each line of code5 W7 Y) q0 K5 [5 y& P
c) print out the lines that are the same9 M+ f0 g! _0 {
d) count the number of lines compared / lines the same
# r- G, L) _7 F+ x0 g. H4 W) n( U" OThe AuthorisedUsers class: (Total maximum 20 marks available)
( W, h6 B, U  L, `# b6 y3. 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)
" B  K' ~, g. V7 B4. Provide methods to:, u4 v: Z6 k5 u9 o' ?) g& p
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 match9 F: n" H5 F( Y# ^5 P# J0 o2 I
b) return the name of the authorised user
$ Z7 Z+ Z& ~9 w" Z* `; b" ec) return the name of the department of the authorised user3 @# L; o9 p" Y+ p
Individual Data (Maximum 20 marks available)$ ?, L" V7 o( r# 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.
0 ~# D( [8 U/ A/ j; T: I: wDocumentation (Maximum 10 marks available). k+ `% }/ {7 a- H9 g
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.
  ^. J# i$ m- Y0 m( x# m: zBSA104 Business Programming – 2007: Assignment 2! o' {# ~& B: a6 Z, ^0 o+ v
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 P; R) h1 L9 G+ c不过你要翻JAVA的类库说明。你有下载没有?. M# J( }7 U7 V3 H* [" n- t
查询关于对比的函数。貌似关键字是contrast,还有compare
/ \2 C3 ]9 y3 C# d+ @9 \& o0 a; m+ g7 S9 g1 U( [
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& N3 W/ u' L5 B" }可以下载到的 是 jdk-1_X_0-doc
- n- Y  P4 s" A) |& ^" i
( u+ w! S! z5 u" F8 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-18 02:18

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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