找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1195|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急; @) |% a" y1 q# v& T 6 S# N5 L! S A J, l" E: i' J9 \
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% z; ]7 N) R- v" w+ \7 d2 k
//  ProgramCompare.java         Provided by: DRS7 a9 }' x( a0 }" o8 r, F$ u+ g
//. C& `/ y* u9 d$ j( W
//  Program shell for Assignment 2
8 S' b+ X" }" ^( G- [! E//2 H  y6 x* z! A& y; N7 `% R
//  Compares two text files line by line
  x( d0 |" L( f  v: v+ |//*********************************************************************
: m+ @7 |- J- X! N+ p# p0 d5 g4 t' |+ Y: J2 F5 j. U7 O, r
import java.io.*;
7 g  j, H, R$ T2 ]0 j
# x4 H% @0 t- @( J3 Hpublic class ProgramCompare; d( u$ m" S. ]9 k+ v! J$ C) L( f( R
{
) R' t9 v& H1 r/ p$ g* x        //-----------------------------------------------------------------
& [0 p; m5 j2 T& S1 P        // Constructor
9 p( N" T$ Q2 W  M        //-----------------------------------------------------------------
" s# _% O4 O4 ?1 U' W/ y+ k& p        public ProgramCompare(), C7 Q6 E- i! {" x. U# P9 y; X: \
        {
9 E+ V6 H5 G( v4 P# @8 G3 t5 O+ o        }2 s( J$ ?# ?# }/ J" P

! Q! v3 T8 W6 [  P" r) }5 ~        //-----------------------------------------------------------------' }7 c' y+ F( M1 j
        // Method for testing that class has been reached
$ a2 ]8 I# L0 ~6 k' ]: O        //-----------------------------------------------------------------        # V/ ?6 o4 M0 T: A+ a( p: s
  ^" Q9 J. d7 Y. [. e8 Q* c  O: ?2 J
        public boolean ProgramCompareReached()        
3 A0 h/ f7 G; R5 O4 B7 [7 z6 R4 Q8 H        {
% z: x8 c' C) ]! a/ o      try
0 F, U- Z4 a: ^# Y   {         : s: V- P7 d6 X$ ~  D2 U; R
                       
5 I/ q3 N" ^* Z                //********************************************************************4 s  K* A/ [) y$ i" }
                // Try-Catch Statement is used to handle exceptions - such as file not found
' B0 k" }  t% ?6 s                // Reading the files will need to be placed inside a Try-Catch - just like this one!% \6 z& A5 X# E  n% G! q
                // For more information see page 534 of the textbook" Q7 M  v6 s0 z, {, S3 |
                //********************************************************************$ T  y$ m0 m2 U
                       W* P6 h. m* i+ Q
        }3 D) w/ R" Y! X7 L1 {9 z% u
             catch (Exception ex) // Exception caught here and message displayed to the screen 8 }, \. Q0 T0 x6 m
          {2 Z( |4 ]1 |* C, \/ l1 F, {2 R
                    ex.printStackTrace (System.err);- B- S+ @( x! U3 u0 Q
           System.out.println ("Error message goes here"); // Replace this error message with your own          ; L# [' h/ t6 }
        }
% O' n) e- [* W7 I$ r- w( m3 @                return true;  ?) ?$ [# g8 A$ m+ Y" C5 \2 ^
        }
9 q6 g3 {6 u- g3 Y7 S
" ^+ M# d9 |2 l} // end of class ProgramCompare
9 a7 k& Q4 b' b, e; B) h7 v6 w# ]3 M& e7 h9 Y6 t: }' L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* {. t7 e- R4 H//  ProgramCompareMenu.java    Provided by: DRS  r7 p" @4 L  u& Z! H# [
//
5 V7 t% n9 [& C" ]4 k* q3 D4 X//  Calls AuthorisedUsers.java and ProgramCompare.java
. |6 z# f0 b! a. W//
- f" c2 }: x) M6 c//  Driver shell for Assignment 2.2 y2 X& }$ P% d, Q7 @4 s* C
//********************************************************************
/ @( x# d/ {+ E# A: \2 E# e9 v$ y- r7 E# s0 K; ~+ W
class ProgramCompareMenu
, I' u- f* o( N) r* B{
' i$ R: R0 I7 @; f% V    public static void main (String[] args); K8 H" s; s% `6 I! E
            {
  L6 }& I$ y. k5 ]/ H. e1 b                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable+ \' s) C, F9 A, y& X( H. e
                ProgramCompare reached1 = new ProgramCompare(); " m+ B: T" D+ f+ K3 G
                AuthorisedUsers reached2 = new AuthorisedUsers();        " W: G" i9 p4 G5 e, Q! W
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, Z& e6 J; m$ X7 z; b                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
2 N3 ~" f1 D( B5 g" L        }
/ P3 T% c: L4 L# W7 ~4 s# K7 F, x4 u}// end of class ProgramCompareMenu
- G* H0 k; P5 R1 Q1 X2 d
6 Z) L& R" G" ]' _) Z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ c! b4 U1 I! e3 M% W
//          AuthorisedUsers.java          Provided by: DRS
; H( \4 y& P3 R$ Q//                ( b! r; {3 L% V6 l+ L
//         Program shell for Assignment 2
: Y7 \2 R, h; |: }4 ?//! S" h- R2 F: P6 l! H
//         Represents facts about an AuthorisedUser# E- B5 j6 C/ A* ?$ C/ g
//********************************************************************" [9 ~3 {2 o7 P7 ~; w& j
' }; C% o$ j* _# s, P
public class AuthorisedUsers" D8 p8 c& `8 I% J9 t$ B, j5 [7 y
    {
9 w! v7 n. o4 n# I: ^, ?1 m" {. F8 A" V9 G; m
        //-----------------------------------------------------------------5 R' F+ d) C8 y( ^. a. I
        // Constructor6 G0 w. F1 h! U+ y
        //-----------------------------------------------------------------& w+ {+ l8 Z1 x, \- A, y: o

8 r7 k* G0 ^5 ^+ L$ K8 x# C1 u! c        public AuthorisedUsers()
* \  H0 n0 h- `2 {: i, t                {1 C- W. ~4 P+ \. z+ o
                }2 ?+ b1 z/ r% g" `8 F
( D5 l  Z" R( l8 j) c
        //-----------------------------------------------------------------
7 [; ^: Z0 \: m& D& @5 u9 x% n( F        // Method for testing that class has been reached
- z% U6 H% ~1 D: }7 U: U        //-----------------------------------------------------------------       
! ?4 V* p( k) h: X        public boolean AuthorisedUsersReached()% ], q/ z+ M+ u6 x* `
                {' i* G7 g( o* ~. [, b- ~
                        return true;                       
0 W7 F% ~1 m$ }* Z9 L: N2 H1 e. N                }( c( A$ n! T: t6 x1 C/ @4 b9 O- M
               
: G% C" D. Y( N5 m1 M0 u" i4 J    } // end of class AuthorisedUsers: g" f) C: [" b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 }* V' L& n! V3 O* _Shanghai - 2007
! s. E) t& ~3 b: O5 ^Assignment 2
) p' n; ]( N4 `$ Y+ Q& s& Z6 QDeadline 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" h! _0 r! G8 o( G1 v' ]
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.
$ t& L* M- ?* m/ V" K( Q' p5 _' _The staff must be able to:
; E( Y# f  c0 I% H9 p; s: ] Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# N: q1 z& ~( F9 J) Z( t: g
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., E/ w9 v3 _* Z' }) z
 The interface should provide a menu so that the staff can:0 d  |# j( w) S' P7 M1 V# M
a) Enter the names of the two Java program files to be compared
  n& ]$ @6 d: k5 ?% {4 y# } For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ j6 ~- k2 z6 S: [' i7 _# H9 l- |
** 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).
! @$ C5 m" ?% p3 F8 f5 T; nBSA104 Business Programming – 2007: Assignment 2
. y5 B) L2 \" b! Y: M) uPage 2 of 5- F+ p: r; s# Y- X
b) Print out to the screen all the lines of code that are the same* U' X& g6 B* U; \, F
 Include the name of the file and the line number of the code being printed for each of the two files
" C% u9 g$ k- o7 A6 v& S1 }3 gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# |/ x. f- R- J# ]  _' |3 v; b
 the name, username and department of the user$ N# q( {, E9 n; s3 q' s( a& k
 the statistics of the comparison
! `9 D# d7 b- Z$ a/ g8 k- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 W: A& x7 ^7 h+ {; V the recommendation for further checking# x& u3 U1 A8 Z3 C3 y
- 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
! n* b! t3 X7 `$ a the names of the two files compared
4 a" `" u0 V! s8 X' @8 }# ^5 K" fd) Leave the program (exit)5 `* m0 ~0 b! t2 j" X
The ProgramCompare class: (Total maximum 20 marks available)
) P# o+ K, a% v0 z4 H2. 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)
4 I2 q# }4 C; ua) provide an error message if the files are not found or there is a problem opening them7 u6 A- ?- C8 U8 W9 `. p! ~
b) compare each line of code
" I9 R+ m, g) y1 e9 t0 Kc) print out the lines that are the same% t. _' ?! z. n
d) count the number of lines compared / lines the same
1 F' z) t# b7 g* P" UThe AuthorisedUsers class: (Total maximum 20 marks available)
. c9 U9 h9 Z" z/ P/ }5 g3. 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) _3 @, W; l+ @' }4. Provide methods to:
" {! V4 x1 z4 B$ Q) _: Y( O2 Va) 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
! a; H5 w) k3 D4 F" Tb) return the name of the authorised user
; s( I0 V" g: y5 yc) return the name of the department of the authorised user& ], P+ G( ~. T8 ?
Individual Data (Maximum 20 marks available)% u$ e4 k  \2 p( e- ^( {
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.
( j' V4 l, s; k% R* r) KDocumentation (Maximum 10 marks available)
5 F! B  P% k7 z+ w7 F4 t* `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.  o, ]3 d* O1 B! s( t
BSA104 Business Programming – 2007: Assignment 2
: H& }- |" o5 E. uPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ F  C* ^+ j3 g# d3 b0 r# W/ L- E
不过你要翻JAVA的类库说明。你有下载没有?! g& w: E7 R2 }0 j' z0 I5 x/ z+ X" }
查询关于对比的函数。貌似关键字是contrast,还有compare% A) N# r5 T8 X0 W9 }! s
2 j& e/ P3 O6 N, y2 G1 Y# C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
& t9 q' ~# u& X7 a  C4 C3 P痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ o9 e  @5 t7 q8 b
可以下载到的 是 jdk-1_X_0-doc" g) h4 F9 a4 T# X

7 l& d$ E: {, a* ^, j0 J% ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-14 21:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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