找回密码
 注册

QQ登录

只需一步,快速开始

查看: 926|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! w$ A N, Z2 n" c 6 F& N2 L4 O' ?3 K
回复

使用道具 举报

 楼主| 发表于 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 r* U/ P8 N1 k
//  ProgramCompare.java         Provided by: DRS' k# u! A' N# m! s
//
+ X, f" ~3 A1 f, M2 A8 l//  Program shell for Assignment 2& j7 V3 H% s% e8 a% e
//
3 r3 {4 w3 L2 }7 s* |7 ^//  Compares two text files line by line; M5 I5 f+ a: [' t
//*********************************************************************- H1 r: Z( Q3 S* N

; L( W0 M2 b, n) Zimport java.io.*;
) m+ e& A' _1 U9 o4 U/ i( h) N, F1 l# V  ?% r
public class ProgramCompare8 K+ B/ ^" Y9 Z; [4 ?! r- {6 I) i8 j
{
- y' }, w* z( ]/ u2 i) i3 p        //-----------------------------------------------------------------
' h! K( ?4 @3 f/ C        // Constructor+ n; L- D1 O1 o4 d, @. O1 v
        //-----------------------------------------------------------------
" P. w: s. a, L& l        public ProgramCompare()6 W' F& }; F0 F$ w, W/ @
        {
# y$ i% Z6 ~7 o3 s: w7 s1 C( e        }5 V6 L5 c, s; e. A) V& X
: r$ a7 ?* n1 o8 C; C6 Q( O* |
        //-----------------------------------------------------------------3 q+ K% @( l; A( g) C
        // Method for testing that class has been reached
" R" J7 B7 O" Z2 [        //-----------------------------------------------------------------       
8 g, S* x6 N2 w. O6 M; G3 B- i) E8 v/ Q% G1 v5 d
        public boolean ProgramCompareReached()         ' c+ _- z" M1 [1 q' u2 m
        {
* Z& ~& M2 ~. L( f5 T/ A& b2 j      try , W% F/ c& \$ u1 n/ A
   {        
7 r# `5 \+ l2 h& o0 O                        9 ]4 K: ?! e% ~, Q. R
                //********************************************************************
! L7 n9 K4 l! ]9 [4 M: T7 k, F                // Try-Catch Statement is used to handle exceptions - such as file not found ) }8 r) R. n9 v8 ~! ^
                // Reading the files will need to be placed inside a Try-Catch - just like this one!, ]+ X3 \5 `! E
                // For more information see page 534 of the textbook, F7 B5 ]+ S& V2 ]! p: b
                //********************************************************************
/ i, Q7 v/ I$ G4 ]5 c+ u                    
0 w9 h1 y) L) B8 I        }
2 D2 _/ v/ W" d. [1 N3 R             catch (Exception ex) // Exception caught here and message displayed to the screen
" {  D+ q6 c4 B/ S# ~5 r          {
5 }9 b9 I" q/ R                    ex.printStackTrace (System.err);2 ]( L. j+ q$ B8 p3 T: M$ E
           System.out.println ("Error message goes here"); // Replace this error message with your own          3 O" g7 w" d* r; U0 w: F
        }
8 j0 v' c  j9 O# a' C: k. E                return true;
0 v- f3 L; t+ h! p! O- J: T; O        }
" Y9 ~+ G# v; J9 _( p0 D
2 e; {$ M0 G5 F4 G( }) ]} // end of class ProgramCompare- }& v$ n3 I( }- c6 m: K* ^
5 {# l9 R3 z+ ?" z4 y9 c4 j/ q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 S) y6 H3 i, y# G6 \
//  ProgramCompareMenu.java    Provided by: DRS& W# @  ~& g3 ?! o! G1 }
//
. V7 s1 O% L$ N+ I//  Calls AuthorisedUsers.java and ProgramCompare.java
1 C# J5 V" r' K) U2 a" T1 m//" ^* c5 |- ~- S0 j6 G. L. w
//  Driver shell for Assignment 2.& Z9 D) s  b+ }: g. ^& U
//********************************************************************: N2 G  s% a' C6 H3 h& a1 t4 w8 s

3 s' w: |5 L" N5 E' u" M7 f1 P, `6 Nclass ProgramCompareMenu1 m2 N% L1 N/ y5 \& R
{1 V3 |( D% J/ A  [" q/ I
    public static void main (String[] args): I1 a' S3 @/ U. W0 Q( n
            {- c$ x2 m# `3 g  ^2 K
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 z2 j1 U" x2 ^! O0 X' }6 U9 l+ D                ProgramCompare reached1 = new ProgramCompare();   o& F) l! K: t' I# @' ^
                AuthorisedUsers reached2 = new AuthorisedUsers();        / c/ C2 s$ B; O
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());! A) H0 b, l4 V8 l" t8 h
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & F; _0 V3 l% i: \4 Z. Z8 y
        }
/ ^- i( j8 W5 N: J: t* U/ F}// end of class ProgramCompareMenu
0 P% d/ l# j8 }' o9 }; X- k: f1 v3 V' D7 A, J$ j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# y/ |; z' O; d1 e//          AuthorisedUsers.java          Provided by: DRS& T4 w8 _* @/ R" g4 {
//                3 I$ ~, g' P. t. ^& c0 h
//         Program shell for Assignment 2$ z) M, w# [* D9 {
//' a6 P" N7 G8 `
//         Represents facts about an AuthorisedUser7 ?% n4 M2 Q/ p8 M. G& J
//********************************************************************0 d5 Y; K3 o6 L, |1 Q, H. u

1 l( Y3 u; F4 o6 l* ]) f2 c& b9 Epublic class AuthorisedUsers
  d- s/ r6 q* q4 E: h! }    {
: r5 |4 N" n2 d( V/ @) ]! y2 C$ e. m2 X9 J7 B8 R
        //-----------------------------------------------------------------6 t2 L3 l6 _# _  m  K3 X, n/ j
        // Constructor# l' n9 l6 {- S0 u2 X
        //-----------------------------------------------------------------
' i6 z6 u! o  i+ U/ G6 u0 A1 E& m- j/ S* C( R; ?
        public AuthorisedUsers()
. e* ~* G/ ^3 p  a% H7 G) S                {. ~, A* s. ]% e8 r0 R0 x8 O
                }9 M5 M6 R% Z1 Q

