找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1855|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急( p5 F! n/ W( a: q Z5 { 7 H, y8 e9 ]! R/ a% o' o1 ?
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! S4 j) [) t$ w0 H$ p; E
//  ProgramCompare.java         Provided by: DRS, P6 _: y, R7 i5 t
//
4 A  C' o5 W% f9 h//  Program shell for Assignment 2, h; C4 t2 |" C" n$ P
//
: n" ^9 I# x$ X! Q* E! b: R8 K//  Compares two text files line by line8 Z6 d3 }1 S" v" G  Z" j& N
//*********************************************************************
; |* B6 Y* Q' A0 [1 t+ I  r) O
0 t6 G0 P" d2 W4 R" Qimport java.io.*;
; {9 N3 T9 ^* d, u2 s9 u6 v
3 ]2 a9 p+ t$ V* z6 {& t! Lpublic class ProgramCompare( D% W' x$ L# i" N1 ]) F
{. S' J  u0 D# Y
        //------------------------------------------------------------------ z! s2 R/ ^4 y* P4 L4 w8 [
        // Constructor
1 j$ V  Q2 I# k, c; x: b) ~        //-----------------------------------------------------------------
5 a6 ]6 {! j% W# q. F! j9 G& c& G$ s        public ProgramCompare()- v( @- e9 b9 T- J1 J& v
        {
4 x: S- h' W! X- H& }7 q2 D        }( E3 ~; @; B+ b) }1 N: q) L
. g7 D  {9 X3 F/ t
        //-----------------------------------------------------------------
& \6 \" V2 P( m; c6 W2 U5 [2 ?        // Method for testing that class has been reached+ f6 o6 a! X. C) V4 I
        //-----------------------------------------------------------------       
: D3 p9 e7 K* x, q1 P5 n
2 _7 E2 w" w( E% y. T8 g        public boolean ProgramCompareReached()        
* P1 z0 l( x5 |, d: C: m        {/ [+ c3 o- B2 v7 K! l
      try
! R' z0 K  j6 E3 W$ g! K   {         * s( P% a" y0 P' M. t
                        8 U! B8 Q; o5 D, Q8 R3 p
                //********************************************************************. ?( X" Z9 _# f5 C, i' W2 k3 I
                // Try-Catch Statement is used to handle exceptions - such as file not found
  C% w; |# ?& {: e                // Reading the files will need to be placed inside a Try-Catch - just like this one!( e9 @3 p; k) h
                // For more information see page 534 of the textbook! {/ M9 V1 k7 Q7 M- ]" u! P
                //********************************************************************) j1 R8 p7 G2 O' ~
                       w" v3 {2 v- G
        }" x0 r5 K* ^9 B2 k( D/ S+ O
             catch (Exception ex) // Exception caught here and message displayed to the screen
1 s0 @9 {# \0 q: d) X          {
4 q5 h4 p) _" X+ i* a' ]9 U, F) h                    ex.printStackTrace (System.err);
9 V/ f( M9 i( N. P5 K           System.out.println ("Error message goes here"); // Replace this error message with your own          4 G4 T. ]: d3 N' D1 b( s, u  p
        }
$ Q" P1 g" @+ \# v" N                return true;/ Z0 k: W- T( t7 m3 @
        }
; A/ J4 A/ q. N- V. }4 u1 r% p1 |9 G/ {! F
} // end of class ProgramCompare8 O% h  G8 N% ~% J. i- u( u$ O
0 C" f, r$ T' Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, n2 r; n8 ?$ l$ j- Z+ P. p//  ProgramCompareMenu.java    Provided by: DRS- U% I. E/ R0 d
//2 q- d+ c# S. k
//  Calls AuthorisedUsers.java and ProgramCompare.java
# V0 R$ S* J$ z3 ], r# E//0 I8 a2 l% r; K' J
//  Driver shell for Assignment 2.
, Q$ _9 c+ E, d; J//********************************************************************
2 s2 d8 Y. p$ t2 o
' D6 t- N) X5 j' Zclass ProgramCompareMenu9 u/ y+ j. O1 W6 z5 ]
{
3 Z4 X! f& a8 Z* v4 q- A( c9 I    public static void main (String[] args)
4 d9 x% f/ y$ t. ?            {' y" f( W+ i0 r# n4 V+ z8 i& H
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, w1 F. ?$ y5 B4 P4 H9 P: @- k                ProgramCompare reached1 = new ProgramCompare(); & P5 ], [; m. U! u0 F' ^1 h
                AuthorisedUsers reached2 = new AuthorisedUsers();          ^- k$ H/ ]: Z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! L6 a' F& ~  ~, \% ^                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
4 ^" c1 t% w+ O- \  B        }
& ]% g5 b8 ]$ ?9 C, w+ @  A}// end of class ProgramCompareMenu
) `% l  I/ X8 ~1 _+ f( S* \; W' g# ?% h# Q) i( Z# b  `6 k5 }  O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, I5 s5 W3 b* J6 P
//          AuthorisedUsers.java          Provided by: DRS
+ T  S: _9 m2 G9 n) a3 t$ z//               
7 ]# I8 G' R! [5 B" L6 B) z//         Program shell for Assignment 2
1 C! O- Q  ?2 g* ^- N4 S: O//
$ a& G7 ~/ o* ~//         Represents facts about an AuthorisedUser
' S1 {9 A6 j" ~//********************************************************************: ]  q2 L' e( b- }  I

# v" l% l  V! B$ q7 V" Ypublic class AuthorisedUsers  o0 N0 B. G7 i; O7 T) H' l
    {
( h# F+ h' h; G$ x3 \" l4 a9 g" X5 ~0 C# D) t, `) z
        //-----------------------------------------------------------------' p$ _" W$ [4 H9 Z' q, r7 L
        // Constructor: [0 r% l$ ~* l2 p* k; i( L
        //-----------------------------------------------------------------& D( D4 {/ u8 a: K
& t; V* r' Q+ f
        public AuthorisedUsers()
& `( d% c. [7 y  W                {
+ @3 L+ J! w! t$ {                }
4 _3 V6 _$ o, F& T, U2 N( p. A) A8 W& u% v
        //-----------------------------------------------------------------
2 K, U# L4 o) @3 v0 i        // Method for testing that class has been reached
/ y2 w- n$ X' p! }        //-----------------------------------------------------------------       
: \4 s* ~5 Y: X9 @0 I$ K' l' m        public boolean AuthorisedUsersReached()
- `0 C4 Z7 E2 g                {
) P/ }1 m; w. y1 ~: _1 D9 Y                        return true;                       
; Y* L4 y. H$ Y7 |                }
3 m$ \+ @  Q+ q* w: L* ?5 m: Q: [1 d$ S                , n0 N/ r8 T/ K6 `0 S
    } // end of class AuthorisedUsers5 \! I/ C8 d* N. n, G' `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 `5 W; G: W* b& v, o2 GShanghai - 2007$ o( h$ E8 F! T- B1 E! h5 S9 C
Assignment 2
! x. b4 U1 M; HDeadline 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)" z* [3 a- |# _: ^6 y
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.6 d- A7 q* Y1 u! G+ \1 [5 A* v
The staff must be able to:
" V3 F3 b2 y  K Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! d" I8 L2 R9 M5 h
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.9 G2 y' V! ~; z
 The interface should provide a menu so that the staff can:
+ u* z2 y: v  N' M2 Va) Enter the names of the two Java program files to be compared
" Y7 g# g+ o2 {' y9 N6 D. ~ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
* q( K9 W' \/ A7 \** 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).: d: }9 J# s, R8 k7 d7 M/ R% h# C
BSA104 Business Programming – 2007: Assignment 2
" I6 Z- p) m- c8 @0 Y. b- m. nPage 2 of 5
/ _/ Q8 E2 w- _  N0 t; m& s4 _. Cb) Print out to the screen all the lines of code that are the same
0 I; N7 Z3 h; ] Include the name of the file and the line number of the code being printed for each of the two files6 k' G' t  k  ]; X+ l
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
$ ~2 H6 s3 G7 K- l+ q3 P; R the name, username and department of the user7 S  {9 p& J6 q  A
 the statistics of the comparison. c/ S) N* o5 V+ H9 U2 B" q5 B
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 a  v  c% J; V6 |8 X; m
 the recommendation for further checking8 L# I& ]# I8 b5 L+ t# T' K- u
- 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
0 [6 m; {* b8 M3 H+ `+ h# |: |& K the names of the two files compared% ?( O* ?5 ^6 H3 N
d) Leave the program (exit)
$ @2 R! R# q5 z( F& _The ProgramCompare class: (Total maximum 20 marks available). d6 [! M. g6 D  m* A1 z/ K1 `
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 U" U3 [; \0 [2 {8 e5 F. v
a) provide an error message if the files are not found or there is a problem opening them
; W0 {5 W0 \& [; @3 A3 C1 @b) compare each line of code
$ E0 H7 V$ Z/ z- N' bc) print out the lines that are the same
. ?# i# j9 j& {6 Q3 J+ `d) count the number of lines compared / lines the same: r1 F+ X4 N# s6 ^
The AuthorisedUsers class: (Total maximum 20 marks available)
. v5 S& [8 x4 X3. 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): u6 ]8 ]; Q7 e* E: f; {0 L
4. Provide methods to:
6 b" T% B3 s! H% Q; Ja) 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
! O( t: I1 b* Q$ G2 J. |b) return the name of the authorised user) k2 R; t' I) L, [* l/ j
c) return the name of the department of the authorised user3 X" o$ I1 s% a0 w& J5 L7 N
Individual Data (Maximum 20 marks available)0 _- n6 A1 L4 z
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.
, k: p& U3 d  b# I( ~# `Documentation (Maximum 10 marks available)
4 r3 G6 o* ~% `3 D% @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 F1 K9 U: ?0 J  B9 M
BSA104 Business Programming – 2007: Assignment 2
8 W2 y" c  e$ NPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
6 f. |. N& V( K  X5 q: @+ {不过你要翻JAVA的类库说明。你有下载没有?
4 e3 w( [" k. b* g查询关于对比的函数。貌似关键字是contrast,还有compare0 K2 h5 e# f8 D/ E" g
% m2 a) ]0 D+ n, x& J6 T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -, A1 f8 ]6 `- R8 c
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
9 P( q. G6 I- Y; Z  [" q! h! P8 D可以下载到的 是 jdk-1_X_0-doc" R5 O! L  K' J# `2 x8 ~

& o. ^2 P. [. l5 o! G# o& B[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-25 03:40

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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