找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1151|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& Z4 p5 @. e* W: r! r, F2 ] 3 Z d& f' L% F3 P% ] Q" n+ ?+ [ ^8 f
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 o* b' f$ u& A, A/ R5 Y3 }
//  ProgramCompare.java         Provided by: DRS+ v2 N' x/ f7 p, z, H
//: k( h% c" e* ~# f5 W
//  Program shell for Assignment 2( C* _1 I2 m. B- ~
//: ]6 |% v8 v( s5 }9 t& h: S
//  Compares two text files line by line
% A  `' q7 C0 A1 F& k/ q, B  v+ k//*********************************************************************
* h, A+ D0 s  \8 J4 q1 V. S: C2 b+ X5 M, M6 X& ]
import java.io.*;
1 H$ N' q2 s  |! i6 s' H
8 V6 `% l$ \$ t; f  o8 zpublic class ProgramCompare1 C. X8 t4 V/ _. N4 S! x8 C9 G; N# S
{: s. d; i* J; W  f" ?$ y6 y* ^
        //-----------------------------------------------------------------
7 a$ {4 Q. B. n* k        // Constructor6 A- t% L& X0 T7 l+ K9 c
        //-----------------------------------------------------------------
7 k: f; y1 {5 p. A$ {; a$ M% D. F! R! X        public ProgramCompare(). E+ O' y: l/ ^( d& ?
        {
5 }2 V% x# H& ]9 u! N        }
; d8 N. i  u8 O4 W3 L% Y2 m0 g/ q$ o5 c" i# e! f0 V
        //-----------------------------------------------------------------
  v# J# x" ~2 ]3 X        // Method for testing that class has been reached
' |# w/ O) ?- _- d8 L( E9 o/ l& [# U" b        //-----------------------------------------------------------------        ' v9 h$ W, l6 A* v- Z7 M

$ R* f# ~! I) a. F' }/ {" T& p% X        public boolean ProgramCompareReached()         * ?' H( Q( ~0 O7 v; _- a* Y) d
        {
; [3 ?. @6 X8 p# j$ W+ S9 o      try , V8 K" Y/ Y$ G9 V: [+ }
   {         % ~0 l) h" X& O3 u9 g
                        ! i. A9 E1 V) x; G# K& M, p
                //********************************************************************, n6 f8 i1 Q( h! e& }
                // Try-Catch Statement is used to handle exceptions - such as file not found 6 ^, |/ x2 ^) ^1 P& M3 o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 ?  Z: x# O* M) \' ?) Q
                // For more information see page 534 of the textbook
5 T+ q8 X0 e( [2 N- h                //********************************************************************/ v0 f1 W: M6 ^6 x) a- @6 J" W
                     4 d' `  d) N; A& C
        }
8 D4 b. l) H9 P% ^" S( v             catch (Exception ex) // Exception caught here and message displayed to the screen ! M; h. q+ b  Z! M& ?6 @
          {+ d1 a, H$ w$ I7 M
                    ex.printStackTrace (System.err);/ d" J. e( O8 i+ F" _
           System.out.println ("Error message goes here"); // Replace this error message with your own         
; m. n& U* Q  @, S        }4 @& r3 Q/ y& f3 \7 D6 O
                return true;* h( a9 O3 {- F. a2 V, Y+ q
        }0 t( [0 s% a4 x5 \

& ~* q- P; r8 ^0 _7 q5 ~* o) N/ [} // end of class ProgramCompare( T2 O/ N( J; U! p  @
' \) \6 H$ L& T$ F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ _/ w8 S' P0 ?4 N- ^. v) c4 E) f//  ProgramCompareMenu.java    Provided by: DRS
3 q/ M# V" B' V( S. J: {1 T//
  [8 b+ q: ^, i" b; G//  Calls AuthorisedUsers.java and ProgramCompare.java) I4 h6 d- D" {$ e. l, H
//3 c4 f) D1 B& M% e9 S
//  Driver shell for Assignment 2.
8 l4 h* Y* i7 H6 ^5 J//********************************************************************
$ ]( x( g8 G2 {" ]7 q% g4 a4 N7 ^7 _4 ~% P( G" T/ q2 P& ]) @$ a
class ProgramCompareMenu
. P+ L6 l( Y3 A/ }- `{& ~! n% H5 W9 m) m1 e
    public static void main (String[] args)# x+ O4 C6 ^0 i+ K$ G; S
            {0 u  C# e" k: T1 d6 T8 K8 C
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 g0 n7 t3 v" f# A2 W8 f3 S5 {
                ProgramCompare reached1 = new ProgramCompare();
" ?5 x4 e$ u' ?                AuthorisedUsers reached2 = new AuthorisedUsers();        . }. S' E6 L1 g! h- P( t
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' p( d8 n- `7 {8 n* k# z, u, c6 J
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 Q/ j9 B4 G8 Y% B        }
- H$ A8 b$ t; F9 x! v% g# g}// end of class ProgramCompareMenu
" S3 T9 O, v& K3 f1 E7 J8 D) U
: V. m. K. \* s# k4 N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************( }/ Y. ?5 ]+ ~- K) z% ^) b
//          AuthorisedUsers.java          Provided by: DRS: z$ h. T3 h2 L  W: B
//               
  s: B3 N) _; |' P4 I0 x7 _) N//         Program shell for Assignment 2
' W" D, w+ `5 p8 y6 a( g//
! u# T  |4 V' k7 m//         Represents facts about an AuthorisedUser+ g) j$ @" y; h  ~0 D: k
//********************************************************************
$ G: E: Q3 z. l
, k0 T' F4 }6 W3 S8 l4 L& H5 vpublic class AuthorisedUsers4 R1 M$ x' E7 I# }2 M
    {
- T" c0 }0 u5 N/ v8 i6 L  Q4 g2 y6 O; {% O2 Y) R# y' \/ B* Q
        //-----------------------------------------------------------------. d6 z, v# h/ r/ q6 I
        // Constructor8 G% A) B" V" @) ^
        //-----------------------------------------------------------------
! g6 Q' g: t2 k# h  Z1 k5 i% Y3 D. k* j5 G
        public AuthorisedUsers()
. x: ?/ D3 ]# @                {
1 a5 t9 P5 e5 _0 P: k                }
7 T; A% j, f; O7 ]
5 x$ k# @8 D- ^$ h/ k        //-----------------------------------------------------------------
, J& Q2 M- b9 Y' ]        // Method for testing that class has been reached
& {5 |7 v( n. h( n        //-----------------------------------------------------------------       
6 A' Q! ~6 E- l. Y7 K        public boolean AuthorisedUsersReached()
7 c' X' I3 B* K                {! M/ m$ {% W! [- |
                        return true;                        2 J* t6 _- c& H5 q" c3 d9 j
                }" W6 l+ K1 [) e+ M4 {
                4 Z" X- c, I+ G. }
    } // end of class AuthorisedUsers' C, C, v" M4 V; H9 g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
$ W2 X/ R1 o0 A! |4 }6 {. kShanghai - 2007
) M3 F) \* T) z, v7 LAssignment 2. z' B) i, T9 G% |) Q+ ?
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)
' k* [! y4 B1 q1. 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.
+ O( M2 ~$ J- q4 f% AThe staff must be able to:
) ~! R6 ]$ T2 F2 j& P5 N% R Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# |# A4 W$ ?' e$ C% L- q/ N1. 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.' j2 `, A7 J; P+ [
 The interface should provide a menu so that the staff can:' ^7 G8 k2 O  i! y* u5 }7 [
a) Enter the names of the two Java program files to be compared
- }9 D+ D. h. a' t: n For this assignment, it will be assumed that the two Java program files are in the same folder as your program.. o# ^" a/ `) g: L( `
** 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).! T% U* C9 ?. ~$ a" Y9 q
BSA104 Business Programming – 2007: Assignment 2
, K0 }2 I* {) G3 A4 KPage 2 of 5
+ B5 G9 w' H2 s8 gb) Print out to the screen all the lines of code that are the same- r- T4 {' x& Y
 Include the name of the file and the line number of the code being printed for each of the two files5 `+ S+ b& D3 L" l2 N3 X" p% l- f
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared7 p  U! N4 j1 m3 o) h6 g, Y
 the name, username and department of the user
; Z3 p" W# ~; T" p0 `( G the statistics of the comparison3 u  H  C5 N$ o* n$ h* [
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 n  H# F$ |5 {" ]
 the recommendation for further checking
* E% l$ k) B. M1 A8 W1 {0 x- 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! I; H% D. U/ k0 r- |$ Y
 the names of the two files compared# D) H4 g* R) b! e! R
d) Leave the program (exit)
2 P9 W' |( b2 J. @The ProgramCompare class: (Total maximum 20 marks available)
$ \! E& B6 W$ e2. 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)
  R) S6 T4 h1 t, B0 l9 E: O7 c+ Ma) provide an error message if the files are not found or there is a problem opening them
