找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1625|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& J& H( h1 L! }) Z& w( P8 H % N; Y+ }: y7 a2 U, a) \! e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 n1 o: `9 H% ?1 g$ r  N
//  ProgramCompare.java         Provided by: DRS& X% i9 W% y$ O* `4 X
//; J4 k9 }' G. v- N4 j
//  Program shell for Assignment 2
& M. q9 [5 @4 r0 v) ~) b' N* p//
" Y' e8 f+ ?# L1 c( N: F# }//  Compares two text files line by line- j& _6 \7 E0 b# `, n2 O, }8 A7 q
//*********************************************************************
/ L: |( p7 @1 S* F& z6 e. E' Z& E
8 S3 l6 ~5 S: a( pimport java.io.*;5 _) F4 T) e( R) E  Z* E

. B8 J5 a% F2 V3 g; U% Apublic class ProgramCompare
4 q" U, Y2 ^  u+ }& y{. ]4 c/ [5 X5 p0 |
        //-----------------------------------------------------------------
5 Z; R$ b3 z! s, ^7 `9 o        // Constructor
& k8 |4 i7 n# b( ~' _, |        //-----------------------------------------------------------------( h8 Z7 L9 N+ I/ P
        public ProgramCompare()% `# Z, S, F6 E; X* J
        {1 a! q3 s6 C* n% k+ m
        }3 Y) Q* h3 T: }1 q/ K9 d
: C: k" {, H( B3 b! c8 f
        //-----------------------------------------------------------------. b. t) ?. K, S! U. i# v
        // Method for testing that class has been reached
* N, ]/ g8 L+ f. i6 k1 G        //-----------------------------------------------------------------        , R$ Z7 I4 ?! y4 z  i3 f
' T# c% R( {, o9 M6 d$ m$ a& o8 i1 ^
        public boolean ProgramCompareReached()        
