找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1146|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急; i+ I B, q0 {$ u* Z0 w $ Z* e7 y% ~9 _: X* y- R$ {( n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************# N, U9 O/ H: C2 [9 W, ~! \
//  ProgramCompare.java         Provided by: DRS4 n2 q8 h$ a  R& @, A$ F# b7 Z! O
//3 r- k- i1 ~) P
//  Program shell for Assignment 2" a" ]) ]2 ~6 W6 l4 a4 w/ V% N
//
" b3 S, Q! z: b0 z& D9 N( Y; ?//  Compares two text files line by line
8 h  R- M6 [- |2 J. D//*********************************************************************" W2 c2 K, ~/ S: h4 Y7 d

0 |* j; H2 T6 V1 X, J6 w0 S8 j; Y( simport java.io.*;
- J5 P' f! i8 H6 m+ E7 E2 y: Z4 S) S  x) R+ p
public class ProgramCompare
8 z$ N: z, n+ q2 t: h. Z{3 N) C" q% G9 N' N3 M
        //-----------------------------------------------------------------
: F' ?2 Z0 Z8 x, p        // Constructor0 ]9 H( u- E% G) d
        //-----------------------------------------------------------------
1 ]" m" M/ H7 Z- `. L, ?% [6 V# S        public ProgramCompare()3 l; x5 S( O2 f' S* R; G  X, Y
        {
: }/ z4 l! T3 E0 a* a$ B6 v        }6 X4 _, t+ x- A7 C; Q9 o1 c1 m6 V+ g3 e

6 f! D. p2 L( D2 w* @' ?        //-----------------------------------------------------------------
% y  e" Y& K2 W  H3 S" w1 f% g# Y* @/ q- f        // Method for testing that class has been reached
2 `) I( X2 f" g9 L1 Z" i        //-----------------------------------------------------------------       
, W( g3 F' A9 V8 }6 r7 \& x$ Q0 T* Z; ~0 q
        public boolean ProgramCompareReached()        
4 ^' {" V7 d" E        {
5 ~4 D3 W3 N5 i# U      try
6 ~. F6 g$ Z# }2 \) w* ~   {        
6 `6 F. z9 _( s                       
* O8 N' d' V+ [9 F; H                //********************************************************************0 U! |/ c4 P; y
                // Try-Catch Statement is used to handle exceptions - such as file not found
5 Y7 k: w/ d0 c$ _/ k3 C                // Reading the files will need to be placed inside a Try-Catch - just like this one!
' c8 h/ D4 C% J* Z1 f9 |                // For more information see page 534 of the textbook
# Y2 s/ y% U" E6 z2 A                //********************************************************************3 {2 ?# {9 V, s5 l% Z' c3 w
                    
/ j1 {4 c  n( n/ Q- g5 ~        }1 W$ d* G! H. I2 k" ]2 p
             catch (Exception ex) // Exception caught here and message displayed to the screen
4 M/ |4 r+ y9 d1 w0 d$ D          {
4 d0 k% T* U+ X9 b) C$ Y; ~  Y                    ex.printStackTrace (System.err);; Z# }3 q2 ~' t. s
           System.out.println ("Error message goes here"); // Replace this error message with your own          : [  I) B7 e% h4 m" T& X; L
        }3 X, N+ X: z' T4 H) K
                return true;
% a+ N: n, ~! ?' C        }: @/ n5 P9 a9 k8 W, Q, _0 l
6 S( Y/ I$ ~$ B6 u1 C
} // end of class ProgramCompare
1 K$ T3 j: G) N  z- ~" y6 V! u, N7 R/ G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- {! ?% y" M3 f8 x  T  z0 l//  ProgramCompareMenu.java    Provided by: DRS
" E, u1 M( I$ t0 U) ]//) S, {+ F5 ?; X" Z6 H9 d
//  Calls AuthorisedUsers.java and ProgramCompare.java
# T8 W2 m0 F; K//
# s+ [/ \% }# c  ^3 v3 N//  Driver shell for Assignment 2.8 P: F3 ?: a7 R! i! `, U
//********************************************************************
& Z  S1 y% f% h! o; B: k2 ^8 F( _& G1 B/ m8 |8 R
class ProgramCompareMenu
6 K% u6 }- i( }% U' u, g$ Q{. e2 Q' u, F" N8 B; y( [' r
    public static void main (String[] args)
( }% P3 A, _1 S; h/ @            {  Z1 I- Z7 y  u/ Z2 z, r4 c; \
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
1 m, B" a; V/ ^$ M7 q, N5 P                ProgramCompare reached1 = new ProgramCompare(); . R9 o2 o" V- B/ ~# A
                AuthorisedUsers reached2 = new AuthorisedUsers();        ; N3 x8 x+ h- A0 \
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 P5 b* \4 ~# a- O0 f, Q+ N                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ _2 A5 M! n& a& k! y" q        }. J& |8 v7 k$ s" y9 n
}// end of class ProgramCompareMenu
$ r- c  q. G9 _! X
) `7 P  J' z" m: H# U  b; U4 P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' p  |! m1 \) o" _$ B! U% q' y, Y  ^//          AuthorisedUsers.java          Provided by: DRS3 u% M9 S2 C8 x, b
//               
. d3 s9 G8 H! C% F+ l6 r( {' U1 @9 B9 \//         Program shell for Assignment 2, {6 C; P1 q- \
/// T/ C; }/ u$ C4 s
//         Represents facts about an AuthorisedUser
+ t: l; z% f& V) G//********************************************************************
6 ~( u5 {6 b$ F: H
/ g9 N! L8 G& Rpublic class AuthorisedUsers* X: B0 s5 R% c9 z  N, x
    {
- g7 o$ B+ i6 L
- L8 Y2 j9 ?0 z0 l5 x- V        //-----------------------------------------------------------------
8 y+ K5 }" U! U) r1 k        // Constructor. X* S! P6 H% O: [" F
        //-----------------------------------------------------------------& |0 G) t* t. l$ j# N/ m

+ M  k: |8 N1 F+ p        public AuthorisedUsers()
0 }& |; r! U8 D                {
, w/ Y" x& E& K; M5 b! |                }0 \8 B+ P: l6 @; V$ ~1 ?
# E  M/ N+ e8 e- e3 l  L
        //-----------------------------------------------------------------
! X* a7 q! U  Y1 c) z- Q        // Method for testing that class has been reached
. R% S: Y) Z+ o# o2 v        //-----------------------------------------------------------------        / U! C7 Y' u6 D
        public boolean AuthorisedUsersReached()6 W) Y( g% r0 S" n$ v. X0 {4 u
                {4 C5 T8 q3 O; o2 p! f
                        return true;                        ( h% o- a4 o+ J! I
                }; [+ G3 y$ c1 y% d" [5 o
               
+ ~& A3 X3 `, r; H2 v    } // end of class AuthorisedUsers
3 P& `1 w6 l/ e# e$ G  ~% f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 j  c( E4 C/ B* J2 }+ H, i5 `Shanghai - 2007
: M. [# d" L8 F; A% ~4 s. E0 ?Assignment 2! N$ a! g8 d9 b6 H& J; i, J
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)1 ]9 A, P5 d9 T' R
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.
  p& [4 u+ D5 Q9 i7 [" `2 `The staff must be able to:9 h" `2 h# O" ~) R8 j: [
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
$ r8 n  V% O0 O" e1. 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.
) ]% n4 m; L7 S* v/ X  N: a9 | The interface should provide a menu so that the staff can:
" i& D) B% l7 v' ]' a" da) Enter the names of the two Java program files to be compared
, L. B0 y( ~0 F* ~6 t For this assignment, it will be assumed that the two Java program files are in the same folder as your program.1 ^- D: t/ ^8 d9 j
** 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).( ~5 k# S  D  _5 @6 V! s7 F
BSA104 Business Programming – 2007: Assignment 25 Z' i% ^% U  b$ n& K6 d
Page 2 of 59 z. T  S5 O( R2 ~
b) Print out to the screen all the lines of code that are the same8 Z9 F. O% l9 `7 s7 g) ]4 N: m
 Include the name of the file and the line number of the code being printed for each of the two files2 D3 }+ j- p: |( Z3 S
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared! I& Z3 ^& f* d' @" i5 O" `
 the name, username and department of the user9 [) [8 r' r5 R# L
 the statistics of the comparison! _8 x/ _' o. x5 A2 R
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different. O1 M9 H! Q' t7 [( R, ?
 the recommendation for further checking" F8 ^. e! G# I
- 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
. C7 s# U& x0 } the names of the two files compared
" w" \% m4 b" r8 ~- ld) Leave the program (exit)/ E, ^9 w0 t0 L$ a, `% E
The ProgramCompare class: (Total maximum 20 marks available)1 i2 h. Q. ?9 V, b3 m( @
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)3 \6 d0 B, ~* G
a) provide an error message if the files are not found or there is a problem opening them3 L& @& s. U) T- s
b) compare each line of code8 F! \5 |5 \. Q( [% l; O% T2 W
c) print out the lines that are the same9 k0 w/ |0 q* u7 H. V- {+ t/ m, s
d) count the number of lines compared / lines the same
( Y9 D3 T8 [6 G8 k& N# i6 B- L, ]The AuthorisedUsers class: (Total maximum 20 marks available)4 e% g# G/ z+ F8 L; o$ v" k. R( h
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)
/ ^6 b+ q+ m# e4. Provide methods to:+ v% ~- U+ ]( R. }' S
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
7 v2 j3 p- P2 P9 k8 j) P' W2 Bb) return the name of the authorised user1 `  q* Z* N7 t0 G2 N" n& X
c) return the name of the department of the authorised user( K# r8 i; |. S9 E6 ^
Individual Data (Maximum 20 marks available)5 r# ^- i( ^* \
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.# c0 N) w7 q1 R( _3 o
Documentation (Maximum 10 marks available)
# b. r5 B1 {- L% _/ Y7 h6. 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.
! W4 ?' g& R9 G: X7 bBSA104 Business Programming – 2007: Assignment 2
7 p- K- }* d* I4 XPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% n" `4 U, Z2 F不过你要翻JAVA的类库说明。你有下载没有?
3 q+ Q: V7 h+ r& Q查询关于对比的函数。貌似关键字是contrast,还有compare
9 {% j: y$ L0 B8 F/ p) l& d7 }6 c# p
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ @# X2 W. s" E# l( p9 G- g  s
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
3 @& C+ B" \/ Y9 s0 H6 K  [可以下载到的 是 jdk-1_X_0-doc( ^  F; j# _2 A. I: Y
' w) |% g7 v1 c5 }& }, G9 c# p
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-29 10:02

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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