找回密码
 注册

QQ登录

只需一步,快速开始

查看: 954|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 F6 S! J; m* z, b9 a# U ; L; B+ m5 ?; j+ b" k4 B
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* a/ ~4 Y, }7 W/ a( ?//  ProgramCompare.java         Provided by: DRS' N* A7 g4 d/ k2 k- L
//% J  A# N3 A* U  r6 O7 [1 {" n6 i3 |, J
//  Program shell for Assignment 2+ _  Y1 t5 H' U) x* J+ t
//- t( F! X+ q. k) }( E# h
//  Compares two text files line by line
2 B8 J8 R1 p  o5 z1 \: Q( g, _//*********************************************************************
; k1 s$ `( \( {/ f; `+ r, B3 t' V: n0 t$ O2 P) j
import java.io.*;; o. d" V0 J$ V: k; `  S  x4 Q4 |' v
, U- @  \# |# G! `: w; Q6 U: n. A$ m
public class ProgramCompare0 ?1 z! L+ g. W0 `
{3 h/ V5 _& m4 O( E( V! E& j
        //------------------------------------------------------------------ [, w3 W* Y' l3 ]  @5 @4 K6 M
        // Constructor
7 D+ i) }' A5 ^/ Z; [; j        //-----------------------------------------------------------------. X$ l+ h0 W9 W  `
        public ProgramCompare()
( @5 f" Z& _3 h- J* j  a0 G% F, U        {8 {9 p) `; H" F2 p1 l8 b
        }' R, n$ A! y+ ~" X. p
+ f5 m2 F0 b$ d) s* F  _
        //-----------------------------------------------------------------% p; ^/ W" l4 A' p  S
        // Method for testing that class has been reached1 u2 v) h, c# |2 H7 L# s2 r9 h
        //-----------------------------------------------------------------       
: c5 h0 Y4 u6 K2 i* l$ C. k. Y; o. ~1 i3 v
        public boolean ProgramCompareReached()        
. Z* u5 P8 P# U0 ?/ d        {
2 l0 F  i6 ~3 @      try " @% K" `2 b: s* ?/ Q0 }
   {        
. D# D" p4 \" a' W- {, D* k+ Z5 H                        2 j! v- U% z8 \
                //********************************************************************! d4 M- G6 g$ R- d
                // Try-Catch Statement is used to handle exceptions - such as file not found * E2 ]8 z- r1 ^: D$ }- P2 m9 _
                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ M9 w  |" Q; T" C- v7 [, _8 w$ S
                // For more information see page 534 of the textbook
# r. h  j: k: |8 w9 k8 w                //********************************************************************  |0 u8 C: m5 S1 F
                    
6 l4 V- q3 D7 F' e  P        }# `1 i8 U! s' Z! r# f: E: c9 y
             catch (Exception ex) // Exception caught here and message displayed to the screen % X9 S' S6 r7 c, k( g/ ?3 M
          {
6 e4 U) t! I, ^( N/ |( |2 f* J                    ex.printStackTrace (System.err);3 G: E0 `6 n2 h: Y' U
           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 q( q6 Y+ d) J: Z* k' a# e3 [        }, e$ z9 ~/ {7 {% n7 \
                return true;
! x0 L& ~  ]2 S5 i8 C        }
* g7 N+ ]% X7 S$ U$ _. A9 P( t2 C( g
} // end of class ProgramCompare
+ Q, a% J4 d6 g: u! S9 j# R+ j2 L  M& F! v# ?( d* m# R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
! X  L% o* Z  Q  i7 o' s9 `; S//  ProgramCompareMenu.java    Provided by: DRS
- H$ ], G6 Y6 L$ x//0 i( D: b0 `4 E
//  Calls AuthorisedUsers.java and ProgramCompare.java' H' z9 M6 v, n9 s5 r
//
1 M# C& s0 O% Q  f. z, t//  Driver shell for Assignment 2.
# Q6 T3 \) H7 I& U1 A% \# t9 m//********************************************************************2 Y* N9 e* N' o' m6 r

: ?8 L! `* G  W) n* p  E: S3 ^class ProgramCompareMenu# t- }7 N5 G5 L# u
{
5 A  p% Y" x3 U) c0 X    public static void main (String[] args)7 ^! A/ }1 r& A' x4 q
            {
0 F; d! u3 ~; L  W                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
4 I) i2 D* p. q2 V                ProgramCompare reached1 = new ProgramCompare(); " O2 m5 R9 C8 p! }, y1 C
                AuthorisedUsers reached2 = new AuthorisedUsers();       
3 G5 |0 D2 G+ D5 P& z( A4 S                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- c8 u( L) E4 J' F2 E2 o
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / T! X. `& e8 }3 k8 I" T: X
        }1 G- v, @2 ^9 r. u. L5 c
}// end of class ProgramCompareMenu
' v' y, X8 }2 E6 ~! G' {  U  f7 r# D
+ I9 R. t, ~% u( a' b; H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 U, j( N2 c3 B6 a7 j! ^8 a
//          AuthorisedUsers.java          Provided by: DRS/ o7 N7 i# c- s3 }8 {9 C4 N
//                ' M) c$ J, P1 n  D, s
//         Program shell for Assignment 2# B) g/ `0 |. o2 F% [8 ?
//
- j. O8 Y/ f9 X//         Represents facts about an AuthorisedUser3 K9 u! e9 D; H4 ^/ M' t
//********************************************************************1 R( ~8 P' N) _/ ~. G/ ~4 A

, e. M6 A; A7 r" ?3 h9 gpublic class AuthorisedUsers
+ G; m7 K% B! C& A& w% B. g$ U& K0 k    {- @4 D% g& P% W% P7 M: }
; B# ?* D! D$ h( f
        //-----------------------------------------------------------------
; _1 }; D, v3 s6 x9 Z! k        // Constructor
, G0 I) }' W2 |0 E* d" o$ V        //-----------------------------------------------------------------, w+ m4 s/ x9 y* q% e

