找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1661|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急; F" O% h1 L3 J4 @+ v- M. d6 f. x - M7 e& e0 y% I K$ y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
1 Y5 @% ]) e- B# `& z1 t//  ProgramCompare.java         Provided by: DRS
* {4 t. n! Y9 V* g+ R% [0 h% k; B//$ N9 `# q* F) R2 E0 v  c7 ~
//  Program shell for Assignment 2
9 J4 e0 i4 ]3 J//
) \0 \7 z9 D& |# e) L' O//  Compares two text files line by line
* Y5 ?& Y: u1 Q1 ^) V. ~0 s+ j//*********************************************************************
% K: }% S8 O5 h6 j3 K. H- s3 y9 r. H  f; C, m
import java.io.*;
& b( W9 |2 R4 O0 u$ Y0 z8 t! x4 s. c$ U& @) ?) v
public class ProgramCompare8 H' D7 s( `1 W) c: Q
{
3 z5 Q* G  _0 e8 A2 Z4 b8 A. G/ j( o        //-----------------------------------------------------------------
* i% g6 [+ ^( M7 k        // Constructor
3 {3 R: \$ p+ T# m& ]5 {' l6 S, `+ A        //-----------------------------------------------------------------
% j; E: W$ g9 c0 o  [/ M        public ProgramCompare()
% D) K, D+ a* L. _, W        {
: |+ c& I5 w- d: U5 A        }5 U: a, Y- i: G4 H/ \2 A
8 ~2 d5 r! E* G7 j) N; s
        //-----------------------------------------------------------------: `& L3 _$ `) t
        // Method for testing that class has been reached
. V, v7 X! K+ f        //-----------------------------------------------------------------        ; r3 Q1 z) b- }% J  c+ l
" E" R9 P' H/ B6 K5 r5 a9 c! [
        public boolean ProgramCompareReached()        
2 q* e, C6 P  ?( \0 B$ F/ w7 t        {. B" ?: m4 O' V# @1 k8 u0 }$ e
      try
% l* h4 r" Z) p0 r# m; t& y- F   {         5 v9 J  w" J4 x+ S
                        & n+ m! J# N4 L, ]$ z
                //********************************************************************
$ _9 q; ~8 }) V* u# z                // Try-Catch Statement is used to handle exceptions - such as file not found
2 |2 w8 d! u0 C4 t                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 j1 o; x9 E/ @& v$ W
                // For more information see page 534 of the textbook
  p; Y$ K0 |6 w& t! A                //********************************************************************  x! \& E) J( _# ~
                    
1 m7 v8 a/ M4 l% A" ^        }2 z" C0 h( s) K# k! X; z
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 i/ N+ s1 L5 E- V9 f
          {# e" D- h% ~! _+ O) ^. P1 r
                    ex.printStackTrace (System.err);, O$ U0 e9 s6 v, F
           System.out.println ("Error message goes here"); // Replace this error message with your own            ~. Z5 H5 n: d( S
        }' \  N! Q& K3 A9 N: b8 E* a2 ^3 [
                return true;) ?, m8 C' U6 U" D" h
        }- V9 O' }! L4 @# Z

4 P0 m4 j, I% o) k, l- F0 I} // end of class ProgramCompare
  s5 g3 m1 E9 C& F/ R  L0 Q, c0 f7 u3 j6 _8 B) h
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& ?4 ?1 @. K1 F
//  ProgramCompareMenu.java    Provided by: DRS
. N4 Z* w6 L6 b- i//$ X, l8 ^9 J3 L- h, Y$ v  L
//  Calls AuthorisedUsers.java and ProgramCompare.java, v. E2 Z/ y7 V& T7 d. e1 w
//
& c* D2 K) E) B7 s2 z) z: G0 q! ^1 u//  Driver shell for Assignment 2.  P( K8 s# T$ }/ q
//********************************************************************% {4 p' S/ e# }/ J" e& ^4 Q

' n: ~/ W. ]8 Y8 R( Kclass ProgramCompareMenu
0 N; L: {' K$ g' m5 n# B{
; b$ _- d+ o9 o& d/ L    public static void main (String[] args)# D5 Z1 |# X# Y6 Q. \- a; q# i
            {
. C: z4 J: L6 _8 }# h                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 C% W+ [* i3 m7 \; x1 D' ]  M6 M$ p5 c                ProgramCompare reached1 = new ProgramCompare(); * `% I  J5 b0 x
                AuthorisedUsers reached2 = new AuthorisedUsers();       
* [2 l8 f" |! m/ D! z9 q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());; Y& x( E# F( F8 P+ T! _+ _% T
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 w& e; ~+ Y/ Q        }
3 C# ?6 y% E3 S. w6 R}// end of class ProgramCompareMenu
; F$ D( a1 _2 R9 Z. }  C+ I- i0 r2 k8 o  o) p, p
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************9 Q# Z: {* L% M6 A
//          AuthorisedUsers.java          Provided by: DRS6 l+ Z2 T+ n# @' o0 ?' {- K
//               
* [  |* b* E; z4 w//         Program shell for Assignment 2$ h% t$ t/ k/ b! M" p/ U
//
6 K8 `5 j  G) s# [8 g! t//         Represents facts about an AuthorisedUser
/ I' L% z5 G' y) l//********************************************************************
4 T$ ?: _- `; k+ A
( ~2 O" B( M. @5 R: Tpublic class AuthorisedUsers9 z' h' J, G& h7 `; `+ [! B
    {
; o1 w0 J0 M* N) k( S( d9 m; k5 L
! |* @0 ^  A9 U! L( J5 s        //-----------------------------------------------------------------
- C% h; ]5 s: h% H  }        // Constructor( [$ J# o- D9 i# H
        //-----------------------------------------------------------------
; D7 {2 l- j( ?
7 F" ^$ `) g2 b- G0 P! n) u        public AuthorisedUsers()
! D& I8 E* X- r. V% j% R                {5 h6 L7 v9 P4 \& j
                }; ^2 v0 ?" N( ^% l/ W
" M  x& L7 [* e/ Z/ d7 i
        //-----------------------------------------------------------------
+ H4 \0 M+ F6 B! O3 m        // Method for testing that class has been reached
' V9 ~5 I% @  w% T! G# G$ T        //-----------------------------------------------------------------       
0 r3 u) R3 M  b. O. Q7 G; E) U5 G        public boolean AuthorisedUsersReached()
. X2 W6 K) s! N# n8 }# a5 D                {
% A. W* O7 m1 w- W0 n# I                        return true;                        # m+ C' h+ T: `3 {0 N" k
                }( P- S$ I9 J- O) f+ O, N9 O0 d
                3 C' ]& s5 k1 g9 m; c: ]* }
    } // end of class AuthorisedUsers
