找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1313|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 U( O K5 u: |, `7 v1 k8 C5 B0 y5 V3 R* {' A4 p9 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 | 显示全部楼层
//********************************************************************** {  ?" Q% Q8 b8 W# I3 A9 E
//  ProgramCompare.java         Provided by: DRS
% o! v: R6 D9 e' S6 R* z//2 V+ ^. h4 H+ S  C5 y: k$ i/ Z
//  Program shell for Assignment 2- ?2 ~( H2 o* T8 x+ p3 z% H
//$ f% Q  O+ f5 G+ K3 K1 m
//  Compares two text files line by line" x+ }- }7 Y  J; B; T% D6 U9 Y2 p
//*********************************************************************
4 z$ H. U8 y  ^  \9 x/ S& x) v. o0 f# K
import java.io.*;
9 f1 ?; l8 }5 _4 n) R. C, E1 d
. p3 `4 T4 U# s4 Xpublic class ProgramCompare. c2 Y- m7 V6 G( Z  G
{* k1 q0 y/ G" H/ p# t
        //-----------------------------------------------------------------
7 O! Z6 D& v* G- t        // Constructor/ m4 p7 n  z  m" G
        //-----------------------------------------------------------------% @7 G) }' [( ]. ^0 N. w
        public ProgramCompare()& d2 D  m, j5 I) |2 E6 a1 v
        {
  k$ Q: x1 p7 _        }: |; N$ m- Q! u9 u4 G( K6 j

7 ~4 g+ c7 U: [* m' L* K        //-----------------------------------------------------------------
4 ]$ I+ q/ B) _% |  l" t        // Method for testing that class has been reached" r' H1 w: X- D( X! d8 l6 U2 ]
        //-----------------------------------------------------------------       
+ C/ s1 y% V% O) ], T5 t/ F
& f/ J: e; N0 N2 a        public boolean ProgramCompareReached()        
, V( L3 c" J& |        {
3 W3 q8 T+ r, C. ]$ S' W      try
7 Z" [4 y/ p9 W5 O   {         + _# L5 v* Y7 R: B1 X9 @- j
                        2 S3 i  }; q: ~0 c. h, f9 N# G  v
                //********************************************************************
/ c2 ]5 n0 T* r+ i6 n5 C                // Try-Catch Statement is used to handle exceptions - such as file not found * R9 o2 L4 P2 ~- d  ]; o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 F  a3 |* S0 j5 G& I% ?                // For more information see page 534 of the textbook& T8 W" g1 `  x" g  c
                //********************************************************************# n5 c# d& p6 n9 R
                     ) Z/ ?" m" Y: B- k' [4 L5 ]
        }
* Q+ ]0 E# g  }" b  H% P1 A             catch (Exception ex) // Exception caught here and message displayed to the screen 0 _6 b7 b( ~1 H+ ?' B
          {
: v$ D7 ~" F8 R                    ex.printStackTrace (System.err);
8 Q' W' w+ \: a  _; ^. k           System.out.println ("Error message goes here"); // Replace this error message with your own          ) o  J- t" E" {8 U
        }) d3 e1 z+ z+ V/ U: T' _
                return true;. q0 C: r+ u4 f: J6 v. Y' l6 v2 ?
        }6 Y0 V% e! B0 r" {9 P

+ |$ _! O# V4 I( ~4 E/ k+ }$ p/ y} // end of class ProgramCompare
( d$ g  o8 @$ T: y$ p2 H; ?9 R4 i2 a& o5 _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# r7 C  z: k: l2 P& k1 i+ _/ ~. s" }9 n//  ProgramCompareMenu.java    Provided by: DRS1 I2 m0 S# b/ a2 R% i( q
//
$ I3 ]6 |7 q7 J//  Calls AuthorisedUsers.java and ProgramCompare.java' ]* D$ s: `, H  B
//
% i$ i5 k) F" ?% D/ E9 X& ?//  Driver shell for Assignment 2.
) K6 Z% ?6 V8 k* g//********************************************************************6 K9 G  [! k: w
! }* `) X; A1 r' E$ y! ~  C
class ProgramCompareMenu4 k0 k# z4 L) J; J4 p% r
{7 {5 `# z9 }% O
    public static void main (String[] args)
! U  a7 z- c9 C8 e) d" m# J9 M/ n            {
+ R+ U. O) ]$ p7 r                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 h' k) C! D3 v+ S/ v5 \$ r0 B                ProgramCompare reached1 = new ProgramCompare(); 7 k. Q2 c5 ^, @/ J* t% [7 ]
                AuthorisedUsers reached2 = new AuthorisedUsers();        9 q% k, Z9 p1 H' n$ C
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 O# m" \0 x7 N; C                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ( P  u1 }' o* O. @
        }