$ q. m  }1 B! D2 [6 s, ?        {9 S7 F1 \' b1 \* m- t* b" q
      try
  T( q8 X) A+ _. J1 R8 Z   {        
  S. h; r5 {# {  M                        # U. F# i8 g3 g2 I' z
                //********************************************************************) ^. M- B8 t1 X
                // Try-Catch Statement is used to handle exceptions - such as file not found
- I  s3 T6 k' g& Y7 ]3 O# f                // Reading the files will need to be placed inside a Try-Catch - just like this one!* c$ `9 K" g" \: y3 h/ M
                // For more information see page 534 of the textbook
% s2 i0 d4 H  @1 E" P8 r                //********************************************************************2 J7 P6 e' {5 P% y! u# l9 n
                     - ^  R$ H6 H4 d% l9 j5 K+ V
        }# H; U) a8 d& H6 l. \1 ~6 y/ S
             catch (Exception ex) // Exception caught here and message displayed to the screen 9 ~+ t/ ^" ?8 P
          {0 j5 u9 [2 G( m5 E2 m
                    ex.printStackTrace (System.err);
9 @4 L3 o) Z: O& h           System.out.println ("Error message goes here"); // Replace this error message with your own          1 |- V2 u' S. o$ m
        }8 V/ K, a) M8 Z9 M: J, n2 f
                return true;
/ q0 A( u7 U# y; V1 I" V        }; h: g; w# s5 R" z9 r7 _

9 n: \4 h$ Y1 {6 k$ [} // end of class ProgramCompare2 I9 K. b7 v# `' E3 {4 e

* W( h5 d* ~8 ]* F( E2 i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 r7 j' o9 b: _//  ProgramCompareMenu.java    Provided by: DRS( ]; C2 w1 T! ?- J9 f% ~" U9 \
//
7 s% ^/ t' {9 y- W# E7 o. C//  Calls AuthorisedUsers.java and ProgramCompare.java* {( h) I" B- \& @: {: v$ b/ @
//' |4 M: d/ W! X# a! C: g8 l4 }
//  Driver shell for Assignment 2.' N) w; |% w1 p- v/ y* u
//********************************************************************7 b! r- O9 |+ @2 P* q/ I
( H, w5 P, ^- A. N  f6 Q
class ProgramCompareMenu
$ P/ u9 m, B3 n- _6 o7 ]{1 ]: @& y, }7 b& f" c
    public static void main (String[] args)' J6 h6 @5 X. x: ?8 J
            {4 n- X  m( P3 G6 H5 U/ n
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: m0 S! P9 i9 |. r8 p( G
                ProgramCompare reached1 = new ProgramCompare();
; R; g) |0 |1 W) j$ \3 d0 {                AuthorisedUsers reached2 = new AuthorisedUsers();       
5 U3 r) O5 V* q: K                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());& G. m% {. `' k5 l5 t! C/ i% X  ]9 Q
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
  D% w9 A( U! d        }. j5 v# L: f- n" [1 u( o! U( I' j
}// end of class ProgramCompareMenu
# I, N8 p) H$ N8 W8 @0 L
& u) B8 k5 a) V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 H' E- o0 Q7 g6 m/ \; a& z//          AuthorisedUsers.java          Provided by: DRS
" ?# }1 j: t% o# R$ f( S# `! R//                & u6 t% Y  M. h& r( v' z. |
//         Program shell for Assignment 25 k, o+ U+ b( j
//  h, c$ t, [* q6 c
//         Represents facts about an AuthorisedUser+ ~3 x& R: }5 ?, p! d
//********************************************************************* K, k! @* q" l$ c! n

- s& b2 D. b9 z. Bpublic class AuthorisedUsers
4 S, o9 k, l7 W4 e& q/ X    {
: |9 H* a: \! O3 w7 [6 M, X1 \
& H9 T1 v! O+ x1 e& k        //-----------------------------------------------------------------' L% q3 f$ Y4 p' D: [
        // Constructor, L+ [, ?% `9 |. W0 o
        //-----------------------------------------------------------------
* l! }% \' t8 z
+ _: ^# Z6 }" ]  x: b) H        public AuthorisedUsers()
% `& G9 {0 A1 c0 ?" b: b" V                {
* C$ B4 o9 J8 \. D7 c2 I2 X" a. ~                }6 K9 M6 {! r4 }9 Y7 l' w3 {

! u. g% j4 {' r7 [% `        //-----------------------------------------------------------------1 j( t( o9 G: B& ]( ]
        // Method for testing that class has been reached
0 X9 Y( K* Z& j( S4 {( c6 Q        //-----------------------------------------------------------------        ' j- a3 z  _& q! z
        public boolean AuthorisedUsersReached(); P' j$ A' |! g( s. f
                {
+ g# U% @! r: ?                        return true;                       
- s" h3 `7 X& h3 ]# g6 c                }, f/ u/ _8 A% f/ L+ {
               
- `0 N) ]5 S. P. e0 Y3 b' d6 ?    } // end of class AuthorisedUsers
' o% J1 V' G( t; W/ @2 e8 X1 P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 h: J# m" ^2 W) X* F8 h* PShanghai - 20070 c0 D7 t/ C. A- i/ G9 p/ S
Assignment 2
5 i1 k& v. Q$ i! uDeadline 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), A) `( [# Y. I# 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.
9 u- J" m) S& I8 nThe staff must be able to:3 ?+ n" w# e2 y; K/ v- O( X8 Z; l
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.$ u& f7 {6 M6 J" p
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.
- J% M" G; O0 U% d The interface should provide a menu so that the staff can:+ X/ O1 S1 S7 H1 j% p. w; l  `/ q9 ]! m
a) Enter the names of the two Java program files to be compared  w% x$ M# _8 `3 y
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: G  y+ k  j2 c, d0 R; E8 x! |
** 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).
# L) T2 W1 B( F' y( ]BSA104 Business Programming – 2007: Assignment 20 i) i+ V4 ?7 y1 \! \  Z# v9 m
Page 2 of 5$ i2 ^! ~( e) v: H
b) Print out to the screen all the lines of code that are the same+ D/ z) O' A: h6 K% y% o! A4 w
 Include the name of the file and the line number of the code being printed for each of the two files
' T1 b" t% h, F  h$ k- g) ]c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- _0 s; b3 _: e5 \ the name, username and department of the user) M: S) O7 S. i  C4 u: P' _8 z1 v
 the statistics of the comparison
# D) M2 r/ C1 w2 ?- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 Q" k! k, n0 Z
 the recommendation for further checking
7 s  u1 _6 s8 ]# I2 R- 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
1 L) F: ^' |' J the names of the two files compared
* e6 M) Z- W8 z' b9 G1 td) Leave the program (exit)
0 ]' h5 W( u( {! `The ProgramCompare class: (Total maximum 20 marks available)
) @2 A/ B, l& o, L0 _& O2. 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)
9 V' w. F1 ^4 V9 M4 g" I& \a) provide an error message if the files are not found or there is a problem opening them
# H( x- e: z) sb) compare each line of code% M6 _) k4 M2 P" N) N! ?3 p( E  c+ p
c) print out the lines that are the same4 E# i% T7 W: V* e9 j$ l3 d) Z& i& Q( j
d) count the number of lines compared / lines the same
- S( V% g8 q$ [* C3 |6 B- DThe AuthorisedUsers class: (Total maximum 20 marks available)
: \! b8 o9 }% w- Q2 J# G# e, `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)5 p9 N7 Z: J' x3 f/ U' A5 l
4. Provide methods to:2 y- {, r- N" X  A
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 match7 ^+ J$ v4 {8 |0 K, u
b) return the name of the authorised user6 C; b- [; x0 Z5 J
c) return the name of the department of the authorised user
# ?$ Y+ X- _% ^Individual Data (Maximum 20 marks available)
9 J% Q% F6 @. {. ~& I  W5. 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 u+ E. @$ p2 u; r
Documentation (Maximum 10 marks available)7 a4 L' t7 i: b" w& v
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.+ y: r* \9 s8 v0 F4 l0 l  q
BSA104 Business Programming – 2007: Assignment 2
  Q  r; q5 w: R: n' U7 aPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ f7 {) R7 F$ o( p" q不过你要翻JAVA的类库说明。你有下载没有?
% K' M: e! q; s0 x$ P) D查询关于对比的函数。貌似关键字是contrast,还有compare
) Z2 s) f' X. E, q6 F+ _. k' p& v6 Z% V  A0 L# L( A
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -6 {% }8 K$ [* E$ ~" n
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& C: l. D( l5 n9 Q可以下载到的 是 jdk-1_X_0-doc
8 C7 \  v. H8 {0 B' {3 W) V- ]$ T# l
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-13 01:56

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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