找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1635|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 , ]! t* U/ m; Q5 z( }& @: y 8 V1 O9 _4 T4 }7 D
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' j& P  E& i- j6 V1 [4 F
//  ProgramCompare.java         Provided by: DRS1 ^, M- w: F) u! J9 U
//
' Y  M3 D7 ^: r//  Program shell for Assignment 2
6 q- C5 |" j/ L' z+ K, q: a//
# @8 j0 R5 i. o( b- Y//  Compares two text files line by line
) t( [$ @3 q# h: p$ a- {2 R( f- ?//*********************************************************************# U6 r9 n3 x. ~9 j: @/ t. ?
$ q# d7 Q" _4 v' v$ M1 G
import java.io.*;
' }! F# [4 p" u6 E6 U1 Y, x. A/ R- E* I
public class ProgramCompare, V% }# c+ T- [6 j% Y
{
2 T% X/ ^3 T' _/ B' b& g8 h        //-----------------------------------------------------------------
  ^" M- h0 H; O) G/ n        // Constructor
. [! u5 J9 s; ]# H3 j- q& ^        //-----------------------------------------------------------------" e" N3 @# D9 s4 a% ~: P
        public ProgramCompare()) ?" z1 ^7 q1 o
        {
6 W6 t) ~* m: t- r& M        }0 [1 [6 s) u2 @! I

8 a' `7 Q/ K- k* O$ K4 G- Q" o- |        //-----------------------------------------------------------------1 i' k* N. j/ m
        // Method for testing that class has been reached9 `$ ]+ d  p# L& X
        //-----------------------------------------------------------------        1 V; A! U3 X$ o1 f' q+ A) C
7 `2 i  T* _( P0 t' S5 G4 X- K4 @
        public boolean ProgramCompareReached()        
5 w& [2 S5 ?# A3 O. ^' o1 n: z: h        {
; i, P( r" I2 c5 @      try
) _9 h5 c7 v0 y( t; m   {        
+ P8 G0 c% J* O# F8 M$ N* M                        ( s7 Z. l4 B7 d6 i
                //********************************************************************. N5 J' U, a8 E
                // Try-Catch Statement is used to handle exceptions - such as file not found
% s/ \- {+ x6 l2 `) a) k                // Reading the files will need to be placed inside a Try-Catch - just like this one!, b5 v8 ]1 ^( G9 m- B% q
                // For more information see page 534 of the textbook
8 }! ]- B% w6 C# Y                //********************************************************************
- x: \1 O% d/ h+ v# Q* e& g" y                    
9 i% C8 \% `  \* }9 E- f        }! O8 B  y; ?4 @2 a+ [2 a) G' L
             catch (Exception ex) // Exception caught here and message displayed to the screen
) v5 l; n' p1 i          {
0 u" w7 `8 h- Y' d' r7 C                    ex.printStackTrace (System.err);
/ O- u/ R  [0 s' h' }& ?           System.out.println ("Error message goes here"); // Replace this error message with your own          9 k* `" D. S, V6 f
        }
4 E# s  m0 E5 Y0 c1 G                return true;" `8 |' h( b  H- y9 u
        }
1 P7 X! A( b6 K0 J8 [
9 t, n+ }* |' @1 B& E} // end of class ProgramCompare/ U, x, U2 W. U; i9 C6 `6 K

- T! J* D. r, I* ~: g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- x. p8 ~6 B  o
//  ProgramCompareMenu.java    Provided by: DRS5 c2 w* ^, V% I
//
0 C" |! L& D" R//  Calls AuthorisedUsers.java and ProgramCompare.java
) [9 U; C# M5 l- t. a//" v7 U- T9 E; w( S- ^$ E
//  Driver shell for Assignment 2.. A7 ^9 f, _2 |
//********************************************************************
# a  j9 a1 q5 x5 _0 H
1 V2 O$ d3 m3 i" n0 tclass ProgramCompareMenu
, Y2 p' f- S4 P3 O+ U8 |* R( e{
6 c5 Q, J, O+ V" f0 N    public static void main (String[] args)/ O0 t6 t; w( T6 Z( L* L1 L" J
            {# H8 f0 S; Y4 v' z  D; I5 _
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 U  y& Z1 ]1 x6 k. t                ProgramCompare reached1 = new ProgramCompare();
0 N) H5 |: h+ |1 T" A, H2 b4 b                AuthorisedUsers reached2 = new AuthorisedUsers();        # z) M  R+ i5 \$ g% z5 [
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# Z3 G& b) W& [7 k; M' e                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
2 t! ?; L1 b. U" v        }
( O$ [5 Q2 S" P, w: K1 Z$ a( _}// end of class ProgramCompareMenu9 f6 p- v8 i1 n# P

2 l" x; h/ l9 j! c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) q, r: E+ N7 D7 l+ Q
//          AuthorisedUsers.java          Provided by: DRS# M+ @, W/ J' z* O
//               
6 K" j$ ?- f  W2 r& X//         Program shell for Assignment 2
* v, F7 z# x, F* u0 f5 z6 i7 N+ }& }//
( N0 k7 e% K- h5 E/ k//         Represents facts about an AuthorisedUser
$ C" W) K8 t$ b, v6 u, `//********************************************************************
1 E+ b# T" B- p8 v+ y/ j8 h/ O* s! h+ Q0 v% \$ }1 l! U. _. J" N8 _9 C8 c
public class AuthorisedUsers
& o! [; Y3 n1 `* H    {
/ M# ?1 ~' B) R" [) j* U. H; F& w0 v' i2 Q$ \
        //-----------------------------------------------------------------% T# \7 r0 b9 C3 N2 f# V' e. l) X
        // Constructor
1 G! w' }7 h7 x2 Y; k        //-----------------------------------------------------------------
2 m5 c1 o6 q! r# q' P+ J7 ]7 f; |: k
        public AuthorisedUsers()
% i: Q3 T9 _$ e* ~                {
$ Y' K, B0 J& S( O$ c                }8 ?: D6 ~) B. i9 `

9 A* i+ V) y: F; C1 C& N        //-----------------------------------------------------------------0 N( ?2 |# k( p
        // Method for testing that class has been reached5 p% \' a2 ?9 A5 p
        //-----------------------------------------------------------------        # y) i) |% N6 n: m- w5 U
        public boolean AuthorisedUsersReached(): c) W0 z- }4 S2 |
                {2 n) D; ?) i9 J% o
                        return true;                        ; h% v3 L: }9 I; y  N
                }
