找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1516|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 |2 `+ l& G7 f3 C' N) _ # B8 @0 \% x3 f2 g# j/ a
回复

使用道具 举报

 楼主| 发表于 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 N5 \& i. h/ ^7 W! y# J//  ProgramCompare.java         Provided by: DRS
7 @# U, ~0 r( U% [. |6 s8 J//, q# _( C' o" l. M6 t$ Y
//  Program shell for Assignment 2) |; o6 B" k( i1 h! e1 {% t
//1 m/ A; a" R6 e8 @! r. h
//  Compares two text files line by line
$ A7 T6 Z8 w$ ^/ j3 u//*********************************************************************
( V( c$ d2 u: Y6 q* V
( k% S5 D! l# Q6 g( I: a$ Aimport java.io.*;
" A8 \5 k5 z5 k$ h) q* e. b" ?* n" V, u1 [
public class ProgramCompare/ w6 `9 f9 z4 f2 @$ e5 j3 }
{
" K9 P' u, u( |2 k0 R        //-----------------------------------------------------------------
( e0 b: k# G2 ~! @; T4 M        // Constructor
" r! M& W) J8 W  l2 ~: C5 g        //-----------------------------------------------------------------
# p* U5 o/ c( t) O& E' h! q        public ProgramCompare()
: A; _4 b1 j% Q4 }! z# k        {
1 L2 F# G3 P0 b$ Z        }' ?& e, a. G6 T# A

2 m0 g% V( ?! s7 G        //-----------------------------------------------------------------* z. }) x4 M0 y; f, N
        // Method for testing that class has been reached
, f# j4 ?+ [# D7 D0 r        //-----------------------------------------------------------------        8 G! D7 n/ w" g1 Y/ [+ y$ _

$ k+ [  G- B! l2 }  z  C        public boolean ProgramCompareReached()         , x+ [8 R9 X& h4 N" i7 k
        {
+ w2 _9 P* q7 x/ G/ C/ ?& G      try 9 n2 ]  C4 ?  d0 ~: P4 t
   {        
/ G. k# [) V3 r                       
5 M# {# u' b; Z( m  S                //********************************************************************
& \" P, c4 j! i7 C                // Try-Catch Statement is used to handle exceptions - such as file not found - u! O# R5 a4 Y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, l7 A( P4 I/ Z6 m3 v                // For more information see page 534 of the textbook
# b! O2 L: L7 j1 i& j                //********************************************************************7 l% n8 B9 [$ M4 Y) \* Q
                     - V. ?$ I% S: u+ }. q
        }) }8 _" a' f& @
             catch (Exception ex) // Exception caught here and message displayed to the screen
0 @$ h1 b# {, B          {% {" O: p- d8 D9 x8 T
                    ex.printStackTrace (System.err);
2 f8 M! q( h2 l0 k           System.out.println ("Error message goes here"); // Replace this error message with your own          ; E9 }4 J: }: o; V: `2 D( N
        }' g0 \. d$ X" ^! x6 ?% ]/ `
                return true;
