找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1454|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 k: a; Z) i* z4 j4 K8 U6 i& P0 X' k5 J3 J5 G9 X8 W
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
$ s7 B; ^7 P  A. D0 C//  ProgramCompare.java         Provided by: DRS7 {: i& r$ F/ w. ~- b
//
+ o- D4 Q+ w9 E" k( _//  Program shell for Assignment 2( G/ Q  p; Z6 F, s  O
//
) D1 z! R2 x6 ]" V8 w8 l# b' Q//  Compares two text files line by line
+ Q+ ?9 H9 G5 P2 M//*********************************************************************/ i0 r# `+ [9 @2 |

* ~# U: S7 y- N1 s6 \1 A6 e8 Vimport java.io.*;
/ x6 e' F1 V( J$ e  [0 M" U/ |+ t
/ K6 B" A) ]- m  Y; Z& O4 gpublic class ProgramCompare
) U. b" I2 Z+ l1 G" I{- h- u+ K& `2 @* N: t% a' x6 v
        //-----------------------------------------------------------------
+ m  @6 N+ _  J4 ?: D' @: I' m        // Constructor
; y: u& F6 L; Q% s+ F        //-----------------------------------------------------------------1 k# \3 G# S% T* K8 d. H! z
        public ProgramCompare()* [3 K4 E8 J0 F! K, X
        {( x' |1 C& y9 O
        }
. {4 z0 k3 ~0 i; c& d5 q8 o
  U# i' `- K( ?        //-----------------------------------------------------------------8 H8 @  G/ S! c* _; i
        // Method for testing that class has been reached
3 @: s  q+ {  c        //-----------------------------------------------------------------        7 F+ N2 `. z& g' W: c; J& `
# ^. V- T1 g) N- J
        public boolean ProgramCompareReached()        
) S& e# f) V$ O: l/ S        {
8 O: _( f2 ~$ U" V# j3 P$ ~      try ! X( d% U3 S; ?$ z
   {         ( s, `3 ]) d$ U# |% j/ F0 P3 u
                        ! i, I' w% m% _/ g4 ~! I
                //********************************************************************
, Y7 T4 A: K/ K+ K' |$ \. P; X) X                // Try-Catch Statement is used to handle exceptions - such as file not found ) [: M- S3 Y! {4 n0 K! W  t  _- Z
                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ B$ O* K# l4 B& n4 S2 r% R
                // For more information see page 534 of the textbook
3 h7 O( }1 U. G                //********************************************************************  U  R! b" k* Z2 Y/ E* m
                    
0 ?5 [' U- b# @5 r        }
) J. x' Y# E0 {3 \- U0 F             catch (Exception ex) // Exception caught here and message displayed to the screen
2 e* e# e: g* U' O          {
' E( N: t* p* x+ S1 k5 L: i                    ex.printStackTrace (System.err);
) k5 q1 R) @# J0 q! I           System.out.println ("Error message goes here"); // Replace this error message with your own          . Z6 g) X- x- |7 b( r
        }. ^' o; c  O' b  t
                return true;
) b0 v4 A0 A$ @8 a        }
1 w, l+ k4 j  K& t8 p% y/ @) p' _$ d
} // end of class ProgramCompare
- c7 |* r& t( V8 o. p( Q' W  m$ z3 U6 O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
8 P, k0 g" D. L: }/ \) I' _0 V//  ProgramCompareMenu.java    Provided by: DRS3 d1 J+ ]8 k3 n1 y+ ]7 ]) L
//
( {/ A$ K2 {8 l9 W# w* z% L; o//  Calls AuthorisedUsers.java and ProgramCompare.java
' j- H4 l- f% T2 ?# Y$ W* [( I//. O, n# c2 H+ {; N8 \6 l
//  Driver shell for Assignment 2.. _7 H0 i2 t& t. v$ g. o' E
//********************************************************************
& ]2 O# G: O$ q: d0 T% s1 T' u* [6 y8 s% u
class ProgramCompareMenu
" F. b7 H8 V% `{  L2 |: G& J" C0 h/ f
    public static void main (String[] args)
  m- f. [) a6 I1 P" n6 l            {, K& `& W  O. f" L% b4 V6 k1 G( Q
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 j6 q/ w( U2 T! w; y4 w  k/ E! m7 E
                ProgramCompare reached1 = new ProgramCompare(); : H! k' [5 Q' E' ]8 v$ j; X  A
                AuthorisedUsers reached2 = new AuthorisedUsers();          b2 C  _# k+ B2 U) n; L
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 Z# G( j9 ?" X) @: n1 b0 E8 W
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( W4 F# M  h; ]! Q' N        }1 l" v' x5 z- {) S0 ?" q
}// end of class ProgramCompareMenu
4 B9 k% W3 |- h$ y
* U/ G+ c- K% A6 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# v6 d7 `0 ^( x6 p//          AuthorisedUsers.java          Provided by: DRS
( ^5 r$ q! \  V. v//               
* D. V& l& ~* n" j/ _" i//         Program shell for Assignment 2
. R3 I2 d2 ^" |3 F) ]2 Y//
; H9 V; v. l3 h//         Represents facts about an AuthorisedUser
* u8 m  k* R! Q1 U  k: Z6 f7 h//********************************************************************( W9 @, j- j! {/ C* R0 G9 |

$ N1 p# @( M$ ~# `0 d. D9 {* Epublic class AuthorisedUsers1 K1 b6 b0 I, }" p+ v/ d( A' g
    {
6 X- i  `. f2 w# ^
* G' K5 C7 E9 ~1 J% G# [8 B        //-----------------------------------------------------------------# E0 W# }1 ?! R1 W. {: T" B
        // Constructor
3 q4 ^, r' u6 |. [" B3 [0 n        //-----------------------------------------------------------------
8 R3 Z8 r9 y; c) D- A
# F- ^- A/ |; g  _        public AuthorisedUsers()8 f  l3 U  i- D4 C0 B; @" I8 t
                {
2 s, w) J2 ?5 R: r9 T3 v0 c2 R                }6 P; s. G9 B" `5 s. R( a3 f
: l/ Q. f% J) d. Q/ g$ ]
        //-----------------------------------------------------------------" y( A' t& m9 ?8 Q8 e
        // Method for testing that class has been reached3 J5 d. S9 M6 i
        //-----------------------------------------------------------------          Q# I3 P8 k  |: f! }
        public boolean AuthorisedUsersReached()* [2 @2 d$ _' [
                {
4 y) C/ u$ [' F! W6 N( X" D                        return true;                       
1 K  T6 O+ F% R                }
+ K! Y  a" V8 J" X% H4 R1 l' e                8 i' J( y3 Q, D* u  p; j
    } // end of class AuthorisedUsers
% D  W' `. ~/ H9 j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ M) s) [" n  f# R  c' h, e5 c! X
Shanghai - 2007
7 g1 ^, N) ]8 V8 T2 w* sAssignment 2! y: {  ]0 V  E- e# ~* W, X$ B6 {
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)* }6 v. j: V7 K0 Q+ O' m
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.
3 @4 p6 U  y7 j: v$ w2 c2 h& R( qThe staff must be able to:6 |: e( ?8 O7 y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ e" s5 y! C  O* n1 T
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.
6 y7 n4 P) q3 N The interface should provide a menu so that the staff can:. c( Q! L' T' Y* s5 J5 V
a) Enter the names of the two Java program files to be compared
* Q8 }# P' c% G! } For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
" c4 C9 E0 o5 A% H5 A% X: Z' r** 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).* J4 c* Z$ G+ N) W, B' P6 z' a
BSA104 Business Programming – 2007: Assignment 2
8 w% D! g0 u, U+ ?, l8 zPage 2 of 5) w! f& ^0 h3 L6 o& _
b) Print out to the screen all the lines of code that are the same
* g. w2 [& V: R Include the name of the file and the line number of the code being printed for each of the two files9 O- p2 @9 Y3 P$ X6 d
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
1 [# w7 E+ ]6 N$ b$ `  M the name, username and department of the user9 |4 z" u) }- [( E
 the statistics of the comparison
/ c" S" a. C' ?, q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 F7 w! A" k7 Q( h  c& H the recommendation for further checking
3 P8 S& @) _* ?- 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
0 k1 {' P3 h7 Z9 r4 H: s  T the names of the two files compared) a; N8 K! G- a$ C( W/ E- i
d) Leave the program (exit)# F# @0 z2 E1 e' ~+ G
The ProgramCompare class: (Total maximum 20 marks available)
" }0 |$ b( k) B- H- r2. 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)
/ i8 h* h0 ~1 ~: l2 Wa) provide an error message if the files are not found or there is a problem opening them
5 e/ w3 |# p6 E+ P9 K* }3 B  X+ j, rb) compare each line of code: j) f3 d& E. E7 x9 F) c7 x4 L
c) print out the lines that are the same
& S+ `, v* i; Vd) count the number of lines compared / lines the same1 ^! }5 N1 K* q9 P" m. r
The AuthorisedUsers class: (Total maximum 20 marks available)
$ Y/ X: E! q2 Y4 x3. 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)
8 D3 p8 ^4 g' O- z5 \4. Provide methods to:
% w2 `4 C9 _/ o* g1 @/ G* c! ?! Ma) 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
7 l! O5 T* d2 z' Y' wb) return the name of the authorised user) T* L1 W1 P6 W$ S$ N. U0 m
c) return the name of the department of the authorised user6 G7 A, s5 w7 w7 z) a  a" b
Individual Data (Maximum 20 marks available)
# X( h/ Z7 }( g+ E4 }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 m0 o7 B* c; B% @7 y' k, C3 v) cDocumentation (Maximum 10 marks available)$ V: K% R% q  z  l$ 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.5 v$ T+ K, ^1 [& q1 w; R: D/ W
BSA104 Business Programming – 2007: Assignment 20 _, n- z3 {" r  X* M+ [1 l6 V$ R3 I
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ {4 v2 m0 J. a; S( N
不过你要翻JAVA的类库说明。你有下载没有?
/ o/ w) I2 E0 w2 r6 Q$ N# T4 q# P9 K查询关于对比的函数。貌似关键字是contrast,还有compare% F9 t+ P+ Y$ x6 w
) ?- l1 A% X5 j: M& _; ~
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -* y; y$ h" e* U- x8 O9 v
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ k2 U6 |3 [+ t2 Z" R1 w
可以下载到的 是 jdk-1_X_0-doc
& I. N- |& n8 g2 U5 j8 w$ ~0 L* X0 j( a4 w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-13 05:07

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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