% |) n0 G% e5 L, Z/ B                % P5 b' H1 [6 p& ^: ^5 W+ z8 ~' j
    } // end of class AuthorisedUsers6 C/ J, F4 \6 C9 t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, W- S# n  ?% K; P) F( F" o' x; F/ l3 G
Shanghai - 2007
$ Q( i& t7 X0 ~2 o% ]: CAssignment 23 E* X8 K$ E; `# D/ a; q3 k$ l+ P
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)
' P7 H0 U; M2 v1. 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.
( n9 L) }" o: x6 ]  H" ~The staff must be able to:# q# J4 H% J, b$ j
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
- b% s! ?6 {! [( 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.
) `/ r+ U; k1 A$ K  n( F; ^ The interface should provide a menu so that the staff can:
) J) Q! }- _" @$ M7 a1 xa) Enter the names of the two Java program files to be compared
4 _0 Y% o  T! `# b/ T0 T! W For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ e# {0 D/ D0 u$ m1 G0 i) E** 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)./ I. k6 h) M6 }3 k) V; G
BSA104 Business Programming – 2007: Assignment 2
2 g- B! Y, k" y, p8 LPage 2 of 5' z2 `3 k" s" Z  D
b) Print out to the screen all the lines of code that are the same
" H2 I! t/ K0 L1 n4 M Include the name of the file and the line number of the code being printed for each of the two files
/ Q5 J* q" }2 F4 Zc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) \. P* F2 o( X
 the name, username and department of the user
1 z% y! c* {; o* [! L. h0 r the statistics of the comparison
& b( i( a$ t1 E  \0 ^8 ^/ |- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& v: F) u- b# r8 V8 w7 `/ K the recommendation for further checking% H% }; p5 d8 ?' y
- 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, N1 u! N+ f7 M1 R  `
 the names of the two files compared
! m& P" _9 Y% g; d# Qd) Leave the program (exit): f% k9 h% K2 Z
The ProgramCompare class: (Total maximum 20 marks available)
9 W7 j6 b3 l* D) i+ N2. 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)' Z$ {; k) a( E( T$ R
a) provide an error message if the files are not found or there is a problem opening them4 B( j/ d4 m/ ]' [$ m8 p6 m" B
b) compare each line of code
8 `2 c! w3 X2 |0 Dc) print out the lines that are the same
3 X4 }9 }0 n6 ed) count the number of lines compared / lines the same9 L& D6 A% h- K
The AuthorisedUsers class: (Total maximum 20 marks available)
% P/ O- H0 M) n# z3. 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)9 p' V; w# {$ c& |8 [6 t0 q
4. Provide methods to:
7 K4 o# C' B' Ja) 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
- i  x! r) o& u6 q5 _0 bb) return the name of the authorised user
+ n4 s( B$ h7 F7 Ic) return the name of the department of the authorised user; q9 i2 K0 Z, A/ ]* G% U8 i# K
Individual Data (Maximum 20 marks available)
- J$ x/ U( T! D$ P2 t" 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.
2 H4 Q$ j" N5 ]9 k/ }+ RDocumentation (Maximum 10 marks available)& g) ]. x" Q; q! n
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.5 @, j/ R3 g6 B
BSA104 Business Programming – 2007: Assignment 2
0 ^' g- q4 U+ _1 IPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- r3 f- |! z, k9 g1 t. y& O" F. _不过你要翻JAVA的类库说明。你有下载没有?
: m4 V& W9 }* Q6 _% |* |3 |查询关于对比的函数。貌似关键字是contrast,还有compare1 [* C& r: @0 A& }) s

0 V5 ?: o3 T. J! F5 o, n" Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -8 y( N3 q* C* A  q9 ~9 j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。, v' s* Z. Y! X
可以下载到的 是 jdk-1_X_0-doc
# h0 S. l4 x( Y, B2 B3 \* s4 @8 Q' k! i, C8 M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-17 14:30

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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