# y0 l- \" ?7 p, v& r( b% n2 B}// end of class ProgramCompareMenu1 }+ L% \0 U+ o
' E) ~& g" }# S1 K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 g% s- i% {5 [  G# q, Q
//          AuthorisedUsers.java          Provided by: DRS% F# Q; M3 E5 X8 l# z
//                  h5 J7 N2 S7 U5 @, U/ M
//         Program shell for Assignment 2
8 t5 H9 A" l( x9 k& C//
3 e& A  e" y1 H5 v7 j  Z4 k//         Represents facts about an AuthorisedUser( w1 [& `* Y& Q/ n$ }: f
//********************************************************************
. \6 s! {* F. G0 e& r8 ]; r$ B5 t. p) _. z
public class AuthorisedUsers
$ @' L, r5 I, \/ ~' o) O2 o+ s    {& `' K  ^5 x$ f+ }* {. r; Y
4 {7 `* G4 q# `3 s, G0 d
        //-----------------------------------------------------------------: P; T4 B7 {" `; {# x; v
        // Constructor" [) e% O4 _5 ?  _- i- F; ]; H5 Z
        //-----------------------------------------------------------------
0 }1 g' l% ^; R. S/ F. U4 X2 g1 N( Z5 _$ c8 g2 m
        public AuthorisedUsers()! }5 D2 _% H; G6 u- M# l
                {9 A4 F  q, G6 \+ x: g# \2 ]
                }7 r6 V- J5 C# I* l" T2 z, a
; V+ Q3 a) k5 m) N/ j5 A1 p
        //-----------------------------------------------------------------
! e; B4 F8 j! r0 U        // Method for testing that class has been reached' ^! s6 a. P- ~0 b: y5 ]- ~
        //-----------------------------------------------------------------        6 z: D- A5 O% B7 S
        public boolean AuthorisedUsersReached()
1 }3 @  ]5 M5 g                {# I  Y- F% {9 v! S, T' T
                        return true;                        * P$ b) M0 N: j7 \3 m4 O
                }
; B* Y% k5 x* x7 ?               
. n# C0 {% W8 G* M7 Z  c* O0 F    } // end of class AuthorisedUsers8 [, |5 X7 I! I8 h0 A* V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% W1 C$ h4 L2 i# c# ^
Shanghai - 20072 p" K4 D% u6 O3 Z) r* ~
Assignment 2
1 A, N/ U8 c0 ^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)
5 R& `: i) j( v. |8 w1. 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.
* k' N/ W3 V* p! E' S, f: h& d, CThe staff must be able to:% B8 H# q. U8 Q  ]& H
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* L' \1 @5 ^5 R8 ?/ k" J
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.
  T' E0 w- Z2 Q5 ~& H$ S; N. p* ]$ { The interface should provide a menu so that the staff can:9 ?4 x3 H  y9 }! O# D4 i' S  \
a) Enter the names of the two Java program files to be compared
  X/ y6 R: V9 A! A& Q& k For this assignment, it will be assumed that the two Java program files are in the same folder as your program.9 |  X" q0 O* P! w9 v: ]
** 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).7 y; j: [8 W4 g+ w2 d
BSA104 Business Programming – 2007: Assignment 28 P2 Q1 ^- i) U4 M4 S# P
Page 2 of 51 t/ V0 c, E9 y" r0 @8 {
b) Print out to the screen all the lines of code that are the same
; U! s3 p1 V5 i: s/ Z Include the name of the file and the line number of the code being printed for each of the two files8 @3 f: Q: A6 I9 t8 [$ p
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared+ \  N' G: y/ M* X
 the name, username and department of the user
% \" @1 f) l6 G( n7 z9 b% n the statistics of the comparison
& u6 z+ A' ]7 F! l" s  `/ s- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: x, w+ Q3 @6 \8 @3 L% ]- D2 I
 the recommendation for further checking1 x) w3 E6 @1 v& j9 \
- 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
9 y6 w8 K8 [0 g, F- x7 B: C the names of the two files compared6 |! v0 S) Z( F2 D$ v) c
d) Leave the program (exit)
* s2 y: b( x, \The ProgramCompare class: (Total maximum 20 marks available)
# `1 D& X! n8 x# T2. 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)
& P4 }2 J& [  m, }" Z0 m( Ca) provide an error message if the files are not found or there is a problem opening them
# J5 Y; u) H& c% Vb) compare each line of code
, y8 q# d  B! ]/ t7 \# ?4 Rc) print out the lines that are the same
- s% ~; O% l7 F4 e% S8 Qd) count the number of lines compared / lines the same
$ u: Q- b; k# Q# c% fThe AuthorisedUsers class: (Total maximum 20 marks available)$ D( o9 T0 \& K' L" N6 _  Q
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)
7 _3 L( I/ Y2 H% n2 v: D4. Provide methods to:
. ~' b9 K! q1 _& Qa) 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
, g. H4 I% o  o7 Wb) return the name of the authorised user# T% h- x" y) o7 S( o/ b
c) return the name of the department of the authorised user
/ `( X' i5 w% M" V+ A1 ^Individual Data (Maximum 20 marks available)
3 N6 C( Y5 Z  @! }: S" s6 h5. 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.
" F7 n$ }7 \; @6 m! u; g2 vDocumentation (Maximum 10 marks available)( |' W8 ~; v+ I& D* z0 P
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.9 t" t+ s5 Y1 u
BSA104 Business Programming – 2007: Assignment 2
' ~, n, Q+ i: b7 @; i: {! hPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: x7 U0 h& {+ J( v
不过你要翻JAVA的类库说明。你有下载没有?
% O$ O  N( K1 V" Y4 H查询关于对比的函数。貌似关键字是contrast,还有compare: h/ N, a0 ]! i4 e: \# E
" U7 t% ^, R( V6 A) p4 @" K, m2 z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, M$ u4 x& i1 E8 {痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- u  N" K  m% K+ u可以下载到的 是 jdk-1_X_0-doc! v$ y$ Y+ D4 n+ u% x- a  B
8 D* M; Z: w9 [/ R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-25 22:53

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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