3 S6 B4 I& i) B% T" c        public AuthorisedUsers(). r9 s# B( G9 \- H; A
                {9 ~+ V% p, \. v) m; g- R1 j) U
                }
) r* I- Q& B4 G$ f* L: x: F$ B) Q4 G! M% z5 V
        //-----------------------------------------------------------------3 b1 A% R3 U! t& V* ~
        // Method for testing that class has been reached8 r$ h7 a) a$ Y$ [6 ~3 V
        //-----------------------------------------------------------------       
2 a" @* g* g7 \2 L. Q% i: U        public boolean AuthorisedUsersReached(): V6 {$ T/ w7 ?$ [# c, K
                {
" x6 P* j7 z) U                        return true;                       
3 @5 _1 |# C7 f; O4 K                }
' L. W8 ]; i) T               
; x: h4 ?) m$ N9 R3 o% P9 W# O    } // end of class AuthorisedUsers- E/ ?3 l. V# \2 u0 @: S, \" j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# Z* D: x. S9 Y8 K( r  gShanghai - 20079 k6 L/ L& k9 w2 g: Z
Assignment 2
8 H3 N6 B; _9 y; GDeadline 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 d: X2 e1 @. M! A! A
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.
& o+ F  m3 k3 |' I% ^7 LThe staff must be able to:1 x% q1 z; ?4 d0 m6 S
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 B* U4 e% r' R( ]
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.
0 L. ]. }+ G* }, x! Z& X The interface should provide a menu so that the staff can:% y7 a$ }" K$ R. Z! w6 G7 i1 Z' |! L
a) Enter the names of the two Java program files to be compared# N7 Q% D' O" |; \: p( A' S
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) [/ `, ?" O; k2 h
** 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).
: }* N1 h7 y; [7 RBSA104 Business Programming – 2007: Assignment 2% |) _0 a' l. s" O* ~
Page 2 of 5
8 C& }4 h9 `7 k# S. y( m/ Sb) Print out to the screen all the lines of code that are the same/ l4 k; ?) ]+ p% z
 Include the name of the file and the line number of the code being printed for each of the two files: ~. N! P' T7 M2 Q  s6 L
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% B" D( y3 |5 ]# V7 g2 ?
 the name, username and department of the user
; `" e, D/ e2 Y the statistics of the comparison" I1 a& U) P; @
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 l: F- @8 ?0 J  l1 F' s
 the recommendation for further checking
. ^# e$ j! d! W  p1 x6 x1 r3 `- 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" d4 C8 ]8 I$ _6 x
 the names of the two files compared
, x2 B# [% H$ D: ^) m% Z) {d) Leave the program (exit), G2 |! a( C) t  u: ^/ k$ R) w. M
The ProgramCompare class: (Total maximum 20 marks available)
8 T" |4 G8 L0 b! T3 Q2. 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)5 O' b7 y6 S& I5 X! r# e2 v
a) provide an error message if the files are not found or there is a problem opening them
& e( j1 H' l: G4 Cb) compare each line of code
# S* ~4 g0 A8 o# }; P; }c) print out the lines that are the same1 Q& T6 D0 f* Q' c
d) count the number of lines compared / lines the same5 g8 ]8 D8 V" t2 n" ~1 r$ y
The AuthorisedUsers class: (Total maximum 20 marks available)9 z1 `* a" Z* o6 t& N- L: ~7 v
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), K3 U  F9 S  b& S4 z! C+ n' k
4. Provide methods to:* e: U4 l2 c; s& _
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
; b; J4 y$ i: }; U, H, |% i7 i% Ab) return the name of the authorised user- P: o  ~6 x& _( x- U
c) return the name of the department of the authorised user
9 [% Z1 b! P5 Y+ [% U5 _: F0 r* J7 SIndividual Data (Maximum 20 marks available)
" p2 ]- i4 q2 o8 T5 r9 T! {* Q5. 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.8 H( I: h0 u9 N/ V; K9 |
Documentation (Maximum 10 marks available)
- T( h: H4 V- r+ U4 w2 L9 I1 K6 n6. 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.
" G8 {) O3 {+ t/ Y0 jBSA104 Business Programming – 2007: Assignment 2* m/ R4 Z/ ]7 H' p# \
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
) ^8 C: G# Z9 e7 k# w不过你要翻JAVA的类库说明。你有下载没有?
! o( l8 ~: I& T查询关于对比的函数。貌似关键字是contrast,还有compare9 n! A  W& Z5 y4 f1 y# Y
, ]) G2 u' |& `2 l  B0 I
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 l% ]" p# T. h7 u9 E( A7 U& ]痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 M3 ^5 L6 `% l
可以下载到的 是 jdk-1_X_0-doc
0 K" c, b& Y, n; D6 i4 u8 Z/ q+ j4 W/ k, _
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-19 18:06

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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