找回密码
 注册

QQ登录

只需一步,快速开始

查看: 801|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 N5 G9 i) j" K& _' w ; b% p& p' i1 X1 r) n# 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 | 显示全部楼层
//*********************************************************************- Q% ]$ ~* E9 V: O' q
//  ProgramCompare.java         Provided by: DRS
2 i/ o9 S7 V3 H1 J5 c//
; `6 p8 Z8 x' R//  Program shell for Assignment 2$ W" u% ~1 f1 N. c# W
//
: e' V& r  b" L2 C; a0 b//  Compares two text files line by line- W' ?3 c: u5 \
//*********************************************************************
- Z- g1 `+ l) F* [; E5 U8 J/ C; L1 t4 e' c0 J% A
import java.io.*;
; K# L* k  |3 u; j, e. ^: K; a/ ~1 g( i$ E5 Y: n
public class ProgramCompare" |1 W* Y# Z, s; D2 V
{
. n0 \) w0 N- o' u' C        //-----------------------------------------------------------------
: v$ t  n4 H6 y0 X        // Constructor
; c; f+ `" Y* V        //-----------------------------------------------------------------1 \) e/ e' h/ W5 V( I- e- N2 |
        public ProgramCompare()
9 Z  m0 O: O6 j" h        {
0 \3 l4 Q, w: S- H        }
4 ?6 n) L. k6 H2 x- P" S" F2 O6 @* Y% E2 _: |0 H
        //-----------------------------------------------------------------
0 N6 M& `. W6 W& ~2 A0 N        // Method for testing that class has been reached
/ w& e6 k+ U2 e" O  K# H! }$ [4 I        //-----------------------------------------------------------------       
! I! A! j* _/ I& o& W1 O# C' K& e/ U* J0 d
        public boolean ProgramCompareReached()        
* \4 c: F% D# U; s- E        {
2 M: D( y4 H% [1 j& y0 e      try - g/ H( [# Y! Q8 X
   {        
9 E; S; O6 Q. h1 O                        + [' a8 Y: L& u( g2 j9 E
                //********************************************************************3 ]; n& c* L! Z! B$ F+ d- _
                // Try-Catch Statement is used to handle exceptions - such as file not found   n4 h" Z9 y% v
                // Reading the files will need to be placed inside a Try-Catch - just like this one!7 O+ S8 {$ A% F/ i$ o1 m8 e
                // For more information see page 534 of the textbook, X. m8 M" W8 n2 `( w
                //********************************************************************) z. D  D. R  S' ]
                    
1 m) N" H  x" F% [        }* v& x: w8 w1 ^
             catch (Exception ex) // Exception caught here and message displayed to the screen
: A! B3 U$ d1 ]; v* g          {
$ ~1 o6 L4 C: H5 H. @) ]  X0 m                    ex.printStackTrace (System.err);! }) X, B- W8 o* e
           System.out.println ("Error message goes here"); // Replace this error message with your own          . C! r" x- _" J" w4 n5 U2 L
        }
% V6 n+ J* ^) y' w! R4 @8 @, z: I                return true;
; Z0 P+ }8 Z4 v" j* P, G        }
5 r: P( @9 h4 C; p3 s, a
" \2 i( A, W- N} // end of class ProgramCompare
2 c  J1 R2 N) T) {1 _
1 f" c( C% A! l& ?; P9 _  Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 p1 e( s" Y9 _1 u- N2 N. ~//  ProgramCompareMenu.java    Provided by: DRS/ e% n1 U8 y& |  b
//: Q; W0 i& b4 s
//  Calls AuthorisedUsers.java and ProgramCompare.java
+ F9 \9 ~! G" d$ Q% o//
& h5 E; n" A1 g: z: k//  Driver shell for Assignment 2., [5 k7 ]% ~; }7 A7 V" Q
//********************************************************************
& p, P$ Q+ e  g1 R+ g, t
3 f  ]6 G' n  {! i8 C4 d, u% qclass ProgramCompareMenu
" V' i$ G9 N+ N% e  i0 T{
5 S2 C% a! W- d! _: \0 I% ^: Y# M    public static void main (String[] args)
$ J" a4 R( H' I3 X7 p* d1 K& c8 E            {' x8 p. t: e. b  o- o& ]
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, T% J* W" }; C( n1 s; E' M                ProgramCompare reached1 = new ProgramCompare();
* w/ ]" s- D. o2 F& f2 X3 f5 e                AuthorisedUsers reached2 = new AuthorisedUsers();        . ?2 F" f/ r( L" ]1 k: M8 n% H
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());  p% V  E' Y& u' i& z5 X1 m9 ~/ n9 E
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        . Y$ s( Z' @: w% a- D" Z; a
        }
