找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1423|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 a3 h$ B0 g$ E/ N& ]3 z; M% T4 n7 }& |2 n
回复

使用道具 举报

 楼主| 发表于 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& Q9 k0 b  C
//  ProgramCompare.java         Provided by: DRS! E) `2 ~; C' j/ S0 O
//8 a/ h+ g/ {# Y5 X  X" G
//  Program shell for Assignment 2
$ D7 B3 `: d" \" ^8 r, a% y//; }) e+ T7 v8 W; a: M
//  Compares two text files line by line
2 G% ]% |: t: W//*********************************************************************5 }' {' Y) j- |4 Z0 y1 ^, U
: N7 V0 N7 s5 ^2 u3 u" E' M# G
import java.io.*;0 R% z5 |; R5 k4 }, O
& H) e9 `0 p5 v! d5 j  ?3 W7 a2 i
public class ProgramCompare8 m" ]8 r7 Y+ S+ o8 F
{
9 a: J7 [4 Q- U3 X        //-----------------------------------------------------------------) t0 `; F! ~7 A+ n' p" d
        // Constructor! ]) J: q  n2 O' ~
        //-----------------------------------------------------------------
7 l" O, P" Z/ h2 c5 e0 W/ L        public ProgramCompare()# s0 r* m! l* @! c3 G4 K
        {
2 W4 X$ F3 B/ j$ ^& D( v        }9 w6 {( y: |8 K) J/ P

1 f* G7 ?- X. I" c# u        //-----------------------------------------------------------------) Y* H6 T0 h" i
        // Method for testing that class has been reached
! r2 m8 j- `  @! R9 F; |3 M% x' k; A        //-----------------------------------------------------------------        $ K! l4 ~! ]% ]9 `6 t3 c
7 L1 W2 n+ R/ w8 v. @3 A* Q# f
        public boolean ProgramCompareReached()         , A1 W7 A7 B3 d$ B( X$ N+ E4 E
        {
1 |# L2 a3 W7 @) Z) C( A      try / }$ u$ d, m$ C% H' x, c  @
   {         / G0 t  b( H3 f; H
                        2 E! l3 D9 A$ b. \& E
                //********************************************************************- ~4 A" C5 G4 ?. x6 O8 a/ A( t' V
                // Try-Catch Statement is used to handle exceptions - such as file not found
% |  r+ y% K! T2 D                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. l7 D  i+ _" W& X  l" x8 [8 U                // For more information see page 534 of the textbook
* j' b+ G" h( P) R                //********************************************************************
1 }0 W# k4 m/ P  ~( e                     & H  M: R# I" p( Y8 W, t! T
        }% s" o: X+ m! M
             catch (Exception ex) // Exception caught here and message displayed to the screen
( O$ j' x1 h! }! L* Y- @9 {          {" }7 g8 x& X1 J+ X& l9 \: i
                    ex.printStackTrace (System.err);! d+ j9 l, g- k
           System.out.println ("Error message goes here"); // Replace this error message with your own            J5 l/ Z) y# B2 C
        }
1 M+ K7 |6 M" i* v% |2 j                return true;
2 F$ D; b$ B% N        }
3 b6 V" G- X' [8 `7 \2 H
( D, B# O0 p( G8 j$ R# @3 o2 F/ w9 S} // end of class ProgramCompare
2 T, p% r. P! i4 d& R; q9 ?" S( x' g# b8 V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 `7 Z1 l" V  e$ P" |
//  ProgramCompareMenu.java    Provided by: DRS/ N# _0 v, ~6 \, K6 C
//
4 P- T7 n& L- [* L8 K+ T; K9 ?4 `//  Calls AuthorisedUsers.java and ProgramCompare.java" n$ d3 ^5 C3 E0 C
//
! m2 u$ _& A: R: v$ @8 n//  Driver shell for Assignment 2.
% B3 `& C' t: \2 K9 {//********************************************************************
$ y: R$ g& E( r" u9 l9 f2 l' I) f5 G9 c5 K% m( Y
class ProgramCompareMenu
7 u- _" o6 D" {0 t6 b! D! r3 ?{# _2 t4 m3 h; E- L$ c& ~
    public static void main (String[] args)
4 f5 P8 b$ p+ S' \+ `$ j            {
; o+ u7 n; T& y5 N8 v2 T                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 Q  |$ }$ r1 [6 d4 D( \
                ProgramCompare reached1 = new ProgramCompare(); 7 K+ z5 y) p. ?5 M
                AuthorisedUsers reached2 = new AuthorisedUsers();       
4 e' g$ U* b& `                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% v3 ~% N5 @6 H                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 W& K3 k+ e$ i3 @9 H
        }( w* ]$ m. Q3 w2 a: N, u
}// end of class ProgramCompareMenu
! t& j8 [8 L# i+ N% J" y- j! n1 Z1 h  d+ u+ e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************1 S! o2 P, T& Z, |4 \
//          AuthorisedUsers.java          Provided by: DRS* u' C; u/ I+ q8 ~3 S* b& R
//               
4 y! C* q# [8 z$ k: m  U/ ^//         Program shell for Assignment 2# d' }9 T% g) @
//2 k0 ?! g/ i8 J* G5 @6 d
//         Represents facts about an AuthorisedUser/ {9 _( K9 d- N& t* X, Q
//********************************************************************) i8 j6 c/ R- S* n
$ [  n2 Q- B: Y# n. r
public class AuthorisedUsers2 V/ M, ?( K6 R$ M% e
    {7 w9 ]/ p# _  F# c2 |: J9 Y
+ ?' w1 g9 h+ `* q( k6 G6 `+ H8 d
        //-----------------------------------------------------------------4 A% }  T  I" t& D
        // Constructor
: L2 ~' t. P) m7 B        //-----------------------------------------------------------------0 a3 y; B4 w5 N1 R

- }1 T9 @5 A' i; ^$ k        public AuthorisedUsers()
; g- s1 o% `# j/ ?7 b: N% c$ f                {: v" g% E: T6 Z/ i# j: H0 V
                }
& m; g" L. q/ w* N$ _" ?: }- ?8 b" r2 p5 Q1 w
        //-----------------------------------------------------------------# }8 t$ \2 `5 m, B) ]" _9 f5 S/ H
        // Method for testing that class has been reached% u0 w& \5 Z# r! ^4 c' A1 J2 Q
        //-----------------------------------------------------------------        * @: t" B7 H' ]& X
        public boolean AuthorisedUsersReached()5 M9 s) J; H6 O5 t/ i: n
                {
- [; f  X; W+ n+ F$ d                        return true;                        0 K' E/ R( z' i: t9 }
                }
5 W( U. t9 N% ~" Y                  G7 S8 s. |) B8 S9 B9 s3 L
    } // end of class AuthorisedUsers4 d. }; \/ l- }+ b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 F- {6 g6 v# `& p
Shanghai - 20079 y$ \9 h& X' O! \
Assignment 2
2 j0 ~# e; `/ V% R( j8 b! i3 VDeadline 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)5 a8 c& a3 Z/ X+ I8 t% |8 x
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.
! ^# b2 g4 ^$ z' \$ ^The staff must be able to:# v: Y" i& P3 v% h
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! l* I* p. M" @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.
- l. s! E7 J0 N+ j1 w# U. ` The interface should provide a menu so that the staff can:8 }9 K5 A; I  I  |. l
a) Enter the names of the two Java program files to be compared
: Q7 i3 [5 A; _( p9 S5 L3 X For this assignment, it will be assumed that the two Java program files are in the same folder as your program.& k2 g7 |7 S8 x' w9 }5 L2 d
** 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).& {5 b  O7 L/ E3 y0 d7 R
BSA104 Business Programming – 2007: Assignment 2
! J4 E- ^1 I3 ^/ w4 oPage 2 of 5' i! U2 g9 L3 a2 A1 w1 p
b) Print out to the screen all the lines of code that are the same
% n6 T+ r* @( G' X4 P3 i5 u Include the name of the file and the line number of the code being printed for each of the two files) T: h- ?9 ?1 Y- N
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, T9 p! @7 C/ P
 the name, username and department of the user+ Z* c" u) K: @- q( x' B
 the statistics of the comparison6 R" b8 ]2 I9 ]2 g- U
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ x* R9 V2 y; p- D7 r) X) J
 the recommendation for further checking
2 ?# X9 f  `7 o6 S5 F) r- 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 closely1 Y6 R1 K, ^& p
 the names of the two files compared# q$ d# q( W' m* D
d) Leave the program (exit)
/ s8 C$ G" y3 d6 V# Z/ pThe ProgramCompare class: (Total maximum 20 marks available)6 R; Q8 e' p1 N/ W5 q
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)0 J( Y3 A3 [7 J
a) provide an error message if the files are not found or there is a problem opening them
% m! z9 y# {: \$ Jb) compare each line of code
! H/ N/ |' T* h; s( Ec) print out the lines that are the same
' q" y5 R/ T3 L# F8 ^) M' @2 }3 dd) count the number of lines compared / lines the same
1 M8 J6 P. `2 E5 ]( n; \" y9 UThe AuthorisedUsers class: (Total maximum 20 marks available)
8 m2 g9 J; t9 k& R& g0 A3. 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)/ V9 n+ G, ]  ~, ^0 N3 h  U4 b
4. Provide methods to:
+ m' t' z- z. x  S' \* S% @- sa) 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
' @$ a/ ~2 F( S% }b) return the name of the authorised user
' i/ i7 o; v8 x) bc) return the name of the department of the authorised user
5 U: g, K! p6 `, Q( O- gIndividual Data (Maximum 20 marks available)$ s6 Q7 Z; Z3 q) F. v( {  ?3 |; U
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.
$ |2 o. \+ O5 Y- Z; G2 W& \* cDocumentation (Maximum 10 marks available)
! ^3 M9 ]; u! @2 v- |: a6. 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.: [- ?( x' C; j2 L5 r5 C( I9 O
BSA104 Business Programming – 2007: Assignment 29 V2 J1 a9 n$ }; G' I9 b
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( p% Q8 v) ^& x3 D! J  S  O不过你要翻JAVA的类库说明。你有下载没有?
" H: Q) y. Q6 S7 m" Z% s' a5 n' A查询关于对比的函数。貌似关键字是contrast,还有compare
# O& {1 m% P7 n' [1 a7 V9 \0 c1 \
1 b  _% G9 d  f( f2 I( t2 P/ s[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: \8 k0 I# ~# X% v" ?# g+ K$ A% R痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 x6 q& m) J  F$ J) j2 A& [8 b可以下载到的 是 jdk-1_X_0-doc
: }7 J0 t0 M! ]: @, A
, d7 Z( _! y$ J0 Q% C1 @1 ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-29 17:09

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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