找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1244|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - e u# d* r6 W4 ~6 O* A* V- ]* h% t( f0 ~' ^- {1 l
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
5 P5 b/ s6 S  L! {5 Y# q/ l3 `//  ProgramCompare.java         Provided by: DRS- z. Z) O6 E8 Q6 B
//! T  s/ V4 U: k' Q9 g
//  Program shell for Assignment 2+ x( g" {4 ?/ e# ]9 E4 a
//, a1 |4 i; @* l' ~
//  Compares two text files line by line0 l# R* r0 t4 f- K- _; b7 {
//*********************************************************************
4 D1 Y+ W+ m1 D  ?2 s" h2 r7 g% c7 X- ?. d
import java.io.*;
3 V* V3 I1 W* R" H5 K; k" |7 v( {0 T& X$ u0 h
public class ProgramCompare
' ]) d3 ]$ X& r& {, g* L  o9 N{  R, b& S; ~1 ?6 J. b. X6 o2 G
        //-----------------------------------------------------------------1 _3 b5 i9 ]+ ?0 k/ E; B
        // Constructor; L; g; ?; A7 _1 c) e+ d
        //-----------------------------------------------------------------
' ?2 y' f2 d  Z) Q        public ProgramCompare()/ p" G4 A5 i2 t( W. ]& G2 R0 `- X
        {  D3 m7 z7 B4 x0 q# n  f- m
        }
& u+ H2 Y2 }6 }# K6 a" e3 e/ [, b
        //-----------------------------------------------------------------% W" c4 x' X: x: B  j" w3 {
        // Method for testing that class has been reached0 Y: |; ~* I% y# S! i
        //-----------------------------------------------------------------        ! X& J8 [9 }/ [6 n0 |' i, h" b

5 i- _, ]) ]0 E7 k0 q1 c        public boolean ProgramCompareReached()         2 j8 G; Z% S$ n8 Z
        {' E$ w& ]2 }" X% J2 Q' `: h
      try
& Z. s! t8 D8 g, Y5 _   {         7 \% P' F: W- l$ n
                       
9 F, K4 t, A+ s3 q- a( [                //********************************************************************
; b+ G8 a( i9 e; P& ?                // Try-Catch Statement is used to handle exceptions - such as file not found
  [+ W7 o, R& d  H: N* z) x8 X                // Reading the files will need to be placed inside a Try-Catch - just like this one!, O' l9 M4 q) \% y2 \0 X  @
                // For more information see page 534 of the textbook
* h8 o0 ?" b2 u3 g7 E                //********************************************************************8 M& {3 k9 }* @1 Z
                    
9 G7 w1 V$ `, ^4 y. a        }
% g" t  Q0 M+ S  z6 E* B( @& f! v             catch (Exception ex) // Exception caught here and message displayed to the screen 5 d1 d% h+ n  |4 O: _4 o# [
          {8 H3 a( Z9 k( C" E
                    ex.printStackTrace (System.err);3 {% N+ d" H/ P& A8 R& C) v
           System.out.println ("Error message goes here"); // Replace this error message with your own         
/ Y5 ~; P5 F+ O        }
7 }! X9 Y3 O$ b2 ~9 ?                return true;
( V& X3 Q0 r# l( J* g2 K2 b6 Y        }
. V0 R  d# Z) Y3 l7 I( h2 w( b9 `3 |* R
} // end of class ProgramCompare
# b& G0 w) w0 S" z
3 l) l' Y' m0 i# R& P7 f- p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
: }, B8 P, u& K9 C//  ProgramCompareMenu.java    Provided by: DRS9 M8 F, t8 e; [
//
2 r. Z$ |% Y) g# P& V+ j//  Calls AuthorisedUsers.java and ProgramCompare.java; Q7 f; w" \( b5 x( o* m3 b3 U
//  q3 D6 G  b, L3 ]/ c. z% b$ ?
//  Driver shell for Assignment 2.  M9 z4 a0 ^, |
//********************************************************************0 c" p3 u; H& _/ D9 Z; x

2 n" R* o9 K6 \. D, Q. \0 eclass ProgramCompareMenu
' R# j7 a1 v+ Y6 R3 [% G: C& g9 g, z{
$ X2 k2 a& `3 @$ w0 K    public static void main (String[] args)) G1 M2 k! e/ f3 N/ G  [
            {+ f" L# Y! M0 Q- _$ l; v' m3 r  l% F
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 Z% h' D. G( v                ProgramCompare reached1 = new ProgramCompare();
& C5 p7 W4 z2 ]' i                AuthorisedUsers reached2 = new AuthorisedUsers();        8 `( h1 I& K- g+ Y& k
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
+ z$ F) a4 |/ p% i4 M3 t                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) u- Z- c0 P% u5 r% r        }
/ g  c% M* y% e  M) j}// end of class ProgramCompareMenu' {3 L8 p, K9 c. ~

