找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1553|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 c% R8 @5 q. L- K$ @7 ] 4 C' W2 s0 r* _% n5 Y) P
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 w- q2 h2 t# E) |: e//  ProgramCompare.java         Provided by: DRS
$ x2 {* u6 V/ P//6 k' X$ T. Y9 \5 ], y; R! l. J  u4 L
//  Program shell for Assignment 2
1 R' l2 }5 a. l//+ \* F- t9 O7 U- _% p+ `8 N8 _
//  Compares two text files line by line# q. L) Y$ S8 ~3 t% k* p
//*********************************************************************" {# ~3 {! A! c# S
( F* R3 ?- V, z  [
import java.io.*;
. `& K* k) h% g1 u) Q) d( N' u6 O8 B& R' i
public class ProgramCompare
  K; r+ r; Q6 K" W5 Y{
, D; T' H4 S! x' Z& V1 T        //-----------------------------------------------------------------1 r) C6 `8 O9 k# D9 t( j1 M
        // Constructor5 Z$ h7 n4 F  V3 b
        //-----------------------------------------------------------------/ f3 K* o2 Y2 M
        public ProgramCompare()
- V7 G# ^/ U( c6 b        {- t# U- ~( M* u# W% j/ I
        }" M( p- X* R( x4 N1 @4 A& W

& l) f' }& G; |- g0 P! l2 Q+ ~        //-----------------------------------------------------------------) P' z/ n; T3 O) A( Z8 |
        // Method for testing that class has been reached. s9 I% w0 M$ ^3 ~; C
        //-----------------------------------------------------------------       
& m/ u0 B! ?- P9 ]1 A5 b0 A0 i, u1 z% v
        public boolean ProgramCompareReached()        
6 \, @3 Z3 T# \: a# l. J        {
8 e2 V. E  r; x. e      try & m8 c* L, v; W1 W. E
   {        
! l' F+ l7 H2 v4 [' J" z3 Q0 A3 N( k0 {                        5 y( w! b& }: L9 _! n# X, f
                //********************************************************************
) O# ^: p7 r; Z/ M  U6 g; F+ X                // Try-Catch Statement is used to handle exceptions - such as file not found
! E: `  V! }( C8 |) T% c. ?                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 g7 m' j% L" {                // For more information see page 534 of the textbook( F$ x% R/ [5 y% H& |2 o+ |! }5 Q
                //********************************************************************
6 w! u. z' H$ E5 s  ~                    
$ u+ y* U4 x( R* A/ \        }
& o8 Z6 H" S3 T6 G8 _) }             catch (Exception ex) // Exception caught here and message displayed to the screen 2 ^/ m2 c+ Q6 t$ p! x; m0 R
          {) F4 o, |4 F& V$ A. B4 ~! y
                    ex.printStackTrace (System.err);  I" m& q, A+ K9 ~3 }
           System.out.println ("Error message goes here"); // Replace this error message with your own          9 ?6 a1 z1 F/ v$ x
        }! i4 Q& p% U8 e, z- n
                return true;5 k$ _' J) p. m' F9 A& |  r
        }0 j3 g, N8 X, n) i! F

7 F) T: d' U" j1 v} // end of class ProgramCompare+ X7 x' g9 s2 z  y" D+ Q. ^+ U
0 `3 Y8 m4 c' b! Z4 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( _) s) h; Q7 W  q
//  ProgramCompareMenu.java    Provided by: DRS* h2 E% s1 V$ y' Y3 e3 E
//
, q" P& @6 }; b% K$ }% I//  Calls AuthorisedUsers.java and ProgramCompare.java# L# c3 ?. R, D( C2 [
//
1 E+ b3 |; F& _; B! t- m# M9 b& k//  Driver shell for Assignment 2.
5 ]' t6 x# d, b& H- \8 K//********************************************************************  k+ k7 |* V4 E  y
" [1 r; B; `/ {# x3 h( z  a/ s
class ProgramCompareMenu1 b6 J9 u2 A, c, T% Q& ^# Z
{
( c! S& }' c) I5 x    public static void main (String[] args)
6 q! z, W: k/ z# D5 o9 E0 D6 I/ B            {
- q! E% H( ?# W. f                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. X' D3 ^0 c, v2 ?- i                ProgramCompare reached1 = new ProgramCompare(); ; R7 j3 q) n$ f' x, |
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- z: a# S+ Y- Y6 s7 Y. N                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 p, e) u9 \& d; @
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  b5 \) u  J; H0 @6 }: e( m8 R& {  K        }/ l' L+ y$ j! g: @2 U8 ~
}// end of class ProgramCompareMenu
7 D4 D8 Y  w! _/ h- s0 P1 q" O' d& I1 Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 O! y# X5 {# `# \- V& Y//          AuthorisedUsers.java          Provided by: DRS& }  h, w5 I3 M  H7 I6 I/ d8 }9 p
//               
& A, `2 a& q% a* R//         Program shell for Assignment 2
$ v; h8 N' W1 E: f5 h" E2 Z//2 m& E! a4 \% K
//         Represents facts about an AuthorisedUser
5 a: f% r: u5 J9 N# N$ V  k//********************************************************************
. x. M/ ]1 F) D9 l0 {' [) [
0 o* u) h$ S2 E8 X2 A5 S* Ppublic class AuthorisedUsers- b" ?' E" s& L! z! e3 N
    {* A5 |- V: I/ o: S" _; |5 v

1 b! A9 Q9 s9 y  \3 ?: q) a5 C        //-----------------------------------------------------------------) g6 D$ ~: o/ A& u9 H
        // Constructor0 q& X& J% q4 G: e
        //------------------------------------------------------------------ U/ m" Z. `) ~3 P

