找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1723|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 W$ K/ O4 S4 Y( ^* W8 ?1 N: k+ v2 g# `6 v5 f- U! ^. K0 \
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************7 W  }0 k; J1 ]( X5 c' n' m
//  ProgramCompare.java         Provided by: DRS* u( W3 [$ s4 o, d; W' _3 Y) E
/// P6 }4 d& `  l% K; J
//  Program shell for Assignment 24 G4 e% e, m0 _- P0 V5 O7 n
//
$ z& J, |. a8 Z" e, ^8 `, I& d9 _6 x//  Compares two text files line by line  ^8 S7 Z0 }  D+ u" |1 N& U
//*********************************************************************1 ~1 n# r* P- k2 v. m
' Y  s* V8 @/ F# m" E
import java.io.*;5 I0 P5 {- a$ F* W# ?$ M

9 z, B7 L, I6 i+ e( U/ J2 C- |6 Spublic class ProgramCompare: k; A6 m: N. {  s. f
{' r0 W4 p+ _" s; W  @5 n- H
        //-----------------------------------------------------------------
9 U  b0 X- z" ^1 X. ?$ n        // Constructor* J7 T, l7 y& c) i. n6 ~
        //-----------------------------------------------------------------
1 L4 _% U8 ?" C        public ProgramCompare(), _* C$ |% N* O* G3 `
        {( g2 g* E1 t* A1 k$ O! A) ]. Q) k
        }
; A* f; k2 ?5 X( T: }. R5 ]3 c" j8 u9 R7 A: ^) @
        //-----------------------------------------------------------------+ U4 J# d) S% Q6 B* ?
        // Method for testing that class has been reached
( R- R1 V- Z" U' Y. b- c        //-----------------------------------------------------------------        / O4 `) t: b- |( A
; w- [. v9 f2 j6 M# _! ^4 e) d
        public boolean ProgramCompareReached()        
# C2 o0 s0 u* Z& p) \* _        {
2 K5 ~: e2 F% v      try
. q" w# ~6 ~4 {0 `   {        
( n" R2 E9 ]. C2 O5 {                       
5 z" U$ w. C6 Z( a" L5 `! j                //********************************************************************
- T; g' y2 k2 I4 e; T                // Try-Catch Statement is used to handle exceptions - such as file not found
$ E( }" g* d) i& c0 }. l                // Reading the files will need to be placed inside a Try-Catch - just like this one!
* R& Y1 L$ n  G: V9 F* q# _3 t3 z                // For more information see page 534 of the textbook
0 w' p4 B1 Y; t7 `1 p+ u3 C& V7 t                //********************************************************************
( y  l# B0 c1 E8 a* y. s                    
. M  V) }0 `* X! H. f5 N9 y        }9 o$ _( E1 I4 E1 A+ v
             catch (Exception ex) // Exception caught here and message displayed to the screen   m5 f# K, B0 ~9 d$ ?
          {
5 i% o3 C8 Q; W                    ex.printStackTrace (System.err);' F9 G$ A* J8 F) |9 ~' i- _" W6 B
           System.out.println ("Error message goes here"); // Replace this error message with your own          3 o1 l) w2 v: h- m6 r
        }
, `' Y( `% p+ }5 a$ T                return true;2 }% N3 C) `( S/ X1 R
        }
% h% Q' S+ ?+ T' O- m3 i( h
* l6 h9 `0 H1 O4 p} // end of class ProgramCompare  B5 x, z/ Q8 M# _; {! _# X
7 f7 j) z0 s( U* H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; m4 N+ h# u- ?
//  ProgramCompareMenu.java    Provided by: DRS# o  k2 _  {6 h- m4 K8 I
//. s2 j% {# R3 T% E# G
//  Calls AuthorisedUsers.java and ProgramCompare.java
" k8 z9 g( M' S1 x- E//
# D6 }! f0 ], _5 i9 x( z2 u/ A6 B//  Driver shell for Assignment 2.) s3 ?' Z+ i* V1 Q& x1 o- R
//********************************************************************, M# r0 X7 Y3 N" ?+ X
# u3 O' s6 U* N7 l
class ProgramCompareMenu3 l% g: ?) L# D( D9 r1 k
{: ~: N% r( M  n4 \# e
    public static void main (String[] args)
' h6 _5 I7 d  A' v4 H, X, q( j, ~            {5 k& a+ F7 x% I7 \8 U
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 J. R, a, q- _+ [  P, P. z/ s
                ProgramCompare reached1 = new ProgramCompare();
% |) P3 ^4 k' n. Q/ i                AuthorisedUsers reached2 = new AuthorisedUsers();       
- n2 S5 |) n/ W5 |; R& q6 x5 o                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
- W) O5 [& T+ o1 J! E$ R                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 X1 \; Z, x8 {% R0 c        }8 M* S/ d6 j6 k* X# E
}// end of class ProgramCompareMenu
, o2 ~5 T$ M6 h  d3 k- C
  u3 ^4 q; Z* x0 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
+ ^1 ?- N; P1 c1 n/ e//          AuthorisedUsers.java          Provided by: DRS& }/ b1 W- r* [* v
//                3 C1 U" x& y5 O# T" G3 r$ M6 n
//         Program shell for Assignment 2
5 n- k$ g& n& |1 S7 V9 p% X2 N//
1 j; W+ \- P; Z  d  y* f//         Represents facts about an AuthorisedUser
6 S* x) {$ {# f' _1 D5 G6 `//********************************************************************
; E2 S6 B- `) Y3 Z  x- A
( i0 d7 N0 ]/ \9 f" p6 H4 Dpublic class AuthorisedUsers, ^7 z/ J. \. y) ^8 k
    {
1 E2 g2 T! |' q
8 u( G) l  y3 Y, [        //-----------------------------------------------------------------5 p5 l2 I! m8 z( h) m, m
        // Constructor3 Z$ [5 m6 F8 R3 t  q1 V: f) a2 c- t
        //-----------------------------------------------------------------
0 u; V& h2 d& C
4 i5 v1 O2 j5 j( I& I1 J+ }  D        public AuthorisedUsers()3 {" Z! a9 \8 |% h9 ~* N2 M$ A
                {/ S% N+ o' b! C; w2 Q* Q
                }! F$ ?$ x/ _4 d) e: C1 D  a

' v1 |# D% e2 N" \6 X8 D        //-----------------------------------------------------------------; `' i4 x# i% T$ K2 f
        // Method for testing that class has been reached7 N- M; |. n+ e1 |% U: t
        //-----------------------------------------------------------------       
( {  {0 p* h. E$ G- }6 q9 t        public boolean AuthorisedUsersReached()
0 Z3 E# @% h$ k  ]) j0 n                {0 C" {, N4 V4 K; g& g
                        return true;                       
. t+ h) w4 p+ ^3 d                }
* B+ a" u5 l- N0 z                # H, c) n1 Y* T4 @2 W0 X
    } // end of class AuthorisedUsers
# T! ?! k( n$ n) x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ K. @1 N/ n5 l& }
Shanghai - 2007
5 K0 r* {: B' d! W' {Assignment 2
7 O# S2 n# x! a; D& {& F" 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)
* T, @- s* J! M2 I( ^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% \1 B1 o+ E$ j5 R: n* fThe staff must be able to:1 L: q. H1 X7 |) [( _" w
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.4 D; K$ f/ G6 t4 ^( N9 W* @3 v
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.( K2 b) j$ Q, E! l2 A' y3 G& F  M
 The interface should provide a menu so that the staff can:! E/ R& R! E0 v6 F
a) Enter the names of the two Java program files to be compared1 h; f7 t3 M6 j( Y2 {7 W" }
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: ~3 l" n6 ^% W' U
** 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).4 f% d  U# E8 R6 Q
BSA104 Business Programming – 2007: Assignment 23 M, b0 q' M3 H
Page 2 of 55 v5 F  \' @2 D- w' Q; u
b) Print out to the screen all the lines of code that are the same. m% f9 d0 N2 }/ E: K! P* ^  g
 Include the name of the file and the line number of the code being printed for each of the two files
( y) o: s. z6 c% s" v' wc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 b4 x7 a/ ~& ~( j+ ]
 the name, username and department of the user
4 m& z. _: b4 z7 _3 R the statistics of the comparison, J9 N* W  [! b  ^7 Z) w
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 P0 \- `, o& r2 T3 b
 the recommendation for further checking
  V: M. c/ j8 ^9 B$ ~* O- 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 closely3 R2 X/ i7 I: x8 [% D1 C
 the names of the two files compared6 E0 y! E1 t: h2 D  b8 @7 O: u
d) Leave the program (exit)
0 H7 U( H7 ~7 C6 G- D) I* B; cThe ProgramCompare class: (Total maximum 20 marks available)5 R& [" t5 p  B6 x* `, U( X
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)
& @5 b+ z5 \0 o; D' X  Ba) provide an error message if the files are not found or there is a problem opening them
5 `9 {# t/ w' eb) compare each line of code+ |. {0 N" [  ^1 O5 ?
c) print out the lines that are the same
. ]6 M7 v6 p. p) E( Bd) count the number of lines compared / lines the same% n" v/ q) F, F4 ^# ?
The AuthorisedUsers class: (Total maximum 20 marks available)
) X4 O3 ]* _0 I( P5 a2 d3. 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): x: X! s# J+ v7 |
4. Provide methods to:
  _& b! T; e: u. Q+ N  p' m+ R0 T. E) P0 b* Ua) 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
& T2 d: c$ J1 B) _# ub) return the name of the authorised user" V/ E5 W! L. s, M; b# D# m, u
c) return the name of the department of the authorised user
+ ~! Q. H) c6 X- q" ]: [Individual Data (Maximum 20 marks available)
, Y- N; W$ C; l2 V6 B2 K% {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.+ i- M+ y& U: ~
Documentation (Maximum 10 marks available)9 O4 M. }& q/ `5 y
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.; q% b& w; E5 R) T# T
BSA104 Business Programming – 2007: Assignment 2
3 Y0 ~, t$ S+ R6 w" G3 S& @Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 `4 M  J5 `; {9 W% a- ~
不过你要翻JAVA的类库说明。你有下载没有?
5 A2 Y9 t# e) {0 n' P4 M9 r1 u查询关于对比的函数。貌似关键字是contrast,还有compare
8 _% f6 l3 q, {4 C& q+ H9 g
+ u8 i9 l! w% Z$ m# R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -. \' b6 ~: ]1 X* b$ W
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ K7 {$ S3 x3 c
可以下载到的 是 jdk-1_X_0-doc
6 M/ `- n& E* z0 [3 k" y( t# C7 K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-13 15:40

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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