找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1287|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 H( |; I% D* @- |/ A- C ) ?7 n! D! v6 h$ B/ x+ n: R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  y: o$ B. x6 ~: T3 E6 P) w) B3 J
//  ProgramCompare.java         Provided by: DRS3 I$ E" R+ f; k+ `
//
, A6 r! y  y; `//  Program shell for Assignment 2: u' H$ y  g: {/ A# \) n+ a. v) l
//
: \& G2 m( f! Q0 t$ I( b//  Compares two text files line by line
1 k+ W" d; U# s' m  k. p//*********************************************************************
% C, a) E8 A, B1 J* H3 w& b. n( k9 |' X
import java.io.*;" R3 o- Q; e+ K. k  H" q( t' n9 {
5 |% g4 \: M2 A. I
public class ProgramCompare" ]  f/ m2 {& k# T
{* I$ D+ Y) r4 O2 u. {6 Q3 o- M
        //-----------------------------------------------------------------
0 q) ?) i6 m9 W9 y4 ?  E' t% B% A        // Constructor% |3 M$ I; s1 H5 Y! m3 j! c
        //-----------------------------------------------------------------
& L5 c" I3 [5 u! J; ~6 p7 |. L        public ProgramCompare()* W3 m6 K/ c. p) ^. \' K
        {' G# I# ]* O! P8 d) F8 J( F' u/ i
        }, S. B. c# ^2 X% w5 M4 O

& F+ w( [* Z! `1 m( y4 q6 z- d        //-----------------------------------------------------------------
+ X% a1 S8 B' N; d0 c        // Method for testing that class has been reached9 }- ^% Z, I  S1 P
        //-----------------------------------------------------------------       
  X: q/ d' |$ _
% e8 ?$ o! h9 D( R& k        public boolean ProgramCompareReached()        
% ?6 X; G$ t1 @; e( I        {
* M4 |1 k; r/ ]. Y. k3 W4 {      try
. ^( E9 d6 Y+ C& p0 A% i   {        
0 n/ {, ?# d2 F" C1 x, T                        - W6 Z2 ~/ x( A! J) N& y% ^
                //********************************************************************
. {0 ?& @, ^; |& q7 h5 O% H                // Try-Catch Statement is used to handle exceptions - such as file not found 2 I7 F, @5 ?) V& F$ T+ n# O2 ~$ F
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- h% ^. P0 Y/ l# V" w                // For more information see page 534 of the textbook! V. r# K( N/ \
                //********************************************************************
1 Q5 e( B  i9 }  x0 |                     ( o$ ^# p, l" z* l; q  R1 q& l0 ~, M/ I
        }
4 B& }6 E) d7 G2 _6 F; A             catch (Exception ex) // Exception caught here and message displayed to the screen
- p! h3 m- v; u; V; n          {+ W0 h# ^; p$ `1 ~
                    ex.printStackTrace (System.err);
- P( [9 q8 }: [  G+ {' v9 b           System.out.println ("Error message goes here"); // Replace this error message with your own          ( X# \8 m% x: J. z- b' M. T
        }
; g9 D: D, N' d+ v- Q                return true;
7 @5 `: ]- M' @$ H+ @        }
8 G; C/ p$ _+ W: _# V- G' Q
# `3 @- p: m; o7 D- V  t! ]2 ^} // end of class ProgramCompare8 V$ Z+ d% F" v4 i8 ~

- G  U) w4 N2 R7 ^4 c' t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 u3 Q1 c1 R$ M, u# k8 N; P/ Q- j//  ProgramCompareMenu.java    Provided by: DRS* t8 M3 M) T6 e' x3 G# a$ G& E* e
//
  ^* X$ H0 N) ^//  Calls AuthorisedUsers.java and ProgramCompare.java
* D3 o6 |0 x3 U//
& O6 Y9 t- ]/ |/ v+ G( a! K3 T//  Driver shell for Assignment 2.2 `5 k" i2 ~: e$ i
//********************************************************************
# N7 v' @" I+ J( o: {& P% x  [7 k; r" _- i- {- F
class ProgramCompareMenu5 |% i; r3 v, R) \9 J1 k; ^
{
! m; }* N% a: L' F( T    public static void main (String[] args)5 @3 y& ~6 T2 L
            {
7 b1 B4 s3 q( F! p% P4 L4 v" f1 F                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. S) T  _7 k3 \+ b- e& z7 z                ProgramCompare reached1 = new ProgramCompare(); 8 e3 c- G0 s0 A$ I+ r2 z
                AuthorisedUsers reached2 = new AuthorisedUsers();       
4 X# o  @6 x( Y) n1 i                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
( G+ \% s0 }& ^6 a! y& Z3 R; L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; K: i4 E( U1 R7 m; q        }
$ ~5 e3 A1 }5 q8 U0 K' n" J/ [0 e}// end of class ProgramCompareMenu6 x7 l4 g3 y% Z; u
' ?$ E8 z, I' C6 Y: N  M9 M1 q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
0 b4 S1 a9 k. M7 _- k//          AuthorisedUsers.java          Provided by: DRS9 C- f3 A2 I% u3 C5 k+ ^6 A
//               
! C# Z& m+ o3 K$ ?. n//         Program shell for Assignment 20 |, |3 [4 r: G$ b4 V
//- {& K3 _6 ~/ Q( v
//         Represents facts about an AuthorisedUser' E0 V( _9 X2 n9 M8 K+ R
//********************************************************************+ }* I$ n0 f8 C1 U6 m. v

! T1 d2 K+ X2 f; [: D4 ipublic class AuthorisedUsers* C' E1 o2 t6 }4 @1 E- I  G6 a
    {' Z; d* ]' f$ ~- j
2 A- U, s7 z0 p9 ]+ y  ~
        //-----------------------------------------------------------------# g; L9 z# o4 C7 `/ G
        // Constructor3 I' P( d7 [) z8 K) B
        //-----------------------------------------------------------------# A( c+ O! Z+ }" e% F5 C' T

# z* D1 |3 A' g2 x8 n1 _        public AuthorisedUsers()
4 U7 Y7 r) V# R8 j- K# O) o! u                {% J1 ^$ W0 N: |0 h  j$ C
                }& S& }/ m, z6 b
9 [; l  _! ]4 n
        //-----------------------------------------------------------------* H& X: l% f: i4 X% z) s0 w
        // Method for testing that class has been reached
. F. b+ E* P. n+ g/ {" y$ v( Q% ^        //-----------------------------------------------------------------          g1 H5 u3 n; |$ D, y3 t* B
        public boolean AuthorisedUsersReached()
8 E1 d0 p" k. [! R3 Q) C0 U% u                {) a" L- \  H$ ?9 ?1 o
                        return true;                       
; T; B& X/ b5 R* R. f# u                }
/ G3 h9 H/ [$ v8 o4 y3 A+ U                5 C. G3 s. p: Z7 F+ h3 c7 P( I+ S
    } // end of class AuthorisedUsers! q' h/ ]" }; X0 _( f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 ~# x* a8 U* h, A& W1 B6 g4 aShanghai - 2007) n3 Z+ A( T: M, o' B2 @
Assignment 2
4 y) ^+ @5 N8 G# [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)
( e/ ~) Y4 }( G8 R' t. P1. 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 W/ T4 G9 I* Q% ^$ uThe staff must be able to:
0 m, p( H+ f7 ~1 x2 q* q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
( \7 E! `- J% \9 `% S5 m- q1. 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.7 d  x# l* s: D3 }! A
 The interface should provide a menu so that the staff can:
9 E% w! `8 S, O5 B7 X) s7 ja) Enter the names of the two Java program files to be compared1 S- q7 j! @+ D
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- ]' y  w' a% j  r% B** 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).
6 G9 i8 o7 y3 E4 ~; i7 o  p& x/ g0 n8 `BSA104 Business Programming – 2007: Assignment 2
8 b) q  O" Q5 n& q% y; v! VPage 2 of 5
  {4 s4 p8 c1 ~b) Print out to the screen all the lines of code that are the same
5 f+ T- P8 v7 L- j Include the name of the file and the line number of the code being printed for each of the two files- U8 N" z0 z* i% o
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 u: G6 G& @: D* [2 k
 the name, username and department of the user
% R) H- p2 d5 q0 a' A& B the statistics of the comparison5 ^7 Q! `. ~" }1 H$ J- n
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 x9 f) y3 Y' R3 d) a the recommendation for further checking
7 h5 Z, D3 g$ g" I7 i3 c- 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/ n' _* p6 C8 }2 w% A5 @! F1 a
 the names of the two files compared+ K8 A/ ~% c0 e* \# k( z  y
d) Leave the program (exit)) D7 V3 F+ \2 q6 Y
The ProgramCompare class: (Total maximum 20 marks available)
. _. f# X0 ]! j4 X8 F8 H2. 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)
& f: r. m6 R' X  Q2 i4 L2 j5 J- Aa) provide an error message if the files are not found or there is a problem opening them5 e2 V7 K* j  _( F
b) compare each line of code: x5 O% O/ y# {* G
c) print out the lines that are the same
* F$ |5 \4 [  f/ c( {d) count the number of lines compared / lines the same! f( ^. G0 [. T0 e
The AuthorisedUsers class: (Total maximum 20 marks available)0 v6 Q0 U7 K/ j; X9 Q
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)- Z7 B* u4 z$ h! r
4. Provide methods to:3 @: n# |4 i2 K/ y4 o
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
/ I- Z6 y- |5 C. i" Db) return the name of the authorised user" E, _8 C0 j+ y& N8 D( G  H
c) return the name of the department of the authorised user
2 `7 L3 }6 q; N1 }Individual Data (Maximum 20 marks available)3 G4 C* ^- l5 j: ^
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.5 Y6 t. ?. s, ]
Documentation (Maximum 10 marks available)
3 y1 S/ y# t# o+ a. x6. 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.
2 O( Z8 n* s  \6 R2 S4 Y. JBSA104 Business Programming – 2007: Assignment 2+ [- ^9 |" V5 \  B2 a+ y5 |
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 ]7 [" S7 J$ ~# M- q5 B& e不过你要翻JAVA的类库说明。你有下载没有?
! H% p# m, r1 p9 I, O查询关于对比的函数。貌似关键字是contrast,还有compare
5 X# a7 r9 @- `+ Y& [0 |* v% G, m; U5 d, P$ n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 p+ f) h' g; B8 E4 J痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: }' H. K8 z2 ?1 i2 J. [. u7 C
可以下载到的 是 jdk-1_X_0-doc
, e2 a2 Z9 B4 i% F
8 ~6 v3 x" X- @3 M( ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-15 23:25

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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