3 @' M4 E& l4 O- Z. r, T  }4 h1 j6 l        public AuthorisedUsers()/ T$ q8 Q4 w9 I6 l$ J
                {; D$ J6 K* h' G  P$ I) i
                }  P1 r- O$ _6 O1 A$ S! h; ]9 @

& |( Y, T) [# Y. K' @- p3 h% y$ d        //-----------------------------------------------------------------
1 A) A) X. X4 A4 n) @. S        // Method for testing that class has been reached7 j) @( O( b2 ~
        //-----------------------------------------------------------------        9 C# v3 e$ u1 i2 q/ J
        public boolean AuthorisedUsersReached()  [3 V, X4 M- T: ~/ s: u
                {$ z3 c9 }9 w5 P  C
                        return true;                       
) B( P# d3 C1 O/ H                }
3 F" u/ c. c7 J' G# D% g$ r               
  f; I' [) l' p: w2 T    } // end of class AuthorisedUsers) j2 a6 ]5 T  \, \) |6 m8 ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
$ `- F# A7 O/ S( I# v6 g) tShanghai - 2007
" q9 p3 |. i) t+ s& f( q- z) k2 mAssignment 21 e0 R; s. C6 O/ F/ ^/ \0 i9 j
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)" N/ G3 {' ^& w. i9 \& D: ]$ B: }
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.
' n: @' X* J: z$ V" N6 K  G& BThe staff must be able to:0 q5 C9 f  Z# o4 U- E( r, U$ |: F( p9 \+ X
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.2 a* a3 u! U. |9 B! e2 P
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.
4 ]& e# {, o* U6 Y" ^7 [ The interface should provide a menu so that the staff can:8 \" w1 o2 j5 E; Y( m
a) Enter the names of the two Java program files to be compared0 ~' i' h4 `# e: c% @; M' d+ V
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 O5 d$ t9 l5 z, M& `& U& g8 T** 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).
4 c& L: y" {9 N( E* E& ?" {( eBSA104 Business Programming – 2007: Assignment 2
+ F; c" y8 S6 yPage 2 of 5
. k$ A3 l& _* A5 `7 F# @b) Print out to the screen all the lines of code that are the same
+ |4 u; n5 E, R Include the name of the file and the line number of the code being printed for each of the two files6 Q# ]+ }. {# E4 R
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- G' F0 X5 a7 @7 b* G the name, username and department of the user) }; I2 l5 n, V
 the statistics of the comparison  \. _9 U" w& h* r) l
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% o, D, y* |4 c/ o2 a* W the recommendation for further checking
8 }3 g, U) s* B) Y% T+ ?1 ~: 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 closely
+ Y  q6 U1 Y/ {7 D5 m  X/ t the names of the two files compared' S4 p8 Z6 K+ L% ^/ x  u! K
d) Leave the program (exit)
% k- M# s+ C9 k& N8 r5 d2 C/ _The ProgramCompare class: (Total maximum 20 marks available)
# J; {4 R& z- x9 n0 [# o+ _6 ~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)
# h5 d2 i5 o' [4 ]1 C( A& Q: Na) provide an error message if the files are not found or there is a problem opening them8 e. [4 [% X  M% F" J
b) compare each line of code
- m' O% i9 u4 H$ o" Tc) print out the lines that are the same
& ]- v, P  q. {: c' ~5 md) count the number of lines compared / lines the same
7 E2 e) u/ X$ x" q( }* b7 J8 v+ j5 PThe AuthorisedUsers class: (Total maximum 20 marks available)
1 J8 r6 R5 b0 T% k# t+ M( L: H3. 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)
% N" D3 O# K* C3 K5 ^4. Provide methods to:( u# n5 @' v' E$ P2 l. s5 M0 m6 z, O
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
6 e2 S# J' k; ?* W8 l3 sb) return the name of the authorised user
- L4 a. e* ^5 x/ o* B/ Hc) return the name of the department of the authorised user% U8 Q% G% Y1 ]
Individual Data (Maximum 20 marks available)
7 }+ Z3 s& k4 s) ^; b8 n5. 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.3 C; Z, O+ q9 }6 Z& X
Documentation (Maximum 10 marks available). Z3 n: O4 A: p6 e
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.
# d7 D/ m1 w& t, s( v' ?BSA104 Business Programming – 2007: Assignment 2
- S6 A! u) H7 c" s. KPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了6 c7 X7 J5 c8 b3 ~( b0 J) H
不过你要翻JAVA的类库说明。你有下载没有?+ G7 a# N0 }" W, E
查询关于对比的函数。貌似关键字是contrast,还有compare
' K# E' d9 l* \+ W2 x7 O, `0 L! X
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 x/ e4 S) w, z
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 h( y$ s1 \/ U' B
可以下载到的 是 jdk-1_X_0-doc/ x3 S4 l2 Z+ R+ x- G8 L' p& [

; W" m6 d  j# h6 J8 g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-20 18:25

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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