; J+ I- W7 c" ~: ~. O        }
3 ~# l2 W" r5 d% |' `6 ^. h% i2 v! c
} // end of class ProgramCompare
$ t4 c" A% W) [+ L' i$ N: K
5 q( L) J5 ~, z  X, \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
: G) g/ A$ S3 C: Z! `+ n3 @//  ProgramCompareMenu.java    Provided by: DRS7 q$ o$ i0 d2 z: w
//
- n/ O0 K& O  a7 ^//  Calls AuthorisedUsers.java and ProgramCompare.java% [8 I+ c2 M3 J) ?
//
4 _% a. k8 Y- n2 ^- n7 f1 Z//  Driver shell for Assignment 2.4 C0 M) B7 H7 Z3 ^# u5 b
//********************************************************************
. m6 P% H- {3 T& W; I3 K/ h
4 M5 |+ D- `; @: N: Kclass ProgramCompareMenu5 Z5 |! ^- t& F0 ~+ S
{
9 f- k! F% E- K6 R    public static void main (String[] args)) T7 q( O1 ]+ k$ S: X  L. M
            {
- z' `, m5 ~/ [& W4 ~% d! ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; K, ^3 [  R, \: v7 z, I
                ProgramCompare reached1 = new ProgramCompare();
3 e* N. Y7 }$ F" I- Q& ^                AuthorisedUsers reached2 = new AuthorisedUsers();        % ~1 P: o: Q. t( H8 N% F+ z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& d0 ]% c; L3 |. q" h2 g7 ]4 t% a                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 y& r1 }0 ]; K" p4 b9 v        }
% L3 z7 }4 d2 n; h% V. }}// end of class ProgramCompareMenu
4 F2 z, Z' I: ]6 g
4 @# k' N& X0 M7 X2 L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' D! v8 \+ U2 `5 M8 B) `7 w; f//          AuthorisedUsers.java          Provided by: DRS
+ ?& {+ M+ m+ H- C9 M//                  ~7 I, T+ f+ M$ w
//         Program shell for Assignment 2
3 L$ Y- c( t5 M  h/ s9 ~- T( j//
0 O% q7 g: Y. t! m1 L) @* D8 t6 ]/ e//         Represents facts about an AuthorisedUser; W) q/ D6 A6 V
//********************************************************************
* e$ t0 l6 y0 G1 V& A" |
* L; Q$ M, ~0 i% t' ~7 ?public class AuthorisedUsers
( f2 j/ Q6 x  o$ q& C+ D: E    {
4 z. I2 a3 V: o/ }3 E' W( v# r' n7 ]1 M% ?8 u; U) h4 Q" n
        //-----------------------------------------------------------------0 J& B$ `  o% X6 V
        // Constructor
) i; U2 \7 F6 w+ l# R& ~2 T% I        //-----------------------------------------------------------------
& K2 q$ t# P( S8 C- A7 \) G/ P3 h) t7 _8 @5 X
        public AuthorisedUsers()4 w1 `1 Q1 [5 [8 o+ s
                {
0 u' l" z0 x$ @  m4 u3 r                }- K' _8 C/ a! X; Z& ]
& g$ w0 K, c1 ?) Q
        //-----------------------------------------------------------------( \. ~6 L1 D. A* m: S2 C6 @, F" u
        // Method for testing that class has been reached  ?. Z- l! k8 u+ S4 R0 r
        //-----------------------------------------------------------------       
& v$ }8 g6 r5 `        public boolean AuthorisedUsersReached()
% `' [8 j2 p3 |3 X                {7 j1 x! D- i$ x/ n' f
                        return true;                        7 J" b. N+ v, d
                }7 N. R! r  E! U$ K! d6 }
                $ ?0 W- E4 v$ c& x' \$ T0 L8 c
    } // end of class AuthorisedUsers' B3 ?$ H3 A3 _; A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 }4 r" C, f0 k2 ^: ~3 H" j9 lShanghai - 2007
( o9 v) U- S/ e& }# A+ b7 KAssignment 2
* Z, y% f' W+ F! SDeadline 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)
, W% B( x) Z( l2 J: }, _9 ^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.
. k1 I! \  F& [2 nThe staff must be able to:
; o% U2 g% ?0 u, z: k Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.( N8 N7 v- B6 Q+ U
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.* g& \7 r; I/ V+ Y
 The interface should provide a menu so that the staff can:
4 k* t8 O: \! sa) Enter the names of the two Java program files to be compared
1 T7 b% r' h* r$ J5 p) h; f' G3 a For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) N$ Z4 A) f" `  |
** 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).
* @7 t- Z# O0 r0 Y- H# F; bBSA104 Business Programming – 2007: Assignment 2
% a+ e. i$ Z! a' f' C8 ]2 K/ SPage 2 of 5
8 y9 B2 Z0 H8 H! qb) Print out to the screen all the lines of code that are the same
$ `5 A5 P# x+ j* i( X0 X  h) y Include the name of the file and the line number of the code being printed for each of the two files6 z! c- I' v, F! R9 @9 l
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 h  `% ?; v" l, {) _ the name, username and department of the user6 |- a$ }+ C- {/ P2 _- e0 Y& p& d
 the statistics of the comparison5 l/ u* c! P9 }" ?& L) F; u
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! [6 @, f% x0 g the recommendation for further checking
+ n8 h# c  I, @3 t7 d, Y9 J- 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
: q9 V" d- o+ R9 O7 _7 U the names of the two files compared- ?# f6 S) a. \
d) Leave the program (exit)
6 B' @3 a* @8 I, }* ^; d+ @The ProgramCompare class: (Total maximum 20 marks available)+ s" ~/ Q$ P! A4 ]- q6 Y
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)$ ~  k" [. W# Y2 e+ X
a) provide an error message if the files are not found or there is a problem opening them: w8 [; o8 @1 R( F- N
b) compare each line of code1 z. D- E. z8 o$ X0 n6 c5 L
c) print out the lines that are the same" j/ X. E. `- H0 U
d) count the number of lines compared / lines the same
2 x* Q2 R2 `" l! M: AThe AuthorisedUsers class: (Total maximum 20 marks available)" n  L1 Z! {& A/ y, @
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)
: Y% c# V& C$ I6 @8 T4. Provide methods to:
2 N% f8 h, w4 {  _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
0 Y; E& T4 a9 Bb) return the name of the authorised user( T7 J: C- L: k- C+ U$ X
c) return the name of the department of the authorised user
2 q. H/ ^: T6 _: X" a/ n& EIndividual Data (Maximum 20 marks available)2 m9 r/ y8 W% @$ ~& C% X  d7 }8 R* E: |
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.
; \7 g0 W$ g5 Z% W5 i- q& \* \4 [3 ODocumentation (Maximum 10 marks available)
; N  f* q' ~# i6 K6. 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.* k, U5 [' N3 k) @1 a7 k
BSA104 Business Programming – 2007: Assignment 2
3 h( H2 m3 \. |' JPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) C+ x8 ?0 n! R, Q7 y6 N7 Y
不过你要翻JAVA的类库说明。你有下载没有?
# H$ B0 k6 J. R6 {3 K查询关于对比的函数。貌似关键字是contrast,还有compare
+ o2 {* n# M/ U5 L# j& ^
" f* W9 x# M$ O8 j2 Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- j# T% W8 Y' P. o- B: Q! i痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: X' l7 w8 @- [可以下载到的 是 jdk-1_X_0-doc
; k; d) ^. z, p) A/ p6 U/ ?6 f+ [! R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-3 07:11

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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