8 O5 `2 M# D. C1 N  P# s        //-----------------------------------------------------------------; T" Z+ g7 R9 s, k
        // Method for testing that class has been reached) B( X: F" Y$ X; f5 _
        //-----------------------------------------------------------------       
4 D; T% N* c2 B, g, ^        public boolean AuthorisedUsersReached()" p/ X/ y0 \" c/ v5 m* P6 v
                {
- F# u; P& i7 F( A2 t5 X4 A                        return true;                       
+ x7 G* U3 S2 q) h3 x! x                }
8 N) G5 e5 ~) f. [3 w+ Q8 d! N               
; I1 C1 g0 V$ n5 |* c. v    } // end of class AuthorisedUsers
1 X$ D  m/ B2 L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 F2 w8 I8 F! z# v9 `8 r# V! X- X
Shanghai - 2007! y$ S, x. h/ x" n( s- h) X
Assignment 2- U. t, D/ p3 j9 e6 V4 z- `- t$ ?
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)
" T1 a2 e5 O; E' L1. 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.
7 H- B% q6 E7 ]: GThe staff must be able to:
' I9 a  Y" l" K- C Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# F, \0 |# u$ W
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.& s% p, T! B& R
 The interface should provide a menu so that the staff can:% F- p' v# d, }2 b$ t7 d
a) Enter the names of the two Java program files to be compared/ e2 e5 ]) k/ ?% b7 n& z+ H
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 H! k5 c3 Z+ r6 M** 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).
) ]9 u' n7 n8 x- O% pBSA104 Business Programming – 2007: Assignment 28 x( Z& [( P2 _! E' M
Page 2 of 5
! R6 C. v" t) o5 bb) Print out to the screen all the lines of code that are the same
1 K0 @' B4 W  `* P Include the name of the file and the line number of the code being printed for each of the two files
4 I: w, ~8 l% r# E0 E: p0 Y0 j) i+ `c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 [, }3 f( Y8 S9 M2 g* ^3 m the name, username and department of the user8 B  I# f$ Z5 _- |; ^
 the statistics of the comparison
3 R: d  Q2 X' f4 L  y# N- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different7 i! f6 T6 L- L& L5 q9 W5 l
 the recommendation for further checking: n: [; y# Q" l; q! l
- 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
) X/ R" d) k/ m) r( ` the names of the two files compared% e$ X, R- I: ~7 ^
d) Leave the program (exit)
/ w1 ]- W0 D. P+ E4 X9 |4 m1 MThe ProgramCompare class: (Total maximum 20 marks available)9 P) s% ?! a8 |0 f
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)  l* @. d# ~, p7 e1 N( P
a) provide an error message if the files are not found or there is a problem opening them
- u+ E* ?8 R" N6 ?2 N8 `! tb) compare each line of code  r9 {5 g. s2 E* O+ O
c) print out the lines that are the same
# D% q8 \0 U9 i. gd) count the number of lines compared / lines the same+ i3 a- g% T  G7 \$ J' M0 k
The AuthorisedUsers class: (Total maximum 20 marks available)
. t2 [8 W& |- I3. 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 I% b8 \+ p5 u; V
4. Provide methods to:
6 x  F8 ?8 }- ta) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match3 E$ p" K+ P$ o! U* f1 X( ]
b) return the name of the authorised user
% J' q$ k& M* u* B6 Rc) return the name of the department of the authorised user
' s3 }$ p- d5 _2 tIndividual Data (Maximum 20 marks available)
3 v' A0 ]# E7 W5. 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.
* J4 M0 ]+ l1 K5 sDocumentation (Maximum 10 marks available)
$ S5 I5 Y! o5 @$ b6. 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./ t9 }4 @6 y) H9 }, o
BSA104 Business Programming – 2007: Assignment 2
6 U5 t9 r% ?3 b4 U% kPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 }) |9 q# R/ q2 E不过你要翻JAVA的类库说明。你有下载没有?
7 g9 d" J1 Y$ d& g6 l查询关于对比的函数。貌似关键字是contrast,还有compare7 g: G( W1 P3 n: g* W
' L" E2 U) `7 K/ Q: K7 ^0 Q) j& k, e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 U( \& q$ M8 L' N痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' K; E8 Z9 \3 w; C1 E% c
可以下载到的 是 jdk-1_X_0-doc0 t6 X- o( n* h; z& S, L1 V
% Q) y9 e, A* w  S2 v0 n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-1 23:38

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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