找回密码
 注册

QQ登录

只需一步,快速开始

查看: 983|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 H6 y" w8 }- Q- C9 o! T. i ' }4 [+ U) g$ R$ _. c
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ e9 q' o; H. K. C//  ProgramCompare.java         Provided by: DRS1 u0 T- G+ i; h* p- t
//" k+ n: Q' W5 X! o7 m! W! F
//  Program shell for Assignment 27 ~: [4 Y; c2 Q) v. S
//; r' p6 N) w3 S& |9 p$ g- K
//  Compares two text files line by line8 E# r" m9 _% E6 }9 m$ x
//*********************************************************************; ~% U$ n4 X: C
) Y' S2 {6 e- Q, P# p
import java.io.*;
6 H3 q, _1 `4 C  l" E- v& H5 x, G' N  r6 `) V
public class ProgramCompare
. }* D, j/ _' Z0 K{% W7 O  R: x# O$ H7 X
        //-----------------------------------------------------------------# j+ w/ s6 ?5 d4 h$ k
        // Constructor
# S  R+ k7 j% B        //-----------------------------------------------------------------
$ O% d# {( m. g% x7 O& c# R2 Z6 T        public ProgramCompare()8 A2 [! O& G+ f( h
        {
5 O$ ~0 B" ]! j3 [) f/ z$ i        }. E  l! [8 _$ V& x, ~8 e# W

# }2 w- T- h: V3 u        //-----------------------------------------------------------------& z' p7 ~  W! G% t. n( ^
        // Method for testing that class has been reached
3 T  H4 ?# M7 u8 S3 F2 |. {5 N        //-----------------------------------------------------------------        ! A/ @0 o3 O( y0 K1 L& R
: i$ {0 }6 ^* [) b; x
        public boolean ProgramCompareReached()         # O6 a# B: A, [7 r2 Q3 m
        {/ a9 r5 K- N9 j+ V9 L9 Z- O
      try , e1 k8 g" E2 \, w
   {        
6 [, c  \) h1 m' B, I                       
% l# I  H" g4 Q; n                //********************************************************************9 L. s) p: G) E( o6 v. P
                // Try-Catch Statement is used to handle exceptions - such as file not found * |% Y1 O: o, [9 m5 k2 T! }
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 `+ U+ U* B& K' L                // For more information see page 534 of the textbook
  T2 w8 d4 ^+ h8 z$ ~                //********************************************************************! t7 i" z0 H. j
                    
6 ?+ z1 U( n: G" N6 P" T        }7 \' [, \7 z* Y- H
             catch (Exception ex) // Exception caught here and message displayed to the screen 4 P7 E5 m/ E! m+ ~2 l1 `6 B. y5 J: ^
          {
! I* t! D; j# x3 y9 _) |                    ex.printStackTrace (System.err);
6 t8 C: s1 K% ~& m. O8 o1 h           System.out.println ("Error message goes here"); // Replace this error message with your own          6 I1 U3 |" @* _+ B/ t
        }
3 w2 H7 c# M" `0 I                return true;
. s9 J9 J$ h, E* H        }# w# m- T) n6 M

* j' N- d8 Y2 ?# i' t4 _2 W} // end of class ProgramCompare
. B; I$ W3 s5 T8 _( u* H, ^4 S& z1 ]$ o' l
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ b" ]/ X7 M7 p6 g) ?: J/ O2 B//  ProgramCompareMenu.java    Provided by: DRS; f' F& R. s7 D9 n3 E
//' g) S; Y5 n& S- W2 ~
//  Calls AuthorisedUsers.java and ProgramCompare.java
+ D& K# o5 q2 Y% @//
, ?, j% P- M/ p1 d$ K, ^: U//  Driver shell for Assignment 2.. M' n" d* V+ N- D8 p
//********************************************************************
) s- f6 q+ s4 n# B( {; c! Q
2 \0 Q/ i( x. d' }+ tclass ProgramCompareMenu
" \6 z2 |9 W, @0 H+ H, P{
- t" F, [$ w3 E    public static void main (String[] args)2 P( }0 W8 u6 J8 y
            {' C: h& a; l9 q9 C
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" X. G3 P; C( D/ d" d                ProgramCompare reached1 = new ProgramCompare();
0 E/ |7 @" I! J, o& G3 l/ c3 P                AuthorisedUsers reached2 = new AuthorisedUsers();        8 x% {0 W8 t- \& |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());+ c2 k5 H. Z2 q$ E5 k8 q$ ]5 G
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 N# y% T6 C. j. I0 V1 j        }/ ]9 s: k4 I0 T8 M3 t
}// end of class ProgramCompareMenu
* N# X4 e& r0 n
+ k1 L8 ~5 h3 ]$ m- e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 P9 I1 H* M( v! U1 b//          AuthorisedUsers.java          Provided by: DRS
: Y) t7 U+ r; ~' K8 V2 ^//                ( t  \& a+ }! j' y' u
//         Program shell for Assignment 2( X% J* y. i5 ?* Q
//, ~, O  ^/ p" g! C% X2 E. C, w
//         Represents facts about an AuthorisedUser. Z2 }$ `  Y: Q2 {, g" t
//********************************************************************
9 ^% ]! m+ f" e1 F+ ~+ p& X! d
4 Q. P; [9 W5 d$ q! npublic class AuthorisedUsers
7 c! a$ S' K/ u! C- A- n8 z0 ?    {
; u% F% H! @' G! {( D' a$ B) {0 g. ^: D+ E) O) D& U
        //-----------------------------------------------------------------
) H1 {( \% n+ t4 Z; O0 V7 m# ^/ O! n        // Constructor: C" e1 U" ^  f
        //-----------------------------------------------------------------7 y6 H  ~9 l% s' X
( h) u" [3 m; ]4 z
        public AuthorisedUsers()
9 I" y4 \" b6 e+ J7 f3 E                {/ M8 c  s; I! r1 F. R
                }9 ]; t  U5 n+ b, ]
