找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1528|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / _$ D( \6 m* x6 U4 F. J" B+ B- ~ Q+ s) j' U# ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 U% \: e4 {! t9 w
//  ProgramCompare.java         Provided by: DRS
' t* u- X6 l- P% o8 R7 ?: s//
' \1 l" K. y  a5 W//  Program shell for Assignment 2- z; N# P1 f0 i9 e4 M/ A# }* f2 g
//
- Z3 J; j6 M4 m; H: [- V//  Compares two text files line by line
3 ?1 t. S2 P: R) H8 ]//*********************************************************************2 E5 U2 r' ~# N: [8 j0 S+ ^+ Z

2 M0 p: C1 c7 H. timport java.io.*;
% _4 l* T+ z/ N$ K; u( r- W4 c0 D( h
public class ProgramCompare% M4 j6 Y, Q3 F" X4 O1 G6 O
{
; s1 w5 P0 n/ @* l) z+ h/ Q& b5 a6 g        //-----------------------------------------------------------------9 L" b& z, g! p$ v. c" a
        // Constructor) b) M/ z% t- @  d% Z  Q2 M
        //------------------------------------------------------------------ b7 t, ^# Q( ~* R, O# }; i
        public ProgramCompare()* j5 h* A( |1 M
        {
. t" \+ H1 i  X        }' m/ U7 s, f8 J% x

4 d. Z4 c) m6 S! f( `$ a0 Y        //-----------------------------------------------------------------( e8 q# R4 \3 u% A8 Y
        // Method for testing that class has been reached
: V, S# N, |1 C; n& f4 N: C        //-----------------------------------------------------------------        $ l* I2 V8 G3 f- i& o

# F, U; K0 T. E/ J3 U        public boolean ProgramCompareReached()        
8 V9 C! s% u: L' v        {- R& K" t8 L. O% J% M+ g
      try
0 V& C8 V2 ~% Z8 [4 W   {         * q/ ?4 F9 R6 X/ _- o
                       
) N) i! o( O5 C4 d/ t5 E                //********************************************************************
% E5 d( p8 ~; M, ^9 P                // Try-Catch Statement is used to handle exceptions - such as file not found
! X: X9 z4 q2 f& J                // Reading the files will need to be placed inside a Try-Catch - just like this one!- B2 k, e1 B  g: \" Z  u! |
                // For more information see page 534 of the textbook
7 K! L& `  j9 x% N! h; ~- Q                //********************************************************************6 @1 ~9 i0 K* t! k: p
                    
8 _- ~, h& d4 S6 @' g. a; S; G        }, e) ?- [9 q6 T1 `# [. h) ?3 M
             catch (Exception ex) // Exception caught here and message displayed to the screen 2 ]( G5 W5 K& W2 j/ j: u  [
          {
5 M3 ]: S" o( g2 _                    ex.printStackTrace (System.err);
4 H  E$ z# ~1 u5 H           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 R& j) W4 Y( [  B( r' }  J        }8 ^6 v7 t0 r# g5 y: k& D5 Z' L
                return true;
+ v- a& @9 ?- E( F4 z5 i# a) S        }" T% x6 ?( o' |. |* P' }

+ V$ f3 O# w9 Y% j9 T& Z+ w} // end of class ProgramCompare
4 X7 h: W. G( U' z2 \, S5 {  ?* j5 c/ @7 G/ K! T: _* k. O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************: K6 K6 Z  g! a, n2 h
//  ProgramCompareMenu.java    Provided by: DRS
) R. z5 |( Q. k2 y( c! K: L//
/ |5 k; V4 [* o$ ^//  Calls AuthorisedUsers.java and ProgramCompare.java; n: G. b: i6 ?9 B  _* y1 c- Q$ G
//: r6 x/ ^- o! s2 v! q/ H* p
//  Driver shell for Assignment 2.
% e- L: Q' ^" q" n5 O  ^, A//********************************************************************: f3 f2 a. T; i) T8 b" w8 }

7 ^+ O1 K1 d$ }% {: ~. k$ eclass ProgramCompareMenu  q2 D" n: S& }9 s6 i" H% R( O
{, E2 O- ~, ~# Y  f% @' c, R; ]
    public static void main (String[] args)
+ a/ _5 o. }* W; N* U( _5 b            {
8 P1 X1 u0 K6 n& d                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 a/ A6 t( @: Y  k  P( C8 O$ w8 M
                ProgramCompare reached1 = new ProgramCompare();
. s. ]  x% K9 {5 y6 d+ [# c                AuthorisedUsers reached2 = new AuthorisedUsers();        ( a2 b, \: \9 B+ d
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, y# v+ P' Q& `  X  k: \$ [                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; n! n  c* w, F        }" `, x8 ?2 ~# `& N, ^! f& O* k
}// end of class ProgramCompareMenu
& |: `7 D/ w& g, ]8 Q; b( p: q( s' }3 ?5 I  k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 t: [( j' Q, [# Y//          AuthorisedUsers.java          Provided by: DRS$ u* Q) B/ H* g8 ]/ b
//                8 J3 R+ D( E( S7 Y0 I; T
//         Program shell for Assignment 2
" N# U0 ]7 H1 n- B# v, S//
2 u; e* c7 D6 r7 N//         Represents facts about an AuthorisedUser3 T6 S5 S. E5 ~& `+ N: Z
//********************************************************************
( M' B% {3 `7 M3 p" @. _! Q3 S9 R- G% b
public class AuthorisedUsers- c/ D! k/ y8 H: v; t* t
    {* s# S- e& ?/ e) ?
/ a6 C" I4 ?+ T
        //-----------------------------------------------------------------0 O; r% h3 k2 k' C6 i+ K
        // Constructor
+ V' Z3 t' E* I: s! e        //-----------------------------------------------------------------
9 m; H0 o3 Y8 K6 C( |- G
! m- e) A' c: e        public AuthorisedUsers()+ D8 C. r% u! B
                {# ~# \, |  ~* [2 `/ X
                }7 Z" w; v$ i1 q$ P0 J2 G4 _
& e6 `; A. N' K' |- ~3 D; ]. |
        //-----------------------------------------------------------------9 l8 P/ w; J. t$ W5 S! y
        // Method for testing that class has been reached
) P+ ?7 {4 e4 |9 U4 W& E        //-----------------------------------------------------------------        ( R: X5 d! Z1 D! I# s: i4 M
        public boolean AuthorisedUsersReached()
; U( k/ F/ T, {' y& p( _/ i) i                {
0 R, |3 A* N! X! @, G# j2 o# `( E                        return true;                        3 F& i- r  u! D
                }
0 X5 ^" G: k: O) d8 x$ ]                6 u7 ?9 x! x$ D7 m+ Y1 O
    } // end of class AuthorisedUsers! W6 m- R( H( A/ J: \8 d4 ?
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" ], a5 G# O3 I/ F! N- [( W) _Shanghai - 2007' |% M5 e0 M* ?* z
Assignment 2( m+ ], d0 {7 ]) D  c. \
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)7 y1 R5 x+ m+ g- J) q7 l
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.& u" u& a  V9 z# Z
The staff must be able to:
5 o/ O$ w; r! k& e# d/ z! D1 K6 Y* m5 @ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 J/ [' K1 A5 V3 ?( 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.6 c! H* B+ M5 @  }' j8 J: k
 The interface should provide a menu so that the staff can:* H/ p+ s  d: |
a) Enter the names of the two Java program files to be compared; x% h) |/ R  s+ P$ q8 V  d% r
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 H7 K" R+ X' X% B; l% {0 ^
** 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)." Q+ r6 @6 Z: Z' U/ Z( s! e
BSA104 Business Programming – 2007: Assignment 2" S, W9 R! t* ]% x# `
Page 2 of 5* M9 `0 n! f  d) F4 H9 w6 N
b) Print out to the screen all the lines of code that are the same4 Z7 I& d2 d6 j/ [9 p# N
 Include the name of the file and the line number of the code being printed for each of the two files
  Q2 W: h) {: v3 i9 jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. d5 M  l8 C; d; m. @! C
 the name, username and department of the user
% ?! V) e) q+ \7 E% } the statistics of the comparison
( l! A- a  k) n3 f$ Q; \- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, g4 p1 ~2 ~! w9 {% O/ D/ k the recommendation for further checking
% ?1 Z5 h* Q( v- 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
0 u$ n+ A# N  W8 l; x3 R the names of the two files compared
& z# {6 R9 n* }d) Leave the program (exit)9 C4 {/ z$ D: h" e5 f# ]* Q
The ProgramCompare class: (Total maximum 20 marks available)0 `1 Z: S0 Z+ E& C5 F9 K7 g4 m# 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)+ Z3 E) _; n+ L4 X. @
a) provide an error message if the files are not found or there is a problem opening them4 ^# o5 R. J! p, m
b) compare each line of code
! ]! v8 S0 U' t4 x: |# v. s/ ^c) print out the lines that are the same
9 b  {7 S, I* x, P4 \d) count the number of lines compared / lines the same5 H7 `7 j$ R, {) }
The AuthorisedUsers class: (Total maximum 20 marks available)4 v) F. S8 B2 s4 }; `  p
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)
0 V& O+ h! o& Q6 |; F, I4. Provide methods to:
8 F3 P* T3 a9 c& a' h  j/ k1 u+ ^7 ia) 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
1 s0 k  O, \9 {' M, Tb) return the name of the authorised user2 M9 F, v5 H6 U! S: A  U7 B$ o' @
c) return the name of the department of the authorised user6 _0 Q! ]  m0 c& N3 Q2 M6 O1 m7 G
Individual Data (Maximum 20 marks available)
: Y- e* P- ~6 [* v5. 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 f) [2 G/ O5 `) L' dDocumentation (Maximum 10 marks available)$ {+ {1 q# n+ j% L
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.' N+ B! M& C0 d  i# w3 S% e
BSA104 Business Programming – 2007: Assignment 2# M0 ^, ~1 Y! l7 h' I+ q  {) p: @
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" G- H4 S( [9 a3 r- ^" w9 a+ ?" [
不过你要翻JAVA的类库说明。你有下载没有?. i" i) C# C; F. U6 C; H- X! f
查询关于对比的函数。貌似关键字是contrast,还有compare( @8 A7 H# P( q  r; C+ b1 m, x

! q4 C! U4 J& D( Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' j$ G( e( P/ l" W/ I痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。3 j& T+ I. `2 m" ]
可以下载到的 是 jdk-1_X_0-doc0 g" k0 }# J- ]7 o6 ~) d+ b2 F

* |; e* k; }9 T& m  j& p+ q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-9 04:00

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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