找回密码
 注册

QQ登录

只需一步,快速开始

查看: 841|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' Y4 ^# u ?/ R- P( E2 W: M) [0 E$ M3 ]* 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 | 显示全部楼层
//*********************************************************************" t/ O( j" X- S7 C, v( `
//  ProgramCompare.java         Provided by: DRS
' A0 e9 ?. V! h6 C//" q! h6 p5 m% Y! e
//  Program shell for Assignment 2# C2 p1 F6 u0 w. Q
//% c3 ?! n6 k! U
//  Compares two text files line by line
8 r8 B0 x8 \9 T! \6 B4 M( L$ o, b//*********************************************************************
5 b2 g! t" P6 f' H: F  v$ c% {. e) i4 j. @/ M
import java.io.*;
- ^, i3 s4 P: g2 @' _* R2 _5 L- O6 I! w# H5 Q5 q6 l2 V% D
public class ProgramCompare
. W' Y8 g1 e3 g2 _6 ?{
1 m. @$ _5 O3 I) v+ D        //-----------------------------------------------------------------
; Q: W# z. I3 s  e$ ^        // Constructor4 }2 e0 F4 ?) U3 ~# y7 Y
        //-----------------------------------------------------------------; g$ X" C6 t: d' \* o8 |
        public ProgramCompare()6 O$ l, A: H6 G' j9 r
        {
3 t) a$ N0 }7 B, |        }# P# C! h3 w" a" o