. C- }2 J* X( P: |' V7 m0 vb) compare each line of code
! f' k$ C1 X: A; \7 m+ \: Qc) print out the lines that are the same
, g; k# t2 m- [0 v$ Nd) count the number of lines compared / lines the same
" R: y; m% E; D  w! K7 k' i4 OThe AuthorisedUsers class: (Total maximum 20 marks available)
" x4 [5 l# F! Y0 v1 Q+ q/ J3. 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)
3 X; B0 `. |! Z( \: Z/ O4 ?4. Provide methods to:
- ]8 P1 z- j) h; Ya) 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
. \5 k" A* E  o* ?b) return the name of the authorised user# Y/ W. y1 C1 y' a, E/ K: U; p) Z
c) return the name of the department of the authorised user
2 u9 J. `9 {& ]( BIndividual Data (Maximum 20 marks available)
8 X9 ]! g9 d9 E% A5. 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 |) R) b+ t$ s- @& V+ B
Documentation (Maximum 10 marks available)
- N4 y2 O, \, T! l. S5 r/ e4 T; G6. 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.+ L7 V- b2 D. c, O. v: `
BSA104 Business Programming – 2007: Assignment 2+ z$ W; g" S/ y4 O. ~0 [7 D
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* I" |% c' m* y& @不过你要翻JAVA的类库说明。你有下载没有?( b  E* ~$ w$ ^; Q9 L4 Q
查询关于对比的函数。貌似关键字是contrast,还有compare
: c' s5 p( o7 L' T. ]: _
5 x7 S4 ~/ t) `% T2 o: W& Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
0 T' N3 L3 Z8 x& `* `) {& P9 U痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
! ~% T/ S0 K3 \: c) \可以下载到的 是 jdk-1_X_0-doc
& v' F/ h0 R7 ~4 ~5 u4 }" A) P1 b+ W# h# l! m
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-1 08:39

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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