找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1127|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - ~$ j' s( K6 p( C8 O( Z+ O b. ^+ T# A1 a" J3 U- i& 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 | 显示全部楼层
//*********************************************************************- V9 o$ [* C. H0 P" H
//  ProgramCompare.java         Provided by: DRS
7 d- T. w# L; W8 Y5 _//; p5 o( N: M) t! U2 [' _
//  Program shell for Assignment 2$ I, x) i! w2 M4 B3 L
//
6 D# s/ [2 G% `5 w$ U. M7 g//  Compares two text files line by line
) J0 B; L5 s# U' S, @& K1 C3 M//*********************************************************************
8 J  z3 \# j  T$ I) L# s! `. u: B/ a4 v* _" i* z# O
import java.io.*;
8 l. F" d4 A8 L( Z% m4 q# f5 ~7 [5 \' E8 c, x& T
public class ProgramCompare$ A& g, W7 e. ~3 g, p/ v
{
8 t! |/ P% f. Q- R        //-----------------------------------------------------------------
, G) I# I4 [6 O( x5 q        // Constructor+ L! q+ Q+ ?- |
        //-----------------------------------------------------------------
! y+ |% i# U7 u        public ProgramCompare()
- y. x6 _" v: n        {3 ~# f4 }# i+ j. _# X# L4 j
        }