# i0 u$ J; i- ], [! i, @/ L. v        //-----------------------------------------------------------------
( O9 k9 H5 O3 [' F% F" |2 t        // Method for testing that class has been reached) i& v! e% [2 w6 d# b$ Y8 F4 l
        //-----------------------------------------------------------------        8 e; m" `: R/ X7 g( Z1 _
/ O. G# i  q: J
        public boolean ProgramCompareReached()        
( a3 ?3 `, @- C' h0 ^8 S* m" ^4 V1 I! W        {4 }3 K. }1 l7 n( R0 L% B6 {
      try
5 p0 l/ R) X3 [: M   {           c% k5 Q" v9 D* [1 B7 s
                       
% R6 \# {; {9 K5 y9 @( j5 B                //********************************************************************
, @5 c( _8 |1 S* f8 b8 g                // Try-Catch Statement is used to handle exceptions - such as file not found
6 Q+ {+ G! S. |5 d' z                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- P2 W% z2 R. K                // For more information see page 534 of the textbook* {; _6 n+ j+ F3 d1 ?& f
                //********************************************************************
# K& w) W5 C5 l; {                    
9 z7 k) o3 C$ W. |9 P; r        }
. u8 |( B; y7 @4 O+ Q' J* R5 ], N             catch (Exception ex) // Exception caught here and message displayed to the screen
1 f6 Y& {* w! e4 R, O" s' X          {
0 D* ]3 q' j7 D- C+ @5 q                    ex.printStackTrace (System.err);) C( w$ [2 M( p! A' E) m/ x
           System.out.println ("Error message goes here"); // Replace this error message with your own         
  |' R2 V  V; `( t1 [+ R1 E        }  v3 u- U  w$ f& V( Q4 y  N
                return true;
  U; i# x" {% x9 T9 x  k4 {7 i! g        }
: X6 |$ c6 z0 @8 f/ ^9 f4 {! S- P* Q
0 p! X4 K: W5 F} // end of class ProgramCompare
* h: a& \) ~3 _( i9 M0 z6 \7 T( h
1 E7 m; g9 \( d" u6 Q: l8 r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' J) R8 o. b% V% Q! P: d//  ProgramCompareMenu.java    Provided by: DRS& A* ?% F: a, c2 E7 ^" D6 E( X5 w
//5 G5 {2 k2 \0 s2 Y7 a/ x, s6 ^
//  Calls AuthorisedUsers.java and ProgramCompare.java* B6 ~) N/ r" \' x
//
$ l  `1 R% U3 q3 q$ S//  Driver shell for Assignment 2.
8 Z% j! p. c1 K//********************************************************************% ]3 g! f- Q2 j% X' F. m

3 V  |/ w3 m- D) e& iclass ProgramCompareMenu
" T: _% D- [3 d% G5 k/ h' b{
. N+ D2 H4 f' j/ j$ L    public static void main (String[] args)
3 A: |) p  R% C6 n) p8 H            {: G0 R& h+ r0 a
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: @% H4 h2 F- Q  \4 _! k                ProgramCompare reached1 = new ProgramCompare(); ( \' w* T+ E! F' v
                AuthorisedUsers reached2 = new AuthorisedUsers();        ' j1 p% [" V2 H8 j
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 Y2 F, o$ t$ D+ n# V; j5 C
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 m) s2 r+ i! C9 r5 K0 {" _0 j        }
1 R4 f& \3 ~: V}// end of class ProgramCompareMenu
: T% m0 d7 V1 {3 p. ^4 Y
( H: |: o9 o% X3 O8 O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************! q; Z0 g  B) k8 r  A/ v- l
//          AuthorisedUsers.java          Provided by: DRS
/ T* c( O9 S; m8 {3 m; f" W. k//                0 a5 @6 ]3 D, A' R! B
//         Program shell for Assignment 2
5 @: z0 t: Y: Q  ?//
% |, [8 Z" E! x, z5 E" H//         Represents facts about an AuthorisedUser
/ i  L4 }, N+ C' q! c//********************************************************************& E& S8 T4 c* U  W

( N8 y1 x) N/ {! J  Jpublic class AuthorisedUsers; z, V. ~( A) j1 i5 G3 Z
    {, ?) ?4 t, x) Y0 P0 L( ?

* |  A9 S; \& m        //-----------------------------------------------------------------1 Y% _3 j* F% f* ^0 D
        // Constructor- W4 E$ w# F  B8 W
        //-----------------------------------------------------------------5 ^* M6 c% R: ~7 y
; P8 g: S6 s, W. A- Y& l7 i
        public AuthorisedUsers()0 `  N! u1 y- Y9 {' V
                {- w0 Z, Q; H' k3 U  }7 m
                }6 M, }8 A; u  j8 Z* g& r& ?  X

: ~  _$ h9 N) R9 F& `4 N& b        //-----------------------------------------------------------------
6 M6 x1 o/ u+ K/ ]! `        // Method for testing that class has been reached
7 ?, _" s3 b" n+ g        //-----------------------------------------------------------------        2 M7 w5 Z6 R- v/ I' J( I* O' h
        public boolean AuthorisedUsersReached()
6 R; b, m) j( z+ F                {
9 T5 n  W* \$ [: k                        return true;                        - z( ]$ J& w; \# A7 b
                }5 v) F4 R7 Y# B7 F6 ~2 W6 i
               
& o7 [5 v( j, x$ e" ]. n    } // end of class AuthorisedUsers9 M% n$ g7 r. F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming4 T8 B( r& ?( E) W, [7 [7 W, z
Shanghai - 2007" o% f  k& C6 z8 K
Assignment 27 S: J7 {2 _% [0 i$ @3 X7 L+ M) X
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)
  t0 u# e" i) T, u8 e% R6 _! Y4 h1. 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.+ `6 Y. X8 Y3 n5 f* A
The staff must be able to:: L  b5 l1 F8 |( i; Q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 o5 `% x+ ]: Q# X: u1. 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.1 ~/ r# g. U7 u  h( b2 q# _  M8 _
 The interface should provide a menu so that the staff can:
7 \: ^4 j1 n5 f6 l* w3 b& ya) Enter the names of the two Java program files to be compared$ g% r1 q1 M" H$ P$ m
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 I: C& K) ]7 R** 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).$ v7 r+ h* B; E! ~. z5 a- s) C; E
BSA104 Business Programming – 2007: Assignment 2
: h5 u" R  E" Q: r1 lPage 2 of 5
; r( c4 d& ?. O! Rb) Print out to the screen all the lines of code that are the same' h/ y5 x+ P, c- p$ C( |* Q1 l) l2 {
 Include the name of the file and the line number of the code being printed for each of the two files
8 ^. v& r# e6 |c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% r" V# T: ?9 q4 l: i
 the name, username and department of the user7 M. U5 `; f8 a1 o
 the statistics of the comparison
# u- {& ~0 S& l- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% [. {% j+ V  }+ p( L
 the recommendation for further checking, `# ?" H9 u4 a  {
- 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( U1 a' ]4 |5 x( ~! g: r1 |5 j; Q
 the names of the two files compared
3 R# |5 v5 S  A4 Fd) Leave the program (exit)
. H, P! x: F7 ?. U( a5 fThe ProgramCompare class: (Total maximum 20 marks available)+ @) [8 b7 Y& k, E. R
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)9 F* }# |, e4 s4 N2 x
a) provide an error message if the files are not found or there is a problem opening them
  i" k5 Q. u" S! H* f9 j# w" Db) compare each line of code6 f; |2 |4 F4 p5 A, L. w" p8 s
c) print out the lines that are the same
1 o) s( |9 q/ K, s/ x: {+ u) j3 |" fd) count the number of lines compared / lines the same
& ~7 k! `/ W$ z* x  S. e3 L/ {The AuthorisedUsers class: (Total maximum 20 marks available)
' c' H, g$ {1 m9 X0 @" C% b( L1 U3. 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)% ?+ a8 t% b! v" e' L- C3 m
4. Provide methods to:
; g, r  E! h- _* A/ va) 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$ n+ R' u/ F. ^, K3 H4 a/ R, D7 Z
b) return the name of the authorised user
% M/ @# i& y) G6 x# L+ ?: X* \c) return the name of the department of the authorised user% ]& N+ L3 E% A
Individual Data (Maximum 20 marks available)/ W$ c: w% y. S/ R1 r% 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.- Z- K& m% y- n1 [4 D
Documentation (Maximum 10 marks available)6 I4 v5 d% N8 D/ v; C# L+ Q
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.
0 v; _) U% ?5 sBSA104 Business Programming – 2007: Assignment 2
1 Q5 x2 x4 N/ n' d( R2 ]Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" Q  E' q/ i& r6 n( L! K- q- }* ?3 m. o
不过你要翻JAVA的类库说明。你有下载没有?
2 q% _% S" h9 B9 h, M' A2 A8 u1 N7 P; z查询关于对比的函数。貌似关键字是contrast,还有compare! G# D8 m% w3 ~8 }1 l

6 O' Y9 |, S2 S1 N' H" f[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 y& ]" ^8 a7 o( h, n% r, ]
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ S# D0 q6 |1 ^9 R: t
可以下载到的 是 jdk-1_X_0-doc$ k  z& S& L# i* e* {

4 ]; k* X) L0 A4 f2 j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-6 16:21

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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