找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1398|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 m" Y- |# [ i, ?" X! L # s) r6 j1 D6 [1 k9 ~# U3 e
回复

使用道具 举报

 楼主| 发表于 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( x/ h& }! Z' g2 I* {2 Q//  ProgramCompare.java         Provided by: DRS
* a4 b" g9 v/ {* C% P//8 J) y2 f; ]* v& X2 l1 S
//  Program shell for Assignment 2
$ j3 u+ S2 \% N+ }//' e: M, w! b  }
//  Compares two text files line by line
- |0 z# ~  w; {. u' z  x7 e, j7 X; A//*********************************************************************
8 {. O" K% s, \" ~9 w7 v: j0 ~
! f5 S+ {" s2 d9 c2 ~import java.io.*;
" {- u0 @9 ^3 N# X' ]
+ ~+ d" r5 }/ c& Rpublic class ProgramCompare/ @! ^; D& r" v( K: R& M4 \/ H( R' f4 V
{
# O/ e$ V8 y* p' I        //-----------------------------------------------------------------
  \9 U3 x+ |" Z, @        // Constructor) b  i6 k" F$ {% k5 Q) o: X7 `# q
        //-----------------------------------------------------------------+ c) M7 k3 o# i# \1 E) a9 V! H
        public ProgramCompare()
" ]+ V* k( E1 ^/ i% Q        {  p' r- a" `8 O6 m
        }
, x, _7 v- n5 R% [1 [8 d7 S$ w6 J* ?' U+ H8 ]) N' @5 w7 [
        //-----------------------------------------------------------------6 q0 T  w7 E" ?6 \5 }2 V! u& |
        // Method for testing that class has been reached: L3 U& a) {! A1 d% i4 ]" [, X- _/ `6 W
        //-----------------------------------------------------------------        1 G( t; A6 {% @/ s! f
$ d) w4 k# ?" E
        public boolean ProgramCompareReached()         1 _9 W# O1 Z0 T6 e8 C$ r7 r  g; `
        {" o* E5 _% t9 `) F  ^4 n
      try 8 ?7 I" f. m$ q) v( v+ Q
   {        
" x2 L* u/ T9 X& a2 R/ Q                        6 V3 ^  L6 y! c$ b
                //********************************************************************( U/ U% B8 \! y: ]+ G
                // Try-Catch Statement is used to handle exceptions - such as file not found ) c  g! B, u, M( E0 m  y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!; Q% K& Q4 Q+ O5 r" \3 x: D  A3 G. Y
                // For more information see page 534 of the textbook
# s% Y. e' L3 U. F                //********************************************************************" L3 J: I. h. h% Y
                     4 }3 s1 V0 a, I% e5 ?1 F
        }
( ~+ y9 C# m( y; F             catch (Exception ex) // Exception caught here and message displayed to the screen ) g& d' p9 [. @! {2 e8 t9 W9 `; x
          {
( ?( i% ^# B( s: A+ J3 p                    ex.printStackTrace (System.err);% c6 r) M, x3 w. H$ T
           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 c2 s8 s0 S, w( o2 v" V: _        }. j, F( Y; v' |4 O
                return true;
, h: c" x" {6 X6 K' f5 x1 v% k        }; Z* K2 \3 ]) [
) T& b& f$ H+ H6 D$ o# S1 h7 {+ p
} // end of class ProgramCompare
. \4 x0 r, i/ R8 w0 }, x
: V4 s$ ?6 R# h" ?+ t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! [$ O+ _& @3 z8 y
//  ProgramCompareMenu.java    Provided by: DRS' q; |( C* J# a
//
" q1 s. c5 K7 v. r6 y6 y//  Calls AuthorisedUsers.java and ProgramCompare.java
% z; P$ X/ b6 Y3 r//7 _; d8 Z0 R; D/ r0 T. F4 q$ z
//  Driver shell for Assignment 2.1 _7 Y3 d' l; o  p" ?- `' E! T* m
//********************************************************************
8 M1 ~8 [5 Z6 X" Y8 {9 ~* C0 [8 ~5 z8 y1 u( A7 G! M( L/ a3 P
class ProgramCompareMenu6 q4 k, Q. N4 }" }
{
# N4 @3 Q5 h# m- U    public static void main (String[] args). C- m$ D- _$ v+ s9 L. W  z
            {" [- w9 R# n/ V( x/ u
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 Z; q3 ^" q3 z
                ProgramCompare reached1 = new ProgramCompare(); : E  M' a4 q2 R
                AuthorisedUsers reached2 = new AuthorisedUsers();        " H2 D1 c; Z( [( _
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 v% }: {7 }) h2 c" n! n
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * V, M5 ~6 e8 T( d- J( R
        }* L( n7 i* o* Y3 r# V0 b
}// end of class ProgramCompareMenu
% b, K' D. E6 }" v( a5 x
/ N! r( i# O7 \% p2 ]% D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 }& h) ]% a6 G" V# M0 {% P) ], r) y//          AuthorisedUsers.java          Provided by: DRS
2 v& |( R) c+ E$ K//               
$ ?% |9 r$ o- f# Q! @//         Program shell for Assignment 2& H+ g& ]. ~2 {: K* c
//1 U5 Z$ a  E2 I: J2 \
//         Represents facts about an AuthorisedUser
* L: ^) {% ]9 T0 Q1 }1 |//********************************************************************; ?0 m. ]& V: @4 R7 D
8 e: c# S. E; d, k5 X
public class AuthorisedUsers
8 H0 d, x+ o/ z    {
3 j/ B; m& O: w& E' U' K! |+ }4 s% ^, \$ D6 x+ ?! h. K
        //-----------------------------------------------------------------% n  b, \7 ~2 s% |
        // Constructor+ Q8 y9 T1 q3 O$ }$ G
        //-----------------------------------------------------------------
/ J  H2 Z! P* C: l/ e* w
) T* ?( w, _  G/ S' M( _: H        public AuthorisedUsers()9 T) k- n0 k1 \0 h  I
                {
6 F: V) F! d$ w                }
. Q; v( ~% A8 J5 s7 K. s1 \' T# ~5 O' g' D
        //-----------------------------------------------------------------3 Q( F/ i1 ^, d0 e0 T
        // Method for testing that class has been reached
* S  r: \6 u/ N  Q! B" B0 m        //-----------------------------------------------------------------       
, m2 \  ]' ?& f, Y! F2 C        public boolean AuthorisedUsersReached()
9 K0 {3 [: D/ l& B8 y  B0 X                {
6 s8 ]1 G; k  [2 \3 X) C5 p                        return true;                        0 R! l4 R$ X$ J5 a, N7 H
                }1 j9 w2 i- i! h9 j5 J  c
                - M3 P& U! {" Z0 Y. a. o9 g
    } // end of class AuthorisedUsers% d7 z2 g# K9 R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 O  {0 y" I: w8 JShanghai - 2007
- L* |: w- D' }* V5 ]Assignment 2
. I  L1 b. X( d0 z$ e; x( GDeadline 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)1 A( z  H& O0 P% p; A/ @  |3 R
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.! R+ ?- f3 T4 Z' R. y
The staff must be able to:
- N2 C1 x7 m: q/ A% A( v Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: ]8 h% w( f) m1. 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.
* w: y7 {" h! _ The interface should provide a menu so that the staff can:
. ^# c# I& Q& o9 P( S# Ja) Enter the names of the two Java program files to be compared; p9 z5 y( v$ F' W# }5 u
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program." A, I% {3 l/ i  [
** 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).
  t# m; X; P- y( l: K. FBSA104 Business Programming – 2007: Assignment 2
3 ?! ^( M7 {* m3 p: WPage 2 of 5* d8 U/ P4 g3 B7 ?8 v, h& `+ R: t% F
b) Print out to the screen all the lines of code that are the same! [2 z; u4 d) L; ?; o
 Include the name of the file and the line number of the code being printed for each of the two files
/ }! I) z( q' E' q* K, f) Ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 \5 m& l  s6 T0 E! K
 the name, username and department of the user
5 L' ], B1 O3 z2 q4 T( w the statistics of the comparison& q& @4 V! c* P7 `4 J  @
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ A: F- B5 p: q3 m
 the recommendation for further checking
8 R5 T# N3 Y' S; Y2 M# q- 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: j: S" L- w" Y# D" w7 ^
 the names of the two files compared# V; s) M7 d& v$ p
d) Leave the program (exit)9 n; Q  {) c4 |" ^0 m& W
The ProgramCompare class: (Total maximum 20 marks available)
9 N% Q$ B( N: K0 r+ B6 E2. 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)
6 J+ C, b2 H( y/ W/ H9 j, h4 ?0 ]8 {a) provide an error message if the files are not found or there is a problem opening them
/ n5 X  D8 V0 J9 db) compare each line of code
1 S2 Y5 c7 u) t" J) B9 B  E6 Hc) print out the lines that are the same" n- L( z- \- G4 J- r
d) count the number of lines compared / lines the same* B) P, W) [5 H9 T' ], Y7 p( D
The AuthorisedUsers class: (Total maximum 20 marks available)/ l5 g! C# x  [- \
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)
* ~. ]. ^- z- a$ h4. Provide methods to:
$ a* E' t6 a; e/ t1 Q! 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 match/ J4 k) z5 o" Y' X- h0 ^% h; J, w* r
b) return the name of the authorised user
; h+ l0 G, i  `( Z) L  C+ Dc) return the name of the department of the authorised user
% b  [& n; ]) i9 {/ e: ?- kIndividual Data (Maximum 20 marks available)" s' F! X  j* o6 O0 c
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.
7 Y1 y. O7 E2 t7 wDocumentation (Maximum 10 marks available)( c. f5 R$ q* ^( r: V# o8 |
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.2 }% ~2 J$ ]# r# {: t
BSA104 Business Programming – 2007: Assignment 2
5 T# {5 b& Q" BPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 f! N6 X, c8 Y不过你要翻JAVA的类库说明。你有下载没有?
8 t* K9 U; Z* I0 S& F! K查询关于对比的函数。貌似关键字是contrast,还有compare- t. C: B' k* N; X2 d4 p
/ `  h9 `( b& |& l2 n/ }
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
! ~$ s2 g4 O5 y" j  E) V& c, z痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 j. j4 x0 f: P& y) l$ J! V
可以下载到的 是 jdk-1_X_0-doc* r( o$ W* v" A1 P% B- _

5 n; ]/ p) }& z8 B0 W0 ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-21 07:48

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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