找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1761|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 s! R; k! w6 F3 U1 O/ o' E 7 u/ A* h5 G* n; m y& O
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% A* V$ k; `. l5 S( a//  ProgramCompare.java         Provided by: DRS
' J8 E' L' l( Y9 t7 E/ w; h//* s# H( b' b$ K# G$ X, E1 _: X
//  Program shell for Assignment 2
+ P" w) I" y" N+ R* J: E//
9 u$ f5 l4 w0 c: C7 T# R+ ^! W. ?//  Compares two text files line by line+ R& k+ L: L0 N2 t  T8 T! N
//*********************************************************************
+ e+ l* }2 R2 G3 b4 V8 n' ^# E0 N/ _0 I
import java.io.*;
& c3 g% {! }; K8 Y3 M% ~8 C1 |" k& i  @8 G
public class ProgramCompare
4 y* M' i' X7 z{
# R* T* `8 Y( k6 P  R4 r; l        //-----------------------------------------------------------------
1 S/ M* P5 q! K        // Constructor0 G4 z9 i2 H, B1 J
        //-----------------------------------------------------------------
/ e" t5 S+ D4 c  G0 ]& f* E        public ProgramCompare()
8 T$ r4 z/ d& C* O        {
% M) G+ C$ [+ Y! l        }* q& r' D( f( @6 L
- h6 f* x  k0 N$ U* h& K# f9 \
        //-----------------------------------------------------------------
9 f5 A( C+ M( V* v- R) h        // Method for testing that class has been reached$ E3 S: e: Q% k  w# n; C) e/ n
        //-----------------------------------------------------------------       
0 {# n/ J% H) Z4 p/ r; m% v
1 ~5 Y4 u9 b$ E& p/ y        public boolean ProgramCompareReached()        
( d( d( P! @3 t/ f+ s        {/ U+ O4 m! l. [, g2 ~6 R" Y
      try 1 H( {- \& P5 g& K0 a7 U" s9 g
   {         : E/ q" k! u1 j4 S- ?! P
                        9 G  Y7 u; O7 T, o2 U
                //********************************************************************5 h8 P1 ?( \, J) I  p
                // Try-Catch Statement is used to handle exceptions - such as file not found
. u* f3 f, a8 w& u6 h& B                // Reading the files will need to be placed inside a Try-Catch - just like this one!) B9 U: I  u9 G$ W
                // For more information see page 534 of the textbook
3 C) @3 s: U+ y& u% s, e                //********************************************************************
/ k& V! v+ s9 e+ C, K                    
/ D/ s& Y' q' H7 @+ M& [/ D        }, c' f" c" ]8 v  ~
             catch (Exception ex) // Exception caught here and message displayed to the screen
7 t" q3 ^; x/ r1 ~          {
& s2 i+ H- C+ \" C& x- R$ s                    ex.printStackTrace (System.err);) g# q; F7 P; z4 @/ |" Q0 U  d
           System.out.println ("Error message goes here"); // Replace this error message with your own         
! r% ~+ B* T; }5 J& r+ S' p        }, |; C* Q, c+ a! u4 |' q1 G, R
                return true;* {- B. m- p4 i! l: t' t$ o
        }( |( M8 p, W: H' S/ B. H

5 f" e: o% u& y1 e9 q} // end of class ProgramCompare
: O4 E% Y1 J. H0 J' o8 {/ p" g+ }" s1 P6 \6 W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************4 ^1 |7 A& g, @8 s
//  ProgramCompareMenu.java    Provided by: DRS
8 g7 F# w# `5 h7 y, l) a0 c//* `7 i8 k2 I3 ~' _/ [% Z7 J
//  Calls AuthorisedUsers.java and ProgramCompare.java1 m( f0 I3 e, x5 I, J! S
//
. Q( R9 h: ]8 q6 G# V//  Driver shell for Assignment 2.
8 C8 F, A6 m2 _9 P3 A. G* _0 }& O1 _//********************************************************************8 |# L8 t* n; \6 R

& B, @7 g$ M" q& n" e  \6 e" t/ @class ProgramCompareMenu
4 `' r- a. G" \, a8 `{
, U  G3 s! W; C) n3 w$ _$ I% g1 K' n: L    public static void main (String[] args)
0 J  O' i* x! p1 ]4 V1 I            {
  w+ @& L, g( _                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& A6 B; }* C2 C. ]# g. g  g                ProgramCompare reached1 = new ProgramCompare(); / }7 p) r# B- K! ?
                AuthorisedUsers reached2 = new AuthorisedUsers();        7 p3 O* e: u1 N* @
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 n/ N0 o, b# i
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
% e# X/ |4 H- u2 ^        }, e7 O9 g7 {4 J  S
}// end of class ProgramCompareMenu6 g7 `( J- f1 Q" T* M" s  ?
7 N  y. ~7 @: Y+ H8 o. Y1 M) W% @/ m  H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' N/ a5 t# L! I. l7 y//          AuthorisedUsers.java          Provided by: DRS' j$ w5 n4 U" b& q: F! U0 a5 _
//                , T. ?( N: X  t9 H
//         Program shell for Assignment 2* ^  G( p6 ~6 M( v% C
//2 ]: Q9 U/ r3 y. R' B1 _
//         Represents facts about an AuthorisedUser! Y- u$ G4 H' k  h) k, v4 s
//********************************************************************
8 ]. k' N, A1 C. M* k/ ~. l+ D1 w4 y
public class AuthorisedUsers
( @8 W. O' C7 r, P  q    {
7 H$ p8 ?/ _& ]9 q7 K2 n; V, U
        //-----------------------------------------------------------------
: x$ E/ x7 R! W. G; z        // Constructor! T. U$ b3 ?0 Z- q6 N: E, ~
        //------------------------------------------------------------------ B( T7 q9 {( [8 r1 t
% R) Q& q2 r& y1 b& t
        public AuthorisedUsers(); H9 R8 l4 q( J$ d( }
                {
! |6 C" O# }4 i4 m+ J% R# h                }
; s; |; P2 ~4 P) u; k
# m& G  r6 v& a/ ?* P8 P( k5 T        //-----------------------------------------------------------------
  M9 j* O: S+ r# I6 R6 K; I        // Method for testing that class has been reached
0 ]3 G9 _8 ~  A, v        //-----------------------------------------------------------------        0 u! l4 |: W9 M/ K1 D. x- L
        public boolean AuthorisedUsersReached()
2 p% I& t! @+ Z                {
# I9 I6 h0 g. @5 N# ~                        return true;                       
: }6 c% n, J1 s2 {( R- h                }
* Z: |7 C) B1 B  y                : m+ e6 {) W0 T: R2 i; U
    } // end of class AuthorisedUsers
1 f& `4 ^+ M) g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 j' ?2 y$ Q' x+ \' y2 O8 @  f7 DShanghai - 20070 U$ R0 [0 _- V7 I4 |8 w  q
Assignment 2
  q4 a" S$ l) b2 N# J& CDeadline 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)5 f- x$ }2 Z0 }" H1 @; h" M
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.
2 ?0 R' B$ Z* U$ `6 K* hThe staff must be able to:
% S) E# Y2 r( x& m' q( [ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 M4 F" Z  t1 ~( V: t) T8 B( I* P
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.
8 ]. D, N& O3 O6 x The interface should provide a menu so that the staff can:
' L* }+ h- T+ A5 O! a7 L* ha) Enter the names of the two Java program files to be compared- C1 o3 a% U. C" [9 s
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# _" B0 v" `# t7 F  Q6 [$ [** 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).
; m0 ^9 f- ?' j% n& C4 rBSA104 Business Programming – 2007: Assignment 2$ O& c) v1 i3 j# U8 t5 l
Page 2 of 5/ s) T, u0 c1 O% B
b) Print out to the screen all the lines of code that are the same
; G% o5 D3 {7 A8 S Include the name of the file and the line number of the code being printed for each of the two files
1 w- |/ m0 ~9 G) M' C) s; Ec) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
1 m5 W' x& C2 _ the name, username and department of the user
/ P  n+ H9 n. d- Y; A+ T% e, d the statistics of the comparison1 E/ \0 W4 c6 x5 B( a, _  e5 N
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! C) g. M! t; u
 the recommendation for further checking
( B) Z: w; Q' k- 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
. `' i7 R1 i5 |( [4 m the names of the two files compared
2 h. j, J2 ^. B8 p8 p# Ud) Leave the program (exit)
1 D/ D# E6 B. RThe ProgramCompare class: (Total maximum 20 marks available)
2 P* i. g' O5 J4 y( L+ ~6 F2. 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); I; t& E5 U$ w. x/ c" _6 V
a) provide an error message if the files are not found or there is a problem opening them
* Y) B5 K+ n+ N+ @4 gb) compare each line of code" P) |5 [9 s9 ~5 e  N8 F. D
c) print out the lines that are the same# D) |: K: O5 C. W+ N
d) count the number of lines compared / lines the same
8 L- P7 H0 r) q+ G5 b2 zThe AuthorisedUsers class: (Total maximum 20 marks available)
4 U% e( H8 i1 g1 v3. 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 K# B7 K0 \. q& X9 e1 n! s4 a0 ^" h/ J4. Provide methods to:
6 P0 V: l4 o) ~6 g; i$ w/ W0 c3 za) 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
5 V3 N' ^6 \# n9 l7 Jb) return the name of the authorised user
2 n) W2 S; m; i. `c) return the name of the department of the authorised user
) q: _( h4 |; z6 W$ f2 bIndividual Data (Maximum 20 marks available)
% {9 y" m7 G/ s; f5. 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 [+ g' _& b4 LDocumentation (Maximum 10 marks available), J9 Q8 Y! T) r) b! S$ P2 F
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.
: p/ C1 h5 `, E3 [' GBSA104 Business Programming – 2007: Assignment 25 H- f7 p2 a5 j$ c! m
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 Q# u  f+ k: u
不过你要翻JAVA的类库说明。你有下载没有?, z7 ?: Y: s9 M6 i/ h, f8 t8 \
查询关于对比的函数。貌似关键字是contrast,还有compare
4 e! ~- H  j: k; T3 w
) ^' k2 a5 z0 d/ B; a+ p4 t$ H6 g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ Z! R6 v" _! F痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- r3 U7 l: g. p3 `6 r7 C( q8 G可以下载到的 是 jdk-1_X_0-doc
+ F7 J' z: C+ c0 p/ U- x; f1 q
: d0 |; _0 I' e. y6 L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-25 20:27

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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