找回密码
 注册

QQ登录

只需一步,快速开始

查看: 929|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 $ b7 d# K) y R1 ?: K" N- m- \; B: G9 I- B2 H) H
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
# t: s3 x" L' J. K( p//  ProgramCompare.java         Provided by: DRS2 C# m6 F/ ?7 H3 g
//
. d5 U  C/ {0 c/ w; f//  Program shell for Assignment 2# Y' h" o  f! f9 H
//
. h- e/ I+ B% [7 a//  Compares two text files line by line
' L, X  _' F* I0 H" ^9 l//*********************************************************************7 E2 o; O% ]0 T- z# s

' l  g3 w. |; p& \! ~import java.io.*;. c- Y/ _2 z0 e  Q

, a2 @2 K9 D: I, O0 g4 gpublic class ProgramCompare! f& R- I- k9 P0 ]3 H% O
{7 M1 M0 s9 Q( ]' c* v, j
        //-----------------------------------------------------------------
7 P0 u. F% T6 _! m1 g. ^" i        // Constructor& n! k# z( y2 F5 W
        //-----------------------------------------------------------------
1 M- u8 v/ b3 B5 r        public ProgramCompare(), [! F6 T. ~8 k5 O2 t" @% x
        {6 i$ d0 e* ?  ]$ p, G
        }
/ B) L: F9 k1 E$ C3 |+ T5 W, `" X) z0 w% Y* w4 x3 C
        //-----------------------------------------------------------------# Y0 H1 d" V  t2 t/ c5 p6 V
        // Method for testing that class has been reached* r9 D) a$ j; ?6 @+ y+ D5 t
        //-----------------------------------------------------------------       
* D; b" j0 s* _8 e$ v$ p6 j7 s  ?& h6 D, r, W8 z$ ?" g
        public boolean ProgramCompareReached()         . B( _6 L$ U" N6 ]2 E# H
        {
" I5 L( r! i! K+ t/ O* I9 L- ?: X      try ) T2 t" M4 E- ]# e8 k2 d
   {        
9 O# V8 L" O* T  r1 t7 b& f                        . J3 y" Z& V/ V2 C+ J  n) D/ @
                //********************************************************************
( ]8 l8 W& t* p+ N                // Try-Catch Statement is used to handle exceptions - such as file not found # _- Q. y; o3 j
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- m) @0 w. n. C: i/ G4 f
                // For more information see page 534 of the textbook0 Y, I% j' s7 P6 q, O+ U6 [3 @+ c! n
                //********************************************************************
* s2 V0 u. ]; [  o" a' Z3 @: H                    
) ?# B+ H- N+ {$ _5 }  r        }
. {9 v. N! g2 \6 n5 V' r- W. E, g             catch (Exception ex) // Exception caught here and message displayed to the screen
: o$ L1 E- V+ M0 ^; L, F          {
3 P; `) z0 M" u. L3 T                    ex.printStackTrace (System.err);
# ~/ F0 U4 X2 n: J  W) _1 E           System.out.println ("Error message goes here"); // Replace this error message with your own          3 ^7 X8 P' W" K- \0 h: k
        }2 e7 T/ ~+ F6 V7 {( G2 m
                return true;4 u$ Z4 W+ h. k' s, ^8 K
        }$ p: k% _7 k* ?% j" S; l

8 Z1 r& W- k, Q/ f- I' z} // end of class ProgramCompare+ b7 M" {% H" L. ~: r1 }; Y7 J

/ {+ J( r; |; Y2 e# D6 x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( G" v9 @) w0 [
//  ProgramCompareMenu.java    Provided by: DRS  d! k, [4 d8 Q" E) W( `
//# M( ~+ }9 p8 t; q6 L# ]3 p3 i1 i. g
//  Calls AuthorisedUsers.java and ProgramCompare.java! p. q7 |5 Y$ ?+ N0 Q
//) D9 G; \4 z/ o8 a/ f- Y3 v) k
//  Driver shell for Assignment 2.3 W* z6 i( m2 r9 P* x
//********************************************************************
0 M1 t0 ?1 G. ]2 H6 y7 ?! ?( \. h& I5 [) O, u& a
class ProgramCompareMenu. U" q7 e' O8 \
{
9 F3 R! e# D6 T% {& o* J* p    public static void main (String[] args)
6 V) f3 y- z/ |0 p5 g7 f            {- \, q- a% \5 O& K' M- \% A* U! R
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& x2 ~7 |) [7 P, K                ProgramCompare reached1 = new ProgramCompare();
! d5 G& z3 S! c+ t6 c- b& {; s& V                AuthorisedUsers reached2 = new AuthorisedUsers();        5 V: e' V! w: x. Y. ^; y; O
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());9 ]" g* S! e  T
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ( ~6 e5 ~# M$ K- T, {" N1 g1 i
        }
" d$ X9 M) ]$ U6 Q# Z}// end of class ProgramCompareMenu
. R2 R1 W0 z+ Z5 F: k4 F, ]
1 Z3 \  C* ?' h- H9 E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ f8 X0 G5 u+ ~9 {8 U
//          AuthorisedUsers.java          Provided by: DRS
. E# L2 K, ?, r//                + x! B( g# y& k
//         Program shell for Assignment 2
! d, t( w" O: u* N2 s# l4 I//
7 h3 o6 U6 O8 S4 o" {//         Represents facts about an AuthorisedUser6 `; |) J% @$ C. R# j1 q
//********************************************************************
2 T4 I" j4 s2 `; s* n, u0 Z
" V: M' J9 w. P; ^9 {public class AuthorisedUsers
, m+ `) ?3 g0 `8 y1 _% P" w    {1 x" R. Z6 N% u0 h8 `; h- v

0 ~; C, ]' v) c9 A( a( y- l$ r- I        //-----------------------------------------------------------------
  u$ y3 R8 g2 x: }" u, x! J        // Constructor8 @9 K3 U* G6 m3 A( c
        //-----------------------------------------------------------------5 u! o. U" J. f+ }1 w. k0 O& p

* c: D6 ?$ v' Q" u9 e- r0 M& k        public AuthorisedUsers()
/ U, A5 }$ `$ }' w( B( T                {
' @. O4 I' b8 g( u- a. o                }2 ?3 F' }9 w# l8 P5 R: F* \: b

- {$ R  P! |0 k  `% D. A        //-----------------------------------------------------------------8 Q- x/ o. b- S1 B
        // Method for testing that class has been reached" J) j% r+ W: M' u" Y
        //-----------------------------------------------------------------        # m7 u% [( k: w
        public boolean AuthorisedUsersReached()" ^% H& X+ P' T4 a
                {
, a+ {  q( C9 v& a5 a% I9 D4 e# t                        return true;                       
( V( D$ X- P( M) t+ P8 h9 Z                }
( G: r8 [) l' C1 F% w                % b" n  s6 P3 p, a- i# O2 ^0 u
    } // end of class AuthorisedUsers
2 r1 m7 E2 B+ s9 L. n5 F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ g. E* L" o! P  K, S/ E5 n
Shanghai - 2007
8 T9 a# _# n: N$ }5 Y' `$ IAssignment 2
' n# O/ A  r# ?. NDeadline 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)6 @: d) ?8 c! 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." D; K! Z- W* L, N5 d+ |8 A% r6 E
The staff must be able to:
# H  j# D" _- F/ j Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 ^8 h' F9 a5 g# c
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.
, p  q3 [& }+ h1 Z  g+ k The interface should provide a menu so that the staff can:
2 l4 c0 G7 U; s. a2 ?a) Enter the names of the two Java program files to be compared# K5 w% M  k+ q
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- {, [) I* W* U# a** 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).
# d5 N. P# c" N3 yBSA104 Business Programming – 2007: Assignment 2& f( x$ S& x4 b8 {8 D
Page 2 of 5; ~1 f8 @9 G' O4 o
b) Print out to the screen all the lines of code that are the same
; o0 {; K4 m, j Include the name of the file and the line number of the code being printed for each of the two files8 V' d. L) _) A3 T  f4 Q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 J( U2 X) B: g8 L% N0 j3 D
 the name, username and department of the user5 G1 `1 P0 \  @7 o( u9 a
 the statistics of the comparison
" \/ \: F! u# v2 A  b- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" g  k5 j; i8 G, S0 q$ ?3 m! {
 the recommendation for further checking$ d; u/ r  D- p, V* 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
! z9 n" C0 H2 r- }* q the names of the two files compared% D$ x; Z8 m0 J3 L9 L3 ]7 Z
d) Leave the program (exit)
" i0 P& X5 T6 K3 ^& @, QThe ProgramCompare class: (Total maximum 20 marks available)! d! c1 X" O' W
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). G% u: [; ~- Q0 d$ ]4 ?
a) provide an error message if the files are not found or there is a problem opening them/ ^' h/ h( J; y/ k6 u: T
b) compare each line of code4 x6 h+ ]/ ?: p0 j' m9 |4 W
c) print out the lines that are the same
  m, f# e; V8 o/ v0 u8 F" yd) count the number of lines compared / lines the same
3 f8 J7 I: x) I/ S$ i" I8 S7 eThe AuthorisedUsers class: (Total maximum 20 marks available)
# \; v+ w7 k7 V9 x3 g3. 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)9 d  I1 K2 {- v" U, N
4. Provide methods to:" ^2 G' h0 r% g) 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
! x) q- Z' L0 a; I6 Vb) return the name of the authorised user
/ V7 F8 t6 c( }9 q' y0 A  ic) return the name of the department of the authorised user9 g9 A+ f. R0 j1 F
Individual Data (Maximum 20 marks available). q" V6 \2 U" ~5 w% 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.' v: }5 A0 f9 k1 a
Documentation (Maximum 10 marks available)0 l* h0 r# I! z8 ]6 X
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.+ M/ I1 U9 B( Y; E) b) M$ L8 y
BSA104 Business Programming – 2007: Assignment 2, K  J( p0 I' A" a; P: T+ Z6 q0 L
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了! F8 z8 x7 w) z1 \
不过你要翻JAVA的类库说明。你有下载没有?
* R% j: r  r4 F2 \2 H查询关于对比的函数。貌似关键字是contrast,还有compare- W$ K$ U8 t( \8 g: U" s
+ m( Y! L9 _) e' ~% e# D6 i+ a
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 n* T* N' M$ j2 M1 C% D' }% ^% N' C
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
2 L, ^( l3 Z4 O) b6 }+ w可以下载到的 是 jdk-1_X_0-doc
# V" S& M7 V+ L4 D8 U" v$ X3 Y0 N) T3 H. Q8 z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-5 09:11

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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