; q, e4 }( l* a8 e" ~$ l0 X# t; W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' Z+ O% b' S4 W
//          AuthorisedUsers.java          Provided by: DRS% i. Q1 ]; b' Y& [
//                2 o, D+ @2 B. v3 V9 W8 k8 h- D
//         Program shell for Assignment 2+ ^$ L% L4 H, R* x& w
//
0 E) `( ?- H  ]0 a' e+ C//         Represents facts about an AuthorisedUser, q, ^: N$ |1 F! p- y( F
//********************************************************************
0 A$ B  s7 {7 k# [( v9 s, N
; T" U4 q: ]; n- A3 a- Z7 Ipublic class AuthorisedUsers& P4 @6 }' y$ ^. R: T
    {
" U, e1 j! f2 H" ~  o/ N3 }
2 A6 m/ _. L8 d( C8 x: B        //-----------------------------------------------------------------
: S- o7 ~( s6 [! A" S" E' Q# E        // Constructor
/ G. O& _4 g( m+ w$ w        //-----------------------------------------------------------------) M( J2 _* d( \2 M/ I

2 e$ t; C4 |! {4 Q7 z! S        public AuthorisedUsers()
  ^2 {& Y7 u( L6 G( u                {
* Q! f4 U. G8 Y8 Z& ?3 I. f                }
# N) i7 O# a3 K$ A/ B. I6 U" T" G, o( e+ i. G& C
        //-----------------------------------------------------------------0 K; J- c2 i0 s$ |" {
        // Method for testing that class has been reached7 p3 K/ a" }4 Y2 Q) @) S; ?% ^
        //-----------------------------------------------------------------        - z) A6 C  B/ v0 N3 T5 l
        public boolean AuthorisedUsersReached(); M# F8 e4 H1 Z: g1 Y& ~- Q7 ?
                {
9 s. u. m1 U; ^- l# L                        return true;                       
4 p7 e, x! F) t$ p                }4 T! Q4 Q) U) ]/ _7 ~+ ]1 M
                ! c+ R/ s( H! o7 C2 O# ]; G6 Q
    } // end of class AuthorisedUsers( E3 {5 A  Q2 `7 W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming& T4 F3 a5 w# a1 s, W
Shanghai - 2007) s0 b( Y, w$ v8 }" h  F# J
Assignment 2
. f1 ]1 i1 A5 D3 r, \2 x4 Y6 kDeadline 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). H* `+ [/ ~, J* u, E" @! n! f
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.
& N4 s9 v; g5 k: ^( kThe staff must be able to:
6 d9 W! I2 d8 `* P. P8 o Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 \: D8 j/ P& e9 \% z, {9 N1. 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.
; L5 c; q. l$ y5 o' X- @ The interface should provide a menu so that the staff can:, U( x# W* X- r
a) Enter the names of the two Java program files to be compared
2 S# \( r8 V$ \; T# X& o For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# Y8 s, b; G" Y% Q- u, k. M  q# x/ P** 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).' h& |6 A0 b# E$ Y3 a
BSA104 Business Programming – 2007: Assignment 2* Q: J+ j! w. m4 Z
Page 2 of 5* Z8 ~# a" w+ o: p
b) Print out to the screen all the lines of code that are the same+ h7 F5 u% b9 B% e9 ?
 Include the name of the file and the line number of the code being printed for each of the two files
! V& z4 ?3 h, ]8 M0 _  v9 Ic) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 x- C! P2 i! s% \ the name, username and department of the user) M. P2 [6 a' D: n
 the statistics of the comparison
: c2 p/ G# v9 R9 [7 z  _- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# O. v$ M# C) [3 M5 k5 t( I, N) q  R
 the recommendation for further checking6 M' Z, F% `  g
- 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
+ r" N5 a5 \: O the names of the two files compared
- k1 Y+ v; S7 j& C0 u" Hd) Leave the program (exit)
: `1 `1 e! {: }5 n0 Y8 IThe ProgramCompare class: (Total maximum 20 marks available)# f; n# [" U. l! R9 g, q
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)( \: b1 d) }  T$ a; `# ~0 j/ L
a) provide an error message if the files are not found or there is a problem opening them2 f) _7 e+ Y2 J( i, F8 d, c* P  h
b) compare each line of code
- ^2 O9 g) W" A1 P) kc) print out the lines that are the same% b6 B4 z6 ]4 t8 t6 Q4 k! i/ S* ~9 P
d) count the number of lines compared / lines the same  E0 G6 S! v" t8 D3 b# q6 |# C
The AuthorisedUsers class: (Total maximum 20 marks available)) d# W/ d6 u' c, s
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)
2 Z% H( d) r/ M0 z4. Provide methods to:" l* N( Q5 }- i' x  A; {3 T+ w
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 match1 b6 L: U  r5 H8 }4 |
b) return the name of the authorised user! p0 {! o) c& J9 k8 B
c) return the name of the department of the authorised user- b# `5 V; M& V( W
Individual Data (Maximum 20 marks available)1 v6 R/ g$ q4 d3 g5 g+ a# E
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.
8 N+ Q) C/ M( V+ xDocumentation (Maximum 10 marks available)
) P* Q( T  X6 Z' x# l6. 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 G& l: B9 B  a7 k
BSA104 Business Programming – 2007: Assignment 2; c( G+ ?9 X& }6 r
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! [% x& H4 }& ]不过你要翻JAVA的类库说明。你有下载没有?
: A" ]7 c7 G, Q* S. A查询关于对比的函数。貌似关键字是contrast,还有compare, i! }1 P3 H/ o& K: {% D2 w6 w

  U; C. t2 B1 e( F9 I; Q- L) f; a; Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& y: O+ g* f# ]: p( C$ j- a  M1 X
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 |+ K0 Y0 ?; z3 w% r4 G  e
可以下载到的 是 jdk-1_X_0-doc
. F: z* N6 v; v8 \+ e9 N: H$ F6 n$ p, ]3 P  S: e/ X
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-1 13:11

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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