找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1864|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - p( |, t. d' Y) Y0 Q: ? / d/ b0 |7 N8 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 | 显示全部楼层
//*********************************************************************. _/ o$ I* f& \/ y
//  ProgramCompare.java         Provided by: DRS
2 z- l+ X% Z: G) y7 f3 Q  s. _. P' g//2 d$ q& Q+ n0 g& I' l6 A. U  M1 t6 l! F
//  Program shell for Assignment 2
+ W2 N8 W' ?6 z3 N& W0 ]4 d! U//
( z- k! ?( P3 l  K( a' E& R$ S* _//  Compares two text files line by line
* i4 P/ Q3 B8 R& C1 \//*********************************************************************; g6 d0 e+ m; g; \) t
6 O9 I* U3 ]) Y; s" R
import java.io.*;# ^# T$ F2 @0 y+ P$ ]5 I& E+ @
; q- Q6 A8 N) I! L+ N# e6 m
public class ProgramCompare
4 @2 q4 m9 ^( L1 i. t{
. d6 B- F9 X0 Y7 i; B" D! i$ [        //-----------------------------------------------------------------
8 |0 x$ y0 K4 C4 C' u0 w        // Constructor
2 d$ u0 M1 y- y+ @        //-----------------------------------------------------------------" Y+ }0 A6 r6 w9 |* S9 J9 q
        public ProgramCompare()0 {( r% b8 c5 `7 g* h
        {
* S& Q9 w, b6 J+ ?# J0 b! i        }
# x5 F" p& ]& A! ^( O2 d
9 D6 k( z) Z0 m% W; J3 W; [2 `+ q        //-----------------------------------------------------------------% }4 v9 h0 C; E2 V/ X* B" Z6 u' }
        // Method for testing that class has been reached* W$ A" K/ g& b7 K+ |. ^  R( [5 F" l
        //-----------------------------------------------------------------       
( ]& ?* t( N6 D' Y$ ?
: U: V% `, X5 A$ G+ b        public boolean ProgramCompareReached()        
4 H3 v7 G  r, S$ g1 K( t% ?        {6 Z" u9 P# z) A. v! [( w# {; _6 F
      try " w' d. O# ~% q# f
   {         3 J2 Z0 Y' n* V
                        9 \1 r8 m3 E# z! j4 K. w
                //********************************************************************
9 I  {* c5 H# }9 ^5 G# j) I5 ?7 Q                // Try-Catch Statement is used to handle exceptions - such as file not found % T7 A* E+ u7 S1 o' E
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
1 q, ]4 l( ^. C% q# A                // For more information see page 534 of the textbook% h& M* @& J0 w6 G3 e  W: V
                //********************************************************************
5 {; g- X" `  X0 T$ O; \  e1 z: y! V# A                     8 W, L+ u8 c5 N+ D# Y
        }/ X5 w+ a+ z- L( e& I5 G
             catch (Exception ex) // Exception caught here and message displayed to the screen
1 V) y- i. V, O% U          {% H6 `- f! i1 J
                    ex.printStackTrace (System.err);$ h5 \5 s( h# [6 F) Q, K" u
           System.out.println ("Error message goes here"); // Replace this error message with your own          $ ~2 F( D& N+ \# g6 H
        }- H* g7 t3 Q6 C- X& H
                return true;- q$ e0 B1 c* U
        }4 H2 k9 b& w( H8 `

4 {: s( l$ ?' g# D+ x- }3 E0 ]) e! w} // end of class ProgramCompare
# {7 K$ h: Z$ R) o
6 |; v- w" v$ z& H- U- t0 s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( j' d9 z, m; V" I$ u, _
//  ProgramCompareMenu.java    Provided by: DRS
- P: V. i# |& D  G" a//5 T/ Q" }4 W& P# I$ G+ Z2 r5 S$ H
//  Calls AuthorisedUsers.java and ProgramCompare.java
2 G4 B: e; B  E0 U1 C! }//7 s5 Q- _7 d" N" m/ h) i/ P
//  Driver shell for Assignment 2.
% j# ~/ k' n' K* i& V# m6 Y, p//********************************************************************- \7 p9 t/ a) Q. y
# b) S3 P9 ]7 y0 W5 v' I3 n
class ProgramCompareMenu
: j( S. }" {6 d% G. m{
, a- q5 |' G4 B. I- U# q    public static void main (String[] args)
- [. z1 O% M  b, ^6 p            {
/ I# M% L( k; w  t8 L                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable% v0 ^# R( d* ?# Z- w- k" i
                ProgramCompare reached1 = new ProgramCompare();
" `& D$ G  V: C$ j' F7 U% U                AuthorisedUsers reached2 = new AuthorisedUsers();       
0 i; |* u3 s3 ]; t& L4 f# b) `                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# {0 l) w, L) [2 _
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 g. }' B# }6 j" ^' F! n        }
7 b! h5 p* P% `+ `}// end of class ProgramCompareMenu
+ n+ Q  ^, P8 Y+ [7 a) X) ?/ K/ |( h0 u6 a; y- k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, R2 B( K' c* V" f' N5 R1 D( p
//          AuthorisedUsers.java          Provided by: DRS
; v; r6 S0 F+ H3 k" i//               
" o3 O8 o, P7 J( z, g# l2 D//         Program shell for Assignment 2
- o/ H- `/ A% J: i//
( n+ u5 h# D3 F' p7 `//         Represents facts about an AuthorisedUser( X! O9 b8 A$ j9 o
//********************************************************************% J- j* Q  [2 r0 J- y
( Y; H' K6 ^# l) V2 i
public class AuthorisedUsers
" B4 l" ~8 \' y+ @6 k: w    {
* D: g4 b# U7 c( v# P  z0 ~
7 F& l  @7 K. @- f* Y' ^        //-----------------------------------------------------------------
7 ^/ n# y  B% @( |, p        // Constructor; [* B0 e, b5 i
        //-----------------------------------------------------------------
- p, K" z4 e& i$ ]3 Y! U% S# V" g! m! f8 y7 g; N- S. y( W
        public AuthorisedUsers()$ m; j+ E6 j- L7 R
                {
/ e! X* C7 i. R% f- g                }4 m. u8 r, v# k( @8 s
2 o- H& F* x0 Y- t
        //-----------------------------------------------------------------
/ w4 m& J0 ~! g. C        // Method for testing that class has been reached& h! L4 n" C* _1 F1 K
        //-----------------------------------------------------------------        0 ?% g) _1 u+ d. X
        public boolean AuthorisedUsersReached()
% p2 a8 ]$ `9 U) C/ ^6 r                {
$ K; C& l6 P5 [                        return true;                        ( `8 i5 Y6 P7 |/ F# [
                }6 a/ V) U0 W/ R6 H9 i0 A
                & W* P3 |' B3 t) h$ y! _1 i# h- R+ Z# A
    } // end of class AuthorisedUsers3 U0 {9 R7 q2 J: l; {# \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
% k- x2 _; x0 P( ], TShanghai - 2007$ z2 e. N! z7 Q  N; ?
Assignment 20 a4 ~/ }6 E# G
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)
2 a  Y. P2 @/ C; Y  H# X- i# h, e1. 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., B- T, L5 G) A0 I# {( I
The staff must be able to:
7 @" y& e9 @; d5 P. P Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 |5 z2 g$ t2 K, z/ Q1. 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.
& u2 v4 K' d# j& I/ C: s6 S The interface should provide a menu so that the staff can:
0 g5 W! n6 ^/ p6 Za) Enter the names of the two Java program files to be compared* a" K/ D2 D5 Y0 R# }' l: u" F
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
/ x/ J9 c  g% K** 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).
# y2 Q' F$ U0 qBSA104 Business Programming – 2007: Assignment 2
7 P' e' z" D. `- E, zPage 2 of 5
& b- s+ ?0 _6 T0 jb) Print out to the screen all the lines of code that are the same1 a6 J  u8 g7 X: E
 Include the name of the file and the line number of the code being printed for each of the two files3 r4 d3 {3 }) H7 E
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# c, G$ `1 D0 Z  O, i
 the name, username and department of the user