6 m# }2 G* K7 ~( T! \, i! k3 W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: e7 A- a# M; l% T- WShanghai - 20076 L  P1 W2 v0 A* V& r$ |
Assignment 2
% b6 B5 a/ H' \) iDeadline 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)
8 o1 R7 T4 a3 e1 j0 D0 n1. 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.
4 ]- I0 j" x( Z4 G, v+ uThe staff must be able to:
! h$ u9 [: s+ F# e Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' J- d6 g* G! z9 H1. 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.6 |4 K+ L/ ^, g7 p' E: w; e) ?
 The interface should provide a menu so that the staff can:
2 i9 R3 n6 |' P: h8 |a) Enter the names of the two Java program files to be compared  X1 J% m1 E- J  Y' |
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.+ C+ |3 y) T/ e5 x, K) ^
** 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).
: M! ~2 q! d2 q6 L, G9 OBSA104 Business Programming – 2007: Assignment 2: s) |2 U: w, _
Page 2 of 5
2 t! y# Y; M8 p& y/ [0 y9 l4 I1 ?b) Print out to the screen all the lines of code that are the same
! Y# q8 |. x) F! U) e, N Include the name of the file and the line number of the code being printed for each of the two files
- A0 c; K( G2 Zc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; ?% L+ n( m" k. E
 the name, username and department of the user
; r9 l. B% p! O  Y$ y6 ]$ R8 i the statistics of the comparison4 [9 s0 y/ ^7 i! T" c: r  Q
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 x: Q9 t# b- W0 k+ H" q% u  M
 the recommendation for further checking& n; {1 b) b9 m2 |: C
- 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$ h; t; V  H2 L! V0 u: U
 the names of the two files compared
6 e2 V! o+ X) Y5 |( r" Gd) Leave the program (exit)
2 u# V- R2 Y8 z/ U& `+ \; IThe ProgramCompare class: (Total maximum 20 marks available)2 V" d' ]# Y$ ^# f& y6 ^' |3 V
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)
3 f7 T2 m# ]& e$ N  ^# @/ da) provide an error message if the files are not found or there is a problem opening them
. Y* S9 ~% C1 v8 e! [+ b5 wb) compare each line of code
4 V; @# ?1 F0 t6 n/ t% \c) print out the lines that are the same
6 k2 _& _# x! f. d1 Bd) count the number of lines compared / lines the same7 F% v$ w" @4 n) d+ F; P
The AuthorisedUsers class: (Total maximum 20 marks available)
  S5 ?% p& H6 ?! C6 ?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)0 c5 V, ?4 p% W& F& G9 ]# o& a: A( W
4. Provide methods to:1 K5 h8 J* X% p
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
" r  y) m" m( h) D9 C- {  hb) return the name of the authorised user
' ]. o" Y7 L' ^8 p1 bc) return the name of the department of the authorised user
# }5 r+ r: K" ^4 ^! r  a) A" fIndividual Data (Maximum 20 marks available)
1 Y! T* G$ S/ x  e5. 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.
2 S- {5 y" s  d& a  GDocumentation (Maximum 10 marks available)- p: t/ S' w6 i
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.
9 l$ f$ C! p3 p* Q/ Z5 FBSA104 Business Programming – 2007: Assignment 2% u- V; M0 ?5 g, {) j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 J- g' _  e9 R" x* v* I
不过你要翻JAVA的类库说明。你有下载没有?
# l" I0 i5 Q3 T# {+ n' K查询关于对比的函数。貌似关键字是contrast,还有compare
' o6 N- H( ]! m# h% f
0 t+ C8 ^" j2 t$ ~- V* z- K) R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: @% X% N# b1 v6 x痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 \6 J) E( C- C& v/ Y5 J! C: D可以下载到的 是 jdk-1_X_0-doc6 `# x3 h: [0 K+ D& X
+ m6 i* V5 ]) a1 F2 s8 e2 X# t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-23 14:23

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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