找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1576|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 W- u2 r2 z7 m$ m: K) j }0 a* [8 v( q0 E; ^ m: I
回复

使用道具 举报

 楼主| 发表于 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 Z2 g+ I$ q$ j
//  ProgramCompare.java         Provided by: DRS$ q5 J/ h6 F: B2 ?- _
//- P, B( I0 M# l6 ^2 w( A$ I! n# X
//  Program shell for Assignment 2
( w, z, x! ?7 j% K8 a//
$ \* i8 v' j. W+ M//  Compares two text files line by line8 @' c4 H. m( O  Z
//*********************************************************************
5 O7 I, T) i0 Q' S! }% p4 S: t; B
: x1 ]; K2 B& y5 z0 i$ |% q2 kimport java.io.*;
" v& F) w5 i1 B& x# W# V+ m% J4 h) q! |, `5 o$ r
public class ProgramCompare
5 V( a7 u" j7 h) C{
. f" W; _) f" K* v1 Z. C/ l        //-----------------------------------------------------------------
0 U1 ^' J) B" [: D4 ?7 e$ A) `        // Constructor
! \+ w* Q8 h8 I        //-----------------------------------------------------------------
/ f% a1 |! V) M$ \! c5 a- P. L        public ProgramCompare()
$ m+ K. I4 W  y& d  D& p        {: i/ ^8 Z, e! N
        }
5 p# m9 J& Q2 I# l$ P
6 D, ?4 w* `* L6 \$ D' c( Z, y0 {        //-----------------------------------------------------------------; ?2 F/ h; g9 o0 F1 S+ Q! p2 H
        // Method for testing that class has been reached- v3 R; p$ W( l; B
        //-----------------------------------------------------------------       
# j* c' J# ~: y$ G, B6 u1 C/ C0 r0 R$ n
        public boolean ProgramCompareReached()         3 L  `7 S" S7 _
        {
! v. q/ B' Y, r: Y      try 5 r" |/ i% n5 d% V
   {         2 b! X5 O# ]: n% Q
                       
5 g+ L1 `* b& ^- `* s4 j                //********************************************************************
, [; X& _) Y2 T2 K                // Try-Catch Statement is used to handle exceptions - such as file not found
: A  }8 [! k4 Z- p& H" ^                // Reading the files will need to be placed inside a Try-Catch - just like this one!* G  Y$ W! q- z9 @7 V
                // For more information see page 534 of the textbook
: e8 C0 p  v/ S                //********************************************************************
/ T7 e( s- m. E; y                     ! o9 Z8 p/ H5 Q/ Y( C9 q
        }* p% Q1 ?, L! l. P: ^0 r
             catch (Exception ex) // Exception caught here and message displayed to the screen - H+ S  Y% b1 Y# S
          {
3 s' f# n7 _, |% H  n& a, g. l                    ex.printStackTrace (System.err);
& W- I$ |% G8 L' J. a7 T( F           System.out.println ("Error message goes here"); // Replace this error message with your own          6 Q) n0 W  S7 x% |- i/ Z% y
        }
3 I5 q+ W: s/ k( Q; T( T! \$ a3 I                return true;+ _: y: m, e7 H# j! g. B8 I
        }
6 c$ W, N' D6 d5 g& M* k
; M; g9 s: d3 p$ u- U} // end of class ProgramCompare' l* T1 H* }1 Z

* c, J- P$ v3 u, k; L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
0 h5 Q$ T8 Y* d0 m/ F  _3 p//  ProgramCompareMenu.java    Provided by: DRS; V* r! r9 ?6 J
//. J' }  U) u5 E$ v
//  Calls AuthorisedUsers.java and ProgramCompare.java
6 G# p% _. _9 V( J  d" p. \. {//! x+ {. K9 X7 f: ]( l3 n$ v
//  Driver shell for Assignment 2.
4 X! q' \/ G7 E0 n+ S//********************************************************************( f& r' f! G5 b; D' X% N# B
$ M% h' ^" x% z) |+ w) v5 ?9 ]
class ProgramCompareMenu
& d5 \/ b& }6 Q1 s! S{  d9 S% {( j- P* f+ Q7 x6 ?
    public static void main (String[] args)
1 [5 M2 {  m4 F( \            {* [4 o/ o( }! f/ R
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. l( F8 M" L& \: c                ProgramCompare reached1 = new ProgramCompare();
% `: |  J0 f5 K# R6 M2 f5 W3 t                AuthorisedUsers reached2 = new AuthorisedUsers();        5 u/ e: A0 L: Q/ J
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) ^  m9 ^" f2 E/ Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ! @" n( `" r/ [# m8 ]" J
        }  H: O! `) t/ m( J0 H
}// end of class ProgramCompareMenu0 g) ?: m3 A4 u/ e& c# A9 k8 ]

/ N" X2 R# w8 ^$ @2 \: ?# t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ P$ c3 O4 q6 v5 c( l//          AuthorisedUsers.java          Provided by: DRS
1 J; H: i$ P! ]: k9 N1 Y//                7 h$ ]% S  q9 F
//         Program shell for Assignment 2$ }6 {. L" D2 d6 a# E0 s
//
  ?+ u& H# i, a/ \5 u4 W$ Y" g  C  P//         Represents facts about an AuthorisedUser" K& C& m4 D# u& E  F+ S" g. I$ z
//********************************************************************
- Y/ S. m4 N, \  z, S
- @  o$ _* {3 `+ M3 Qpublic class AuthorisedUsers
* m, Y3 u2 W2 R8 J6 k* g: m    {& a7 p+ U2 Y& y+ C  k
- J: h8 B1 M; a  u
        //-----------------------------------------------------------------' I+ _6 v. ^3 @
        // Constructor
  |5 L, l3 B3 f9 J" y" {        //-----------------------------------------------------------------1 k' E8 Z: v" O0 d- c

( {8 b/ i8 c! m8 p3 z4 U9 J        public AuthorisedUsers()' m% N7 }6 _6 L
                {
; t$ C3 q% d! ~5 E. ]% S                }* y# ]1 B0 M) U  Z8 h" f4 ~+ w
( H! X5 B! q5 `6 O8 p: k/ v
        //-----------------------------------------------------------------4 G# \, _$ _& Q/ I) S2 ^% u3 n
        // Method for testing that class has been reached
, ]. ~7 W0 z6 L: h/ T, d        //-----------------------------------------------------------------       
  m$ W( a/ f5 j- ~  @. ]' q! h( B        public boolean AuthorisedUsersReached()
+ r5 M* u( l; b$ I" w9 {; u                {
( X2 \, P( [3 v  {* W  o0 a* Z                        return true;                        1 P0 m( q* T; g/ Q0 j6 c
                }
/ m, i- c' A  U7 T               
, c. q8 v( L1 o( b8 R3 y    } // end of class AuthorisedUsers3 g$ b8 N' g$ b7 J" N/ E0 G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 E7 ?0 l5 K* S0 mShanghai - 20079 q! ?9 M$ a' ?4 x2 q7 }- P1 f9 s
Assignment 2) \% j$ e  K% k5 x( _/ o1 A
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)2 v/ b9 B" |* o" s- f* ]5 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.1 r- V4 R( h) L' ]0 g7 D9 F
The staff must be able to:& t; T7 R5 T! N1 R, r/ t1 @( R
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
. a! J; D; ?) b$ I4 T* f1. 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.
+ Q" H6 D3 P5 F+ s9 |2 F The interface should provide a menu so that the staff can:/ U4 l2 B8 i+ z5 O- u: l
a) Enter the names of the two Java program files to be compared
! V: n/ C) Q' ~9 I For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 r( O' J5 e3 H7 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).) z$ {) N0 y& S3 b# X
BSA104 Business Programming – 2007: Assignment 2
7 D1 \$ W- h& z7 c2 C" o0 ePage 2 of 55 e7 _  l" R$ P
b) Print out to the screen all the lines of code that are the same
8 D' t/ J$ J5 b8 G  u4 t Include the name of the file and the line number of the code being printed for each of the two files
8 v2 a( Z0 B+ Bc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# }. z7 ]8 k) P$ ^5 H# e
 the name, username and department of the user
6 ~: \4 ]: p2 P2 ?3 O9 _- [ the statistics of the comparison
9 y3 c$ ?, W1 X; s+ ?# J- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% Y% x- |: C4 S4 Q. g
 the recommendation for further checking
8 U4 K, x, ?3 X1 D2 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
% `% ]1 y) {; b( I% c1 [/ o7 M9 Q the names of the two files compared9 ~# x: d# L  m0 G3 Q
d) Leave the program (exit)
3 g: p2 M$ Y, x8 x/ SThe ProgramCompare class: (Total maximum 20 marks available)
& p8 n3 T5 C1 F2 f3 s1 |. L2. 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)
" b  j4 B! r9 g5 k; {a) provide an error message if the files are not found or there is a problem opening them
9 C) p+ W' w3 r! F8 z+ ~b) compare each line of code
- W4 }1 D, `0 g% G* U$ r: A2 L" @c) print out the lines that are the same
3 L( E# r1 ]* l! {% [  Td) count the number of lines compared / lines the same7 h6 }# i' }' L% B5 u
The AuthorisedUsers class: (Total maximum 20 marks available)
  w0 u3 }  ?& |( y' O4 K1 L3. 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)
' Z  T7 L9 [0 d) o4. Provide methods to:; G6 p9 e& B2 @' W# E  _$ p% W; F
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
: t" C, L9 A2 u7 ob) return the name of the authorised user
% @  G7 c/ N; Nc) return the name of the department of the authorised user
& n  q+ p% a0 ]3 FIndividual Data (Maximum 20 marks available)
$ v! ?5 N, \3 m5. 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.9 _* F! ]% \1 }
Documentation (Maximum 10 marks available)  g* ~( {3 k* M9 G1 R1 D
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.3 |+ q+ B; T  x% h' h
BSA104 Business Programming – 2007: Assignment 2- Q6 {; Z2 W7 W* W" [
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ N# P7 I  d- B) K- t
不过你要翻JAVA的类库说明。你有下载没有?  a* C1 Y) e$ h  e
查询关于对比的函数。貌似关键字是contrast,还有compare# r$ f* F* ~2 ~% J

$ Y6 F1 F( k7 v/ I[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 q# {5 x8 q$ `3 \: B( a1 F痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 V( [7 P, ^2 t9 k可以下载到的 是 jdk-1_X_0-doc
  J: E- C& v9 E% }! o" p% f! M: @/ A# X; K- Q8 r
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-25 13:40

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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