( K: u" B1 \4 s the statistics of the comparison
! @3 M  I) Z9 n  w- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" r' e0 k- p; B- x4 p2 W" ^
 the recommendation for further checking  l) F( I4 w7 Q+ n  V0 F
- 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 closely4 z" {- V5 \6 f1 P( m/ B
 the names of the two files compared% ?4 Z9 c+ \. o" {" `
d) Leave the program (exit). l0 v  \% |* p9 ^
The ProgramCompare class: (Total maximum 20 marks available)/ p1 {, ^2 _3 U( ]# r  N
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)  B9 k- u: ?- A  m" I  ~( G) B% E
a) provide an error message if the files are not found or there is a problem opening them
( f7 ^( g0 A, nb) compare each line of code0 L% S+ z6 x; z1 @! P' S
c) print out the lines that are the same  O3 f* ?+ x" w* ~  D/ ^4 Y" f6 [
d) count the number of lines compared / lines the same9 i8 ]5 J  x. j/ ~6 K/ [. N" l% S  J
The AuthorisedUsers class: (Total maximum 20 marks available)- k& w, z) B5 u: u/ d
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): d9 {2 M) `  Y2 x) r7 u2 C
4. Provide methods to:! c" r& Y/ k, f# _
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 match8 s) j7 u- ^. a2 \6 [0 j1 |" E
b) return the name of the authorised user
' F/ o* ?- y$ Q8 H5 S8 ]c) return the name of the department of the authorised user. q7 C' W' r1 v( Q
Individual Data (Maximum 20 marks available)# D) R' r7 o4 I% Z" J
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.5 M- ^7 b; `* n4 l% i/ y
Documentation (Maximum 10 marks available)
& O" ~) B. j9 n, g2 l6. 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.
& h* p, g% {  M+ Z# k% J/ u$ tBSA104 Business Programming – 2007: Assignment 2
2 H/ h; o' n0 g' E0 P3 H" sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# m6 F. \- q2 I& U' o5 h2 P
不过你要翻JAVA的类库说明。你有下载没有?6 H/ z/ G1 x+ {& W
查询关于对比的函数。貌似关键字是contrast,还有compare
5 L" \# Q) |. n" K" I# {
$ s4 `; f( i3 D& ^% @' X" J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
0 \+ \% T, n; u. H7 b痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 o: I; {) y. o, u* t# [( ^/ U
可以下载到的 是 jdk-1_X_0-doc# c& o9 Y, y/ Y7 |+ G) [
8 M: @6 q: ^, g5 o. K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-30 00:38

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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