- g# O* L* X4 `4 I- u5 v}// end of class ProgramCompareMenu
6 K# j" a, H8 h% a  ^- s2 t( j$ O9 @$ w7 y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, R; B: T4 {3 w* l' I9 D* E
//          AuthorisedUsers.java          Provided by: DRS2 l$ S  ^, _$ c+ X' t
//               
6 h4 n1 S: D5 e//         Program shell for Assignment 2* h( m3 }6 r6 V9 T# P
//7 u, \% O0 x  x) P& t) H
//         Represents facts about an AuthorisedUser7 X( `+ S1 R; O3 |+ j
//********************************************************************
: B4 }0 L  `% H$ F/ F5 f7 m8 g. \9 u! ?' `- T& x: E& @
public class AuthorisedUsers
3 R3 D* \) K+ R8 K- \% I    {
) M( {* }3 G$ u$ _% o
4 \! Q6 _. |% \: }5 `: d        //-----------------------------------------------------------------
0 |6 c, q. c* X9 R# P        // Constructor: G& E# }7 \6 [  D5 q, _
        //-----------------------------------------------------------------
( u" _/ U$ y. B+ p5 Q' H8 T: p) S' K
        public AuthorisedUsers()/ @( m  @5 X4 l
                {0 m8 b1 I3 q0 `8 _
                }6 w4 J! d0 Y* C8 K! `7 x

, J% B: v# H1 `, R        //-----------------------------------------------------------------. g+ @( ?, {# e  m, Y
        // Method for testing that class has been reached" {9 a' L  w3 M0 P, e. _
        //-----------------------------------------------------------------       
. i) Q( I$ S1 X. w8 q, Z        public boolean AuthorisedUsersReached()
9 K" Y" o. d$ W" Y                {
: k1 r0 ~: B* y3 [8 B, ]' J1 M                        return true;                        9 `) N! T* c+ k$ [$ K: M
                }, Z  D8 ~2 P8 ~2 [1 y
               
7 N  y9 X( r% U8 O- K    } // end of class AuthorisedUsers& o* g, `1 s! l/ H. m" _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" P5 H$ d% ^" t. d: D2 V* EShanghai - 2007: ], I% c4 m' G6 q
Assignment 2+ Z& K9 S' t7 \
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)/ ~& P4 ?) P$ u! @/ y0 c
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.
: k; I0 G- h2 V' L2 o" `The staff must be able to:! _, z* e0 J& e8 \' {3 c4 y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ @" U" c, N1 t. q* L) ]
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.. J1 U. e' `9 F! L& G+ X5 E% f
 The interface should provide a menu so that the staff can:
7 h; |4 A  f- q. M4 [2 z" sa) Enter the names of the two Java program files to be compared. N1 V$ R& v' c% t2 z8 g& g* e' w
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 ]5 r! \0 n( C# U' u** 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).: O- r) ~$ j- B0 S$ v
BSA104 Business Programming – 2007: Assignment 24 a5 s* S( i) h3 K2 r" ?
Page 2 of 5
. ?2 ]/ u' O' j& x. ?. ~/ ^+ I+ tb) Print out to the screen all the lines of code that are the same. \: ~+ d: O! H+ K8 h
 Include the name of the file and the line number of the code being printed for each of the two files
* K; a( l4 k3 @- ?c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared$ A, ?" u% g( E: g7 _" @8 t
 the name, username and department of the user' @* T3 K8 U& I  u" {; ]
 the statistics of the comparison0 X3 C! h. L8 h, [; V  f1 Z$ ~
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 i4 _6 w0 H$ D8 L9 Q4 J  W. T% G  H the recommendation for further checking: _/ Z0 D% ]: f
- 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+ q6 j* N% s$ w0 C9 U4 w8 `
 the names of the two files compared6 G" x, U: r( X* [
d) Leave the program (exit)
) f3 Z, M; X: o. f8 hThe ProgramCompare class: (Total maximum 20 marks available). G3 O# F, @  p  `/ q& T
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)
! D; j4 v  O8 g. z! p9 y6 H  ga) provide an error message if the files are not found or there is a problem opening them
3 Y' u- j! C( R& Vb) compare each line of code+ X" R3 \' `/ Q" C) R' D
c) print out the lines that are the same9 n1 }+ R& O+ Q5 \2 ?; i+ Z. W
d) count the number of lines compared / lines the same
* m3 D  b, z2 L# a( `) fThe AuthorisedUsers class: (Total maximum 20 marks available)7 \, u( B2 Q# e" a5 H, w+ U
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)
+ z$ g6 P6 X; s% h2 P, a4. Provide methods to:
! b/ S5 ]7 V, |. g. ea) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match2 z2 G; ^) V' b+ [) ~4 P+ k
b) return the name of the authorised user
; o$ N1 U$ X5 \: b9 Fc) return the name of the department of the authorised user
& L6 v" K4 d5 pIndividual Data (Maximum 20 marks available)
* d8 w; B% Q" }; }/ 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.
0 x& w! W% w/ }# X! g, r- K) wDocumentation (Maximum 10 marks available)' N2 t) a. p7 ^1 D8 g+ i) {, v
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.
# ~8 H9 l. G7 j2 tBSA104 Business Programming – 2007: Assignment 2
+ y# \: p4 G# ]- E& DPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了* k5 V2 J+ j5 D/ P+ C
不过你要翻JAVA的类库说明。你有下载没有?: m) p, L- T$ G& [( v2 Q! j9 W
查询关于对比的函数。貌似关键字是contrast,还有compare
/ w! |+ z8 l: I" ~4 X/ m
3 D2 ?  U6 f! F[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
  Q( ~3 m) t. K; K- R8 w痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。, O  Z! U. }1 D5 k9 R' M1 g
可以下载到的 是 jdk-1_X_0-doc
7 T7 y  v9 ]$ c
9 A& h6 e9 f  y! ~5 [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-3-4 18:18

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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