8 v1 E7 G- U* |! {4 N& O- A; q6 x( ~
( Y" K6 c$ Z- k: A8 U% ~        //-----------------------------------------------------------------$ B" t- `/ H  X; c* |  [8 ^
        // Method for testing that class has been reached
1 I/ q! h! {  `2 U        //-----------------------------------------------------------------       
  Q" q8 v1 ~1 G
4 a- l( k, p( @6 `( H- m        public boolean ProgramCompareReached()        
+ I1 K6 m2 U5 I; q9 P6 B        {
1 ^' |  U  M! p( Y" u* a' C      try ; I/ q- R6 u' [0 _) R! X# G
   {        
# y6 ?7 C" x7 c1 Q                       
  i3 \# Z7 v' w* R' y                //********************************************************************2 l6 v% V" s: k& D3 I% W6 X
                // Try-Catch Statement is used to handle exceptions - such as file not found
3 z9 @! ~0 ]# R, D' b: @5 O                // Reading the files will need to be placed inside a Try-Catch - just like this one!
( z1 Y$ d; f2 D- o2 e9 Y  H, i! b6 [                // For more information see page 534 of the textbook& P" ^# r/ F& u& M! D: P
                //********************************************************************
7 o- _; v% Y3 w% j                     + Z/ v9 a# x8 ~& i7 e3 C
        }
4 ]/ s+ v+ w  W" ]& I# k/ m             catch (Exception ex) // Exception caught here and message displayed to the screen
5 Q; T. O. [! L, n+ h          {
' R9 U! @  [  @" C5 u6 `3 m2 _                    ex.printStackTrace (System.err);
- d& G8 ~! Z! @- V9 P; w! |6 B( @           System.out.println ("Error message goes here"); // Replace this error message with your own         
& Y- T2 }/ J  Q* V! Z: u6 ?& b4 s/ p$ ~        }
" B! F' ]& ~" h% A                return true;
# ?3 `. x+ Z2 V; R, b5 K        }
* P. X  b. X! [
  F( h! q5 o4 H$ M} // end of class ProgramCompare: q2 _" h+ V5 E
5 A& S/ q9 _/ h- `) j$ h% o3 a
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 t! _4 o6 x/ m9 G$ c/ S! I* G
//  ProgramCompareMenu.java    Provided by: DRS7 e" `; Y5 C: j. }: w$ [9 j
//$ R, S2 s. n2 A7 A2 M6 M
//  Calls AuthorisedUsers.java and ProgramCompare.java6 K0 @) e6 U+ E' h$ f6 i
//+ ^2 D& o' u3 \
//  Driver shell for Assignment 2.0 C  Q' E5 |9 l5 S
//********************************************************************
$ |4 D1 S# M+ x& x* C6 v. X" \
4 g% V9 t1 \/ e0 Fclass ProgramCompareMenu1 L( b: {5 P6 c. v4 s
{6 Z0 j8 G/ W/ o$ r5 B. ~
    public static void main (String[] args)
3 F) l+ l) c& J7 v2 `            {5 y5 K3 U6 q$ r9 q6 j, K
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 W4 A+ G, G+ P+ V3 Q( K
                ProgramCompare reached1 = new ProgramCompare();
& X6 L4 J" E6 g# I( i                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 g  M. P( Q) D# R                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
4 b; p$ }4 A. Y+ ]8 z- e1 Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 i9 u3 t( L8 C" h" A  E3 `2 O* @        }: M9 {  ?7 L9 `2 a* D% X7 C
}// end of class ProgramCompareMenu, R; j/ d1 }* x" Q# d& D

$ M: |! p- _* i, y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 G7 {* F7 o% M7 u( t9 l' w
//          AuthorisedUsers.java          Provided by: DRS2 U8 s# U, ]$ X0 }! X+ i  e
//                $ r7 M: U3 y0 S
//         Program shell for Assignment 23 E+ j7 g" X" D1 \" K# k! z
//, t0 j3 S$ a8 w$ {% z6 g/ W
//         Represents facts about an AuthorisedUser
, R; v! F) e1 U* l2 w//********************************************************************/ h  }5 X, ]/ Z# c3 i) W, i

! y, B; m! N& `( t! m$ Mpublic class AuthorisedUsers
. O7 ?  @6 z' R0 l  t    {
/ O  z% D( ^9 L  e$ [
. k0 E3 x: a$ v% C! h        //-----------------------------------------------------------------1 A2 \, q# d0 D4 P2 l2 R) V  b
        // Constructor
4 m( F! R6 Y, F        //-----------------------------------------------------------------+ {- g% Q! B; b2 f. _! g. z( P

, l3 r2 A) m2 ~3 [7 u5 }% I6 F6 s        public AuthorisedUsers()
1 U" }  h+ j) b# P- e                {* F0 T7 @/ f2 y* ]# d
                }
+ D8 c6 |4 F; p, {! a+ [  g& V$ e6 q* b. z$ k7 A
        //-----------------------------------------------------------------
& {1 J2 @& [- m  x- [2 u$ c        // Method for testing that class has been reached* f) k; h5 P6 E; q" d  h. |4 Z
        //-----------------------------------------------------------------        7 E; L7 P% W8 Q( u! C
        public boolean AuthorisedUsersReached()
( i3 ]5 i2 ]0 O0 |# S" A: S7 ~                {9 w  L$ @+ V$ m1 \1 q; B$ Z( Q
                        return true;                        / L4 }( n! g! A9 r3 C/ ?" p9 Z& m
                }, d& c  E; ^2 t1 V
                9 X( L$ T# t  a" `0 ?7 U+ N
    } // end of class AuthorisedUsers- o$ o' o  w3 n7 N6 \; y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming6 P7 J0 a8 H1 ?4 |
Shanghai - 2007
: t+ S0 P0 U: j- d: `1 b) \Assignment 2) S6 j4 p( h/ e
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)
" `9 }8 O/ i" ]+ r% k, c1 R# g" E1. 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.
9 s1 Z; X1 G% n' R& d# TThe staff must be able to:
% l2 a6 k: Z  s6 T Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 r0 _! X2 r/ h5 K6 P& 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./ p" Y* K$ h0 x* f4 ?
 The interface should provide a menu so that the staff can:2 v/ C+ E+ G* M$ p3 ?& @9 I- M
a) Enter the names of the two Java program files to be compared
0 B# m- F- P/ N1 v  I5 q# b For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) {$ ]# [4 o/ |; ]* g
** 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).. A# C( V" j' m" G; C1 O# A( J" x
BSA104 Business Programming – 2007: Assignment 2; ^9 {5 O# _9 y' ?8 b9 {8 L
Page 2 of 5
1 a$ G5 w0 V" m8 X7 _# ]b) Print out to the screen all the lines of code that are the same/ e2 r$ {* L/ v% I, p5 l
 Include the name of the file and the line number of the code being printed for each of the two files% j( F& }( Y( H' x3 Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# r7 ~8 X9 R! M
 the name, username and department of the user, j4 f  f1 k; j9 x* r3 Q
 the statistics of the comparison
8 d, k) l2 ?/ {- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 R2 b  p# V7 b) {# s* g the recommendation for further checking
. g) _2 V4 W7 y6 o  s. P- 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: i! l3 }0 K9 y9 V
 the names of the two files compared9 u/ a0 G0 ?# q6 [1 m6 n4 h% G2 K
d) Leave the program (exit)5 e! d  [! K/ \3 h9 f7 O4 u; D
The ProgramCompare class: (Total maximum 20 marks available)
1 e; c5 v+ ?. A9 ?$ J, ~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)$ U7 |8 I5 E; q7 j3 f
a) provide an error message if the files are not found or there is a problem opening them) {, ^$ M6 G4 F9 E  @! L* y- Q
b) compare each line of code8 W9 H2 m3 f8 N
c) print out the lines that are the same
( V# R6 k) a, Y) c  |2 V! [1 \$ ^d) count the number of lines compared / lines the same
5 |, \$ ~3 I5 A2 s6 p: ]The AuthorisedUsers class: (Total maximum 20 marks available); O* J; U% L( V  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)3 t. b8 i- E8 G: D. {; [7 [3 t
4. Provide methods to:  {. Y0 B. _+ Z& d5 I: n. H% u  e7 h7 K
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- v1 A7 Y) r. F% U" {* _5 }: M" }
b) return the name of the authorised user) R# M8 G9 B% O% N3 O3 J
c) return the name of the department of the authorised user9 ]* z' S7 h& t+ l8 n1 q
Individual Data (Maximum 20 marks available)6 v/ Y  }( a. h; s
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.
3 o. G4 L2 w9 ODocumentation (Maximum 10 marks available)
7 {3 Z0 N, W( ]. }# d+ T7 ?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.
' ]7 ?& {2 E8 B9 Z5 f6 OBSA104 Business Programming – 2007: Assignment 2
) n3 h0 G( x8 zPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& m) C. T& f( C# W- E
不过你要翻JAVA的类库说明。你有下载没有?
8 j. K0 P3 G) f2 k9 D3 g% u$ ~查询关于对比的函数。貌似关键字是contrast,还有compare
) J4 v8 a+ Y. ^  D+ L& d" S5 R3 @+ t; s( f
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -! U& D2 Q1 `& h- S9 G7 s
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 F9 h  b3 R. |5 ?0 W5 K可以下载到的 是 jdk-1_X_0-doc
, O; F% O$ e- ~. H  r; Y! Q% ~2 g3 |/ N( h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-19 11:17

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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