找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1203|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" u4 Q- X4 o! `" {( g * a8 w0 j4 c. l1 k8 A5 A9 I
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************, F) ?, @. ~6 }# l: i7 x
//  ProgramCompare.java         Provided by: DRS
1 Y. }3 Y, e0 ]( S4 T  F" N+ _//+ R: z! }, ?* M# d6 L. T1 |
//  Program shell for Assignment 2
0 n* I2 K* f+ F) i1 q. z) H//0 s1 {% Y/ }3 |
//  Compares two text files line by line  `; T( [/ ^$ n' ^: f! ?* C: p3 m
//*********************************************************************
- x/ d1 M9 ^) t4 ?5 ^& o, \) W* C- @. [1 W$ m
import java.io.*;3 ^; i. d# [" B8 Q/ D: p+ y
9 S! }! w  f, q$ Q3 R- d
public class ProgramCompare( a5 K) l- ~( r; a3 |
{
3 B, n0 U! K# M: g        //-----------------------------------------------------------------
) R" Z# L& \; g+ S& F# l4 F% u        // Constructor+ m# I& f* G) q4 I% Z2 Q6 @
        //-----------------------------------------------------------------
, c; `/ l! p/ p0 Q2 i8 i2 P        public ProgramCompare()
- y: O$ i+ b" w4 y9 X; D9 ]        {$ o2 t" ?( d. L
        }
( |; `2 q! {! c3 @( o2 d0 I1 z2 Q/ {4 b( ~
        //-----------------------------------------------------------------
5 t$ u7 C8 u: @! U- v2 ^* M+ N& a' g- q        // Method for testing that class has been reached' K9 u5 l/ X. i* n4 n
        //-----------------------------------------------------------------       
9 ?4 N. s! V  R; F
( P1 T4 W5 \! `% g: \; Q8 L1 x        public boolean ProgramCompareReached()        
0 S! G7 `' Y, Z: r6 j: y        {
" F3 D3 X1 v9 X2 P      try
7 u( Q5 d( R/ q9 W* S. U  p! M   {         . C$ ~0 m9 J: V& l- v
                        / d, H- f" C9 S" K# h0 i
                //********************************************************************0 X* S( Y  h- f
                // Try-Catch Statement is used to handle exceptions - such as file not found & t0 p8 x7 v% {  C6 Y) z. i2 E
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
+ ^/ t& O! K* [                // For more information see page 534 of the textbook7 e9 m' @( X# g$ q
                //********************************************************************
9 G6 z! J3 q- c, ?; n                     ' S) J. b0 m  G4 B5 W
        }
4 x! [0 L" {. X0 `, u' s- W0 d             catch (Exception ex) // Exception caught here and message displayed to the screen 2 Q$ U2 [! b3 }4 l* x; Y; c
          {
( U; ^7 p# z- k6 x                    ex.printStackTrace (System.err);3 @* B5 m3 y" [8 D4 I
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- j5 E6 ~9 c1 O' A        }2 n' W5 q' W5 a1 U& E) f4 Z
                return true;
; K- X# L  j0 k6 m        }8 g+ J4 W5 ?6 m+ I& Z. ?. v, {' ^
; ]9 `# Q& m5 Q3 Q
} // end of class ProgramCompare
1 v2 C, D. t5 \. Q* l, k( ~
- m( R# i9 ?& ]' b- H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! h2 y# K# p: d6 H0 S# f( o
//  ProgramCompareMenu.java    Provided by: DRS
+ Y# F& u- j0 X+ I# U2 Y3 Y3 ?//- g! n% e; b& A
//  Calls AuthorisedUsers.java and ProgramCompare.java3 w+ S% o/ t) {" X/ V8 C2 D
//5 _: j5 w1 G) D  q( y( [5 Y
//  Driver shell for Assignment 2.
: g6 g6 p4 v. F0 m- E3 Y2 R//********************************************************************  P# _9 x3 M" G4 A0 l
% B- V7 }8 z' z
class ProgramCompareMenu
, H" V: }: A& p) @- w1 y% j{7 W4 g/ J0 d, ~0 o- ^
    public static void main (String[] args)1 M. w( o1 b: H1 {1 g7 I' s
            {7 `! ^  G* W  _* e  A% G
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable+ M7 w& ]) x) |2 B. E
                ProgramCompare reached1 = new ProgramCompare(); 0 `& N% T3 T, f! A0 y, F3 E
                AuthorisedUsers reached2 = new AuthorisedUsers();        1 b* E$ d) ]8 ^, r
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());$ l; `' w  \, \$ Z
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * ~  q, g- O1 E! p
        }: W/ `% Y/ k7 ?8 v- Y
}// end of class ProgramCompareMenu
8 e6 W" x" |* p1 |8 B1 U) a) n
. e" i5 \$ S, w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 T; r8 y) j: k7 a+ Y8 b//          AuthorisedUsers.java          Provided by: DRS) W' _) A. a. {) ?* j( M- _
//               
# b9 W+ z: o/ S! l//         Program shell for Assignment 2
, a9 x6 P( Q- c0 H3 q//
2 z" V# M0 T6 U//         Represents facts about an AuthorisedUser
! ]2 C  \% q6 ^//********************************************************************
5 L( r, b# D' f3 q* n/ J7 F1 @$ k( c* Z# D0 F) i. x6 |+ i
public class AuthorisedUsers% z5 X/ }3 K! ~" C) B4 _
    {
& {% q+ V' M: g$ q% F) p. [( W8 K3 Y- K7 h8 w/ w* y, `# `- ]
        //-----------------------------------------------------------------
( H" v' o7 g; H% v( b. T1 @! M        // Constructor# Z! f; f# r% W% t0 q% i6 B
        //-----------------------------------------------------------------7 p/ K/ L% u& `3 I( p! D) i

, D: k6 y3 F9 k3 O3 U$ r+ V0 a        public AuthorisedUsers()& J( Y3 x& p# d" f+ |7 p
                {
4 L2 t* `$ A7 K                }
6 l9 K% [- M7 H
* f% t, V' O; ~2 g$ i" ?  a! X        //-----------------------------------------------------------------0 g, f! K* Z: |& r
        // Method for testing that class has been reached) Z3 `* E! g' u1 Z9 \9 i
        //-----------------------------------------------------------------        * X  a) j1 r% w  ?& Q" c3 s
        public boolean AuthorisedUsersReached()
) u' o2 M0 Y# G: x/ P, r) |                {
9 {1 w2 `& {6 o                        return true;                        $ [' X7 m. {& D0 d
                }
1 q& a: K3 C9 j# z* n/ d: c4 [               
+ q2 v" c1 }, z9 Q3 ?0 x8 ?    } // end of class AuthorisedUsers
7 {, v' X3 k4 U9 b; A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" y9 S% V9 m1 g+ k! C, Z+ W
Shanghai - 20071 K; Y' Q" O* m! ^
Assignment 22 O5 F( M2 @) j5 O3 ?% L' q/ H
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)
, o# W  L* z- z1 v: i1. 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.
8 t) Q) T$ W5 d9 ?* P1 uThe staff must be able to:
) K/ y) P- K1 a' \6 _/ `/ j# o Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& k5 o3 @! }' t. l1. 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." f; d- ?; q4 f+ H: D" |7 k
 The interface should provide a menu so that the staff can:/ m: [- d- v1 y4 y/ T8 c9 N5 O6 f
a) Enter the names of the two Java program files to be compared
1 |8 x* i  B( D2 N; C/ s# H* Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 k% n5 O) e$ V, E
** 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).; F0 S7 @% ?. y1 R
BSA104 Business Programming – 2007: Assignment 2! U$ ?# C9 U. i8 s
Page 2 of 5/ S1 @3 {; Q/ A
b) Print out to the screen all the lines of code that are the same
0 N2 M- r7 l4 a1 m+ Y- [  p Include the name of the file and the line number of the code being printed for each of the two files) X- V" `! E; D3 L( b% I
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. T; A" F# Z$ M
 the name, username and department of the user
3 M- r- g2 l6 | the statistics of the comparison/ N; W0 ?2 O  N* v5 n7 a2 }2 u% H2 v" O
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ w; Q$ M2 u7 x  W  H' J the recommendation for further checking2 \/ U7 ^% j! p
- 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$ a- m1 D$ g1 M4 {+ D" Q6 q
 the names of the two files compared" O% Y$ ?" v1 D! J; V- U3 Q! U
d) Leave the program (exit)
( h( q+ v0 \' h/ DThe ProgramCompare class: (Total maximum 20 marks available)
' |8 S: Y, \# p3 g7 m2. 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)- q5 l1 c9 A. Z
a) provide an error message if the files are not found or there is a problem opening them
! D8 \# L% A# t$ \, k: j' Cb) compare each line of code% S  d: I: l+ k* Z
c) print out the lines that are the same; e) H2 E  q: q; Z0 a
d) count the number of lines compared / lines the same: @' q  Z* L( z% R5 |4 S- e
The AuthorisedUsers class: (Total maximum 20 marks available)+ g2 K, X6 [0 S6 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)
) G8 \5 j- e3 A, K, ~0 ?4. Provide methods to:
" ?: I6 i+ i8 Sa) 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* Q: ~; w" q) h2 o: }/ T
b) return the name of the authorised user$ P6 V1 T. Z* N8 E8 X6 K
c) return the name of the department of the authorised user
8 s$ F  V5 s2 `2 ^5 t. v% x# [" D. ?) `Individual Data (Maximum 20 marks available)4 F& M6 I% l4 C+ q, G0 i
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.
% B8 o7 e& v$ g7 s, MDocumentation (Maximum 10 marks available)4 A0 I7 J8 M4 u# b$ M1 V# l
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.# p9 F* z9 ~6 F8 i+ W2 A- f" ^
BSA104 Business Programming – 2007: Assignment 27 c2 q+ K1 @2 _
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) \* X0 j7 K, Z9 k
不过你要翻JAVA的类库说明。你有下载没有?
: t7 t6 q4 H$ u4 ?. v. ^7 m查询关于对比的函数。貌似关键字是contrast,还有compare
0 E  x/ A. \2 \/ O. Q9 j9 J9 U) y" l* `: `8 I4 k' W8 t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 `; F: m: O( F0 H" }# m
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% n5 ]7 w% }$ z/ R6 p- Y) _
可以下载到的 是 jdk-1_X_0-doc
0 U  o6 z& s! [9 Y; O
9 x+ [( \" `" m" Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-17 17:45

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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