找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1150|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 q# C n4 X! l1 d, L 4 _. @$ N( L9 E, V* K2 c7 T
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
! s* z* p. G! Z6 N' `4 H& @3 C//  ProgramCompare.java         Provided by: DRS
2 Q: u8 a6 w3 l/ U9 j8 p* X* ?1 ]//! z3 E. T# t. T2 B1 A% \
//  Program shell for Assignment 2
$ e! b& W5 [- z4 @$ U# c0 V//- R, `. }2 h3 y) Y7 K. C
//  Compares two text files line by line5 Q4 d0 t% }* t
//*********************************************************************1 |, {9 Y8 H- M  O. s& r

7 P# e5 q0 x3 v$ ^( R$ v  Jimport java.io.*;0 I- t7 w0 X" A( D7 e. x
$ @7 F2 u+ x( u
public class ProgramCompare
, C& m1 ?/ ?: K5 \5 I: \7 I0 n$ O+ F{, J; ~6 F2 a4 w0 {
        //-----------------------------------------------------------------/ t2 r& B+ u* |1 F, {+ ?
        // Constructor8 }# v1 j( |& D1 v1 i$ D% x: t' j
        //-----------------------------------------------------------------
* ^7 |2 X% [  T, _        public ProgramCompare()
% T8 c0 \6 q$ Z2 n, A        {; D  U3 O+ r- d- q
        }) f/ K4 q+ D( Q- U
% {2 H+ W, X7 D7 C6 Q: \
        //-----------------------------------------------------------------9 h' _4 T$ Q0 f7 O% g
        // Method for testing that class has been reached; E& q9 B' D0 I
        //-----------------------------------------------------------------       
; c- \7 I% ], ~( a8 |) w2 ^+ H
. N3 U! Q5 l% {6 }. d6 s7 e4 o        public boolean ProgramCompareReached()         * J% j0 s, e$ @# A+ q
        {
- h4 j, F2 ^) {# ?6 _6 c* }      try " a+ f' E. O3 _- y  u; [$ _1 K2 W
   {        
, u9 `$ N/ y2 r, U; e                       
- a0 _& @" }- C& O! |$ |2 r3 x1 x                //********************************************************************4 y0 J" M0 Z# l/ k: v" k
                // Try-Catch Statement is used to handle exceptions - such as file not found
  o' _- V9 J) E! d  m* Z  e! B                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 i( ?3 [6 `# _& D, n" v4 W, w                // For more information see page 534 of the textbook
8 w# Y2 M" X" C( I* l                //********************************************************************
: s0 {" i7 A$ d7 d                    
2 s/ P  V+ O; A4 {! A        }6 d# o0 n) @6 @; A% W
             catch (Exception ex) // Exception caught here and message displayed to the screen
; I9 C, I; H4 `) l9 q1 H          {( ?# L2 i3 x8 K9 O+ b6 a
                    ex.printStackTrace (System.err);8 h6 T7 M- y1 q1 g
           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 k" w# j/ T6 d8 ?) t        }6 G, j+ {# O4 T3 s. I4 b6 |! f
                return true;, I% B0 O' ?7 r3 _# _  h
        }7 a* s* t# ]  o
- p& H$ P& u, ~5 f" X6 ?- v+ p6 l3 j
} // end of class ProgramCompare
2 {, ?8 J4 G5 O  b% K* d
  m2 N$ D1 I* x8 y2 ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************4 D, }% y% f) Y' f
//  ProgramCompareMenu.java    Provided by: DRS
, T! j, m9 X5 ^* Q2 v8 D//% Y3 X/ F4 e& y! R1 @5 m6 |  S
//  Calls AuthorisedUsers.java and ProgramCompare.java' u! K7 W( k5 Y! d) W" X$ f# y
//8 G7 J' Z5 v; p6 `* [6 P9 X
//  Driver shell for Assignment 2.! K, |; X6 A, u6 z
//********************************************************************
% p* i4 j) q- P8 D1 q9 o9 y
, l# ~" v1 Y3 A' lclass ProgramCompareMenu
7 K" d: J$ n: L1 Y: V0 b. j  f{4 a) w  W. l$ ]* Z
    public static void main (String[] args)
% ~4 _9 F! p0 w* j5 O            {
! o2 }' ?' t0 o. i% B                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable  t$ J4 D1 A0 v; t8 e5 {
                ProgramCompare reached1 = new ProgramCompare();
% G* `" h  M; g  t" j1 j1 x0 r                AuthorisedUsers reached2 = new AuthorisedUsers();        + B2 o2 }! m/ b, D1 u- z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 V* V, h) o% j4 h0 \                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 A  z/ p" L/ F* k7 ]! f        }
! Z) N4 ^$ K* {, u/ c% x0 z- O2 n* O& f}// end of class ProgramCompareMenu
5 e" i! m- w& U
9 {/ W& P( h' E4 p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 Z0 K2 c/ g7 J! P! r2 B//          AuthorisedUsers.java          Provided by: DRS
% U( b; j5 M4 o: n. t7 }' f+ j) ]//                5 a8 r- }1 O/ Z; u- x
//         Program shell for Assignment 20 O. O# z# @& c7 G
//
, ^0 j/ Y1 m4 U//         Represents facts about an AuthorisedUser
( y6 e+ M/ Z/ E! T% L' w) A- e' I//********************************************************************4 \$ K+ r6 O" S2 ^  I* [

0 B; E6 r3 v8 N, B2 ]: A  f5 Wpublic class AuthorisedUsers* _4 _2 C9 m6 X
    {
# V7 g+ y( O! t, I0 m0 z: M
, G' q6 x* r: ^5 z% N        //-----------------------------------------------------------------
+ N5 B  _$ a8 S7 Z( U7 q        // Constructor- P1 A3 F/ C' |: ]; r
        //-----------------------------------------------------------------
; ~+ @+ }: n+ G* `9 P% a# G0 z1 @' N
9 o! V* w! z  Z1 z( p        public AuthorisedUsers()
: L; g2 x) b9 e  V' N8 ?9 |9 y& n7 d                {) j8 }- g8 J% v$ t" X! [) B
                }2 r, H/ h& A' M, r# X* X$ S9 \
7 u" }' [3 X# _: r4 A# C# R  y
        //-----------------------------------------------------------------
5 p4 Y# p  x' @! Q' B" H( p( r4 m        // Method for testing that class has been reached
; ]% x# c0 V9 e" J9 R+ m7 x        //-----------------------------------------------------------------        ! i! O( D* o7 s- j  G0 P
        public boolean AuthorisedUsersReached()
1 X) M( }% |) a! p7 C; K                {
- ~: T6 Q  U% e' V# C                        return true;                        2 F! I3 m$ b( v& P
                }4 |& w4 O* \' F# c! _+ a
               
. D3 O# l- B2 }% y& t    } // end of class AuthorisedUsers4 u" D2 n6 Z' }/ F7 O, v2 J1 W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, _# a8 @+ s* c, j$ S$ p* _, `( P/ K; MShanghai - 2007
1 q9 C& O0 D: @3 p& O% l; PAssignment 2
5 V. z& ]7 B( O9 EDeadline 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)
1 e+ J* ]" Y1 J# f% _! M1. 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.+ m1 t) k" U( U5 G
The staff must be able to:/ X3 G5 {0 `3 f. s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 U; z9 N0 ?; y$ Y, P1. 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.; ]7 W: S) }5 o7 t, {1 L5 X
 The interface should provide a menu so that the staff can:0 e) d  z, q6 p! g% R  P0 U
a) Enter the names of the two Java program files to be compared. X/ M* @! E; Y# d6 Q& H
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& C" Z$ s0 V# @** 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).% R6 I8 }4 u3 r1 s) |
BSA104 Business Programming – 2007: Assignment 20 K- ^- j% T4 _+ O$ H* k4 o
Page 2 of 5
+ K" j6 }( r5 g/ Z  M4 u- Q( m3 yb) Print out to the screen all the lines of code that are the same. U! a3 v  F" x9 R
 Include the name of the file and the line number of the code being printed for each of the two files5 o: f1 y& t* m; w' C! c0 C9 }2 \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared8 Z( J6 M( i7 J0 Q( m5 m
 the name, username and department of the user8 `7 V% L" a, `- G/ Y; D
 the statistics of the comparison
2 |% S0 Z8 }+ p- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 G" P: n3 [& g& p4 \1 y the recommendation for further checking% G( J0 A9 Y2 t; k3 c  H, T
- 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' M" [& g. X+ l; u
 the names of the two files compared5 |6 a/ _& Y# Z2 Y+ `" A" N
d) Leave the program (exit)
/ H- E: j6 a. X8 t7 }The ProgramCompare class: (Total maximum 20 marks available)
$ O* m3 V" O: @5 h' J8 Y2. 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); {4 H& Q4 y) D7 J3 ~' U
a) provide an error message if the files are not found or there is a problem opening them* `$ @, b% A, e2 e* W; H
b) compare each line of code
0 W* f2 u# j9 Z0 [c) print out the lines that are the same
* K/ k; D# ^4 {8 ?( Q1 Ld) count the number of lines compared / lines the same/ q8 ~  `. ~% O! I. _1 h' j
The AuthorisedUsers class: (Total maximum 20 marks available)& }. K9 s) ~1 N# i6 v1 G
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)
! ~" p: F" x" i% W& ]3 o4. Provide methods to:, @8 f9 u* P7 W
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/ z& O5 S. Y9 U
b) return the name of the authorised user5 @/ z4 }& v, R+ g
c) return the name of the department of the authorised user
# ]* q# h/ j) z; Z% l' L* bIndividual Data (Maximum 20 marks available)
9 ^$ g# T5 I* {7 k* J: `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.# ]5 P: H* j/ @3 j' L
Documentation (Maximum 10 marks available)2 n3 ?. ~8 _$ Q
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.
7 J0 b/ g, g1 fBSA104 Business Programming – 2007: Assignment 2
2 g6 S- x$ r7 B3 t# NPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 k+ b, O0 @2 w; |不过你要翻JAVA的类库说明。你有下载没有?
! k; y1 R6 L; y7 ~/ F查询关于对比的函数。貌似关键字是contrast,还有compare6 y) J, ]! N1 N% t, N0 f6 c

( ?" v3 R5 O! g2 G% _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ t7 U4 Q. T1 F5 }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' c: f0 t4 h5 N  Q
可以下载到的 是 jdk-1_X_0-doc
! k& p! j1 r) M3 I
1 P" u4 a+ P& ~. H7 `& X9 N/ [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-31 16:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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