5 s9 m, [* Z% e7 f% F
        //-----------------------------------------------------------------$ e% d) r3 {2 z- B. \
        // Method for testing that class has been reached
: d3 W4 B; o$ x/ a+ }0 c- [* h: t        //-----------------------------------------------------------------        2 X1 i( a: w+ Q( a5 _0 \6 ?4 d. t
        public boolean AuthorisedUsersReached()( {& V) Q0 C4 q" G& ]  n$ Q
                {3 {- ~" i* _' V( f( I
                        return true;                       
' g& Z8 h3 S! {                }, t, Y" ^  c7 N8 `: K# S! ?2 Y* f
               
9 e7 U7 G" P: i. _( I  a6 {    } // end of class AuthorisedUsers
  Z# g; N" q7 p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 |( Y0 }3 ?# U3 g' O
Shanghai - 2007
# v# e+ s; B; |Assignment 2
/ T6 F, z+ W5 U( T& o- ?0 q( UDeadline 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). r$ i! c) V& [7 e9 n8 a
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." }& l& D- g( m0 i8 _) W3 e
The staff must be able to:; l; }( }. i$ [8 T8 ?5 e
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.- E, b+ e9 l2 X! W3 G+ a
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.
' t+ r: K6 L% L" z3 J! a7 o The interface should provide a menu so that the staff can:
4 c' Z# u- r1 Q* _) N. `; pa) Enter the names of the two Java program files to be compared$ Q% Z' F3 j4 d
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
) {( X; d8 b' M, B' _) ^** 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).
2 O1 |  P4 S: y% @% cBSA104 Business Programming – 2007: Assignment 2
2 P9 E( y3 {3 @# t, Q7 K: H2 QPage 2 of 56 O  F, f  p6 j6 m
b) Print out to the screen all the lines of code that are the same7 A" B7 y5 w5 B1 t  u+ I, n) Q( h
 Include the name of the file and the line number of the code being printed for each of the two files
8 n/ Z+ S3 y( F# B- M# ?6 dc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  ~5 J" f# j- k! ~% H
 the name, username and department of the user2 u( m9 T2 q, ~/ k
 the statistics of the comparison& i4 M7 t4 ~4 U5 B4 u$ j) p  x
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
; C; }( I+ j7 U- l9 } the recommendation for further checking
, M' f4 ?$ V" ~2 e) g) ^- 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$ h+ |1 e6 C' M
 the names of the two files compared
) d6 P; j* P5 e5 s: f2 Md) Leave the program (exit)
. G% C; `7 a8 P9 d1 s. RThe ProgramCompare class: (Total maximum 20 marks available)
2 h' u) e9 @. E) z- w' i2. 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)
* H$ v0 S( _; K9 w; x5 Va) provide an error message if the files are not found or there is a problem opening them
" z3 c- y" a1 G( p8 {b) compare each line of code
' U) R, o$ q+ J. z  oc) print out the lines that are the same, l% s9 B1 i8 X" r6 ]
d) count the number of lines compared / lines the same
' x0 X, }' E9 y% bThe AuthorisedUsers class: (Total maximum 20 marks available)4 R/ o8 R/ h* P
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)
; E7 v& t) O& F! `3 }: e4. Provide methods to:8 f/ z! P: }& ^5 c0 B4 B
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  X3 F* f  q6 X% r! g7 y$ l0 g, u
b) return the name of the authorised user
  x! L- u- o6 Z8 c' c7 Vc) return the name of the department of the authorised user
6 ]( W1 B8 K# \- yIndividual Data (Maximum 20 marks available)
" n& p  @8 A, a8 o* M+ s5 z6 |9 ^+ K5. 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.
0 u1 K3 e( `6 L" v& ~Documentation (Maximum 10 marks available)  H4 |4 k: {4 y. ?
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./ A2 {9 Y$ q+ d, V3 B  L. w* H
BSA104 Business Programming – 2007: Assignment 2
6 N0 m* r: v" }- w# YPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了; l* ]( @6 _% g% E" x) o
不过你要翻JAVA的类库说明。你有下载没有?
( M+ |0 k4 Y/ e% F1 t% ?查询关于对比的函数。貌似关键字是contrast,还有compare
8 n* c5 V# B( E% u, Z0 ^3 b( u
' t; b5 |: @7 t( V[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. [* c) ?( h; p: O6 S6 Y3 e- u可以下载到的 是 jdk-1_X_0-doc
: I8 B$ L; P' \: T& U
+ T, R& d5 G: r) e5 M[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-31 10:03

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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