找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1427|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 & G3 F2 S9 S$ [: C: r3 k# ]6 E4 b. 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 | 显示全部楼层
//*********************************************************************
$ R. h  |  e8 z4 A) c' ~//  ProgramCompare.java         Provided by: DRS
* @. u. w5 U0 B' V//, [" O$ n; p% d. @+ j# U: A
//  Program shell for Assignment 2
1 a7 M9 A; H: V# d//
& F- `" N/ c; L//  Compares two text files line by line  M" q4 Q$ U2 d) ]0 d; a- O3 Q% n
//*********************************************************************
8 E/ }* M0 G; c5 \4 Q
( O" v- e+ Q! m1 \, ]+ Oimport java.io.*;7 R9 i5 Y+ t; k; i, _8 F/ X

% ?9 M9 [2 H- H' h* E, ppublic class ProgramCompare5 i) x. ^- Y; y
{  O/ I: h3 }* V" r  L" F% e  v
        //-----------------------------------------------------------------
8 e# r* S, _, S# |, r        // Constructor  m8 o) V) b7 f* x& V) e4 h$ c
        //-----------------------------------------------------------------
! O' I9 \% _% T. M        public ProgramCompare()9 |) }8 s' H( z
        {
; ~0 |+ j% x3 C) F. y; `1 h        }
2 Z1 U; c4 L- P. f: b9 V- R+ G& G# S9 o( @" W  J: w$ |' p3 m
        //-----------------------------------------------------------------" U! W; I) s$ P
        // Method for testing that class has been reached9 l$ c/ ~6 W4 j. h( p
        //-----------------------------------------------------------------        % u1 s- t! s6 S5 S% k0 Y/ ^% a
3 T: F2 x" w7 Q  g8 b; n% Z8 ]- |, \
        public boolean ProgramCompareReached()         1 E: h: v, G, }( h+ J
        {
! ?" \0 r- h( e  ]      try
) S; K( ^% d, ~: P- F   {        
! f3 z  @" O, G9 d( y4 P: V! r                        * J4 G2 q) c% L: |  ^$ Z; ^
                //********************************************************************
% H0 R  S) U2 O5 F7 l                // Try-Catch Statement is used to handle exceptions - such as file not found
4 U# }2 x" y# N1 F% ~" G                // Reading the files will need to be placed inside a Try-Catch - just like this one!* c# S& Z" X9 Q. D
                // For more information see page 534 of the textbook
6 l- c& `; E- N4 i& @                //********************************************************************
0 I/ h% k' b& J! `. s5 Z                    
, ]- B0 Q2 Q/ E: I: X        }
2 W: z  y. @; O! Y8 E             catch (Exception ex) // Exception caught here and message displayed to the screen 5 Y' c: F. S6 }7 d
          {
: g2 o( K3 v* h8 ~                    ex.printStackTrace (System.err);
- V, o* s8 Z. J9 ^4 o           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 j1 |4 g& D8 q( p0 \$ T# y        }# W& ]& I* U6 ]7 b" u' b
                return true;; Z6 I* ~. ?0 [; t/ o, |
        }
! h$ j$ _9 C- f7 M0 K! }9 F/ v& \/ X1 K4 z
} // end of class ProgramCompare
3 X- k6 z  G9 n/ q
* O& C% w' Z0 ?( a! B: |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
  v" V, [( j! x3 _//  ProgramCompareMenu.java    Provided by: DRS
( J4 d  f. @# D) \, T, R% G//8 e( o/ R) f2 J$ h  E, E- l
//  Calls AuthorisedUsers.java and ProgramCompare.java
9 X2 m, R  @1 Z% b//
& D/ s/ ]9 x/ _* m, g8 ?& q( j+ s//  Driver shell for Assignment 2.
  s* a- y4 I) E//********************************************************************7 T; M+ e; e  {! l

( I$ y/ r. t2 C8 _class ProgramCompareMenu
3 C8 B1 N: q6 D! ?4 r6 y2 l, r9 W: m' n{
( b% L; j) `/ W1 c% w    public static void main (String[] args)3 r7 ~. p$ Z5 f+ ]
            {3 Y" b# C6 a' N) m! \
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; J* f. x9 v2 Y
                ProgramCompare reached1 = new ProgramCompare();
4 e+ k3 v2 s7 u, Y# P4 ?3 y  C                AuthorisedUsers reached2 = new AuthorisedUsers();       
" ]: s9 q( v" _; p3 @                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
- f; J+ z: ]5 Z  E                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & s/ c3 j' q" `+ E! y0 `% `3 y6 n
        }
7 Q  \: S% c( F2 l}// end of class ProgramCompareMenu
" s% n+ m4 b3 Z. R6 o
" P# I, x1 L# Z  w8 J9 t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 g$ D3 K0 h* Y) b' V2 h7 r//          AuthorisedUsers.java          Provided by: DRS
, F/ B8 u" C% ]. J- v  a//                / a. |% C% h* O( e. f& J4 D
//         Program shell for Assignment 2% u% \  `5 Q6 x6 m
//" r& _) |% G4 F4 v
//         Represents facts about an AuthorisedUser
' O( k9 x$ `+ i3 Y$ f//********************************************************************# e% K4 T) }! f$ B% _
5 W1 I# l: n4 c' M& t
public class AuthorisedUsers3 x! q$ |0 g  D8 p6 g
    {9 P3 D9 }! U8 U" n& e5 |
- \: J: n5 O) w9 u( Z
        //-----------------------------------------------------------------
6 P1 e" l/ `# O, e& f" d2 H        // Constructor
% p% ~/ v5 S) k" X, ?+ X2 v        //-----------------------------------------------------------------
/ }8 |3 D% `* N
& N/ S: P8 y5 u# e) P0 p9 t8 t7 P7 r        public AuthorisedUsers()  B. }2 s2 e% `7 ^7 j
                {$ J" m" I8 c3 s8 ]1 |
                }
- c/ G8 D( G, i! p" g
7 V% m3 F0 W: ?" q9 z8 z4 T, w2 U        //-----------------------------------------------------------------( {0 W5 v# v' F" U: W0 Y
        // Method for testing that class has been reached
% N# x7 U. c# n+ w  S- W8 f# T        //-----------------------------------------------------------------        8 i; F2 ^' K# {+ F4 |9 d; H
        public boolean AuthorisedUsersReached()! J* f# K& t! @2 w3 P. F. s
                {
: \0 [9 N/ ]5 P# w                        return true;                        2 f0 H) W- B0 v
                }
' d8 u' }: L, P! A               
) M* y9 w0 d, H1 ~    } // end of class AuthorisedUsers
) Y# @/ _& c: S- m/ b9 N8 h2 I: Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming( i( U% D* P( U5 F2 X1 ?
Shanghai - 2007
& f! @9 Q+ |6 }- EAssignment 2
; J6 b; j* {) HDeadline 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)# `0 r0 a  F: F2 p4 {0 g! ^/ E
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 A: O" S$ {! ^/ C7 C2 Q" wThe staff must be able to:2 W) a9 u7 d/ U: W7 R) x5 a
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 I8 r' b, N) a6 B
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.
4 e, X' ^- `, X1 \$ { The interface should provide a menu so that the staff can:
& @, O/ ^0 N- U1 ]# e4 Ca) Enter the names of the two Java program files to be compared. _; n$ H4 D$ ?' Z. a" u! o
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  ~# r# k: x+ V1 I1 U$ u
** 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).( g; ^: `8 O0 X6 `; h2 s
BSA104 Business Programming – 2007: Assignment 2
8 d2 f0 U: p' m! _( oPage 2 of 5
1 A7 {1 Q, J" e+ |& |5 zb) Print out to the screen all the lines of code that are the same
( s+ {0 X7 K0 ~* m  v1 w# I Include the name of the file and the line number of the code being printed for each of the two files
/ K4 F, k, H6 W; _c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" R& k1 N7 u9 T+ ]7 t% R( E. d% h) i# j
 the name, username and department of the user2 g7 ^, D& K9 d) U
 the statistics of the comparison
5 V" R5 V" {& p$ Z- s- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: V3 u! P- F$ k& @1 r, ~
 the recommendation for further checking
4 y! k# y8 K5 \0 U/ |- {- 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 closely0 ?, K& E  I6 S, q4 E. D' F
 the names of the two files compared
. h% ~6 ~/ ^$ l7 }d) Leave the program (exit): [+ h3 g3 c# c: m% _1 _
The ProgramCompare class: (Total maximum 20 marks available)3 Y$ T' W4 k8 t0 |
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): j" G0 G' G+ u9 f! O; {5 M5 V
a) provide an error message if the files are not found or there is a problem opening them
, H  P2 I. o8 n$ `0 d8 v: H, qb) compare each line of code- y2 F- r6 _% c8 x( g& @$ Z
c) print out the lines that are the same4 l8 d- {" }6 U
d) count the number of lines compared / lines the same
6 M. R0 Z2 R5 K) C7 W$ c* nThe AuthorisedUsers class: (Total maximum 20 marks available)8 t3 x6 i/ Z% c2 x/ \# 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)& ?3 G( ]$ N5 D
4. Provide methods to:5 b7 G0 [  u! P1 v
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
( K2 I6 `0 B6 h* w! A- m# kb) return the name of the authorised user
8 B% k3 u  I: N* X" D% j- dc) return the name of the department of the authorised user
' s  O' y9 d; B5 A- \" DIndividual Data (Maximum 20 marks available)# D0 S6 `5 B7 W
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.; c4 J- V, P& U5 o
Documentation (Maximum 10 marks available)
' M& ^4 I" t+ F% v7 K3 ]7 q5 z6. 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.5 X, ]% M& A1 }. D+ s1 d
BSA104 Business Programming – 2007: Assignment 2
! e& ^& [  g8 c0 E8 Z, K. {Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 ^) i' n0 R. v' w. Y' ~
不过你要翻JAVA的类库说明。你有下载没有?& [! V! x/ K& P3 P( [5 \
查询关于对比的函数。貌似关键字是contrast,还有compare
$ Q- m, g3 W# d0 F0 H
1 V  v/ {$ ]' _; \" b/ ~3 I( S[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  h  Z. ~3 s5 k6 p
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。7 \" R( I8 X. L* u- v" F
可以下载到的 是 jdk-1_X_0-doc
/ T/ z* l( |. d7 g# c; _% [
% u: {1 P" [* f' T8 W. @& L, o( U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-1 07:45

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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