找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1849|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& a3 D! u X4 | ; g" L) z1 c x% s/ y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************$ ^8 h) t; t: ^* e, c" v7 s+ [
//  ProgramCompare.java         Provided by: DRS
  l; D  f; f0 e% Y7 ^. s2 w//& Y) m  F$ Y! z. l* v$ v+ x
//  Program shell for Assignment 2& R3 r( O, g4 m3 ]
//% ^7 {% r9 ^( Q3 k6 C" D
//  Compares two text files line by line# e/ t/ e! V# c6 M
//*********************************************************************% e* X# H. g2 [8 V' D1 a
! D8 H, h: q, E" a( l! T
import java.io.*;7 C0 w7 v% {5 G# J; o6 l

! j7 {! f/ Z/ a) Z5 U3 ^/ T# Epublic class ProgramCompare
9 \3 \0 C- F" O* T4 f2 ]{
5 n1 b2 D1 f' \# ~        //-----------------------------------------------------------------
1 j, ^% n  C1 b& @* e        // Constructor
8 D8 I3 y) D2 p" H9 |        //-----------------------------------------------------------------
' b0 v1 l, T9 C7 ?9 r        public ProgramCompare()
" U4 E6 |$ L- z% k; E! J        {) S+ e/ T4 d0 u9 h( k! \5 d2 U
        }
! V. x( Q5 @- K) j% f6 s* W1 L8 w+ L# _
        //-----------------------------------------------------------------
* x1 X1 @0 [9 ^6 e; V, z# z) G        // Method for testing that class has been reached2 z8 [3 o' d7 s* s
        //-----------------------------------------------------------------       
; B* b; H$ b0 V7 S0 [
) M$ G7 l) y- }: [6 N2 G+ j        public boolean ProgramCompareReached()         7 }7 O2 a2 P3 j. D, P; G* E
        {2 l7 M, |+ H2 B' d( h
      try
3 \: ]" |* O' ]   {         1 U: Q7 C$ B7 z! _/ t4 {% S" y5 b
                       
5 q( E/ N' E8 P2 |8 x# C" P7 Q                //********************************************************************2 L/ M1 H" O4 v$ g7 r$ w% ]* W0 [
                // Try-Catch Statement is used to handle exceptions - such as file not found
8 o/ F' `& @( l5 O5 d: I                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ d+ b& g, u% h+ @, z1 ^* ]* u                // For more information see page 534 of the textbook
/ ]8 @$ M  v, B/ U- K: V* L5 C                //********************************************************************
7 V+ ?) ]# L* a7 e2 R5 H7 J                     * i. x) X6 H0 A( x- F! Y
        }: W4 R- ?( c- m; g, H& Z8 S
             catch (Exception ex) // Exception caught here and message displayed to the screen   H; ]) g' i6 Z3 i. J
          {
8 F2 n) e6 z, U4 w                    ex.printStackTrace (System.err);
1 u* u6 |& {* [4 ^, k( i           System.out.println ("Error message goes here"); // Replace this error message with your own         
) L8 _$ p3 c6 ^        }
  z5 U! m  D: m* z% f# m                return true;
2 [/ |* K% u* t9 `        }
! U, h0 S9 u( ~  i" r% V/ [4 M
. p( `% V/ V% x* \# f, U# X; R} // end of class ProgramCompare6 D. d" w% B1 e
& Y1 d$ \0 h& z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ s" `- X! j1 v//  ProgramCompareMenu.java    Provided by: DRS3 k2 W5 C' U' s- d- D
//
# U  K2 D5 P4 p9 E9 _//  Calls AuthorisedUsers.java and ProgramCompare.java  a" J* l5 P0 D
//# ~  g2 T# F- v4 b$ d5 e
//  Driver shell for Assignment 2.( g5 K4 h2 ^1 p9 i, A+ n* O
//********************************************************************
3 G- T6 `# R2 a9 E/ f$ U
( a+ e- _7 F0 G9 D1 ?/ a5 Y) |7 H5 Vclass ProgramCompareMenu
! Z4 _) {0 A$ P% Q{' ^$ M" ~$ L9 T" z( E# E7 V
    public static void main (String[] args)2 r* o: p. y: s
            {
' F6 l2 R; q- ]" c: _! Z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
$ ~! j" d8 X( L3 t+ D& C                ProgramCompare reached1 = new ProgramCompare();
) I* e; @  k; }8 m8 r                AuthorisedUsers reached2 = new AuthorisedUsers();       
: p1 a1 j$ t# x                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 r( a" y  Y( i- n; @
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ i* S% N0 o, e
        }" Y0 Z$ c' }  c0 N% V
}// end of class ProgramCompareMenu
8 o& i: s% `( @* b: }' D5 j: Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************% h( d; ~  s% @! j: C8 d4 l
//          AuthorisedUsers.java          Provided by: DRS. v8 Q; m! O: _9 V& Z! N- W
//                ; z$ C/ E9 j. `! n! ^
//         Program shell for Assignment 2
/ N( t* J! ]3 T  v0 a/ M//7 B/ n0 [8 h$ D. L
//         Represents facts about an AuthorisedUser
- ~( m- H6 Q+ K0 o//********************************************************************5 @# U( [# R8 |0 [# g! u
! j0 Y: \6 k$ R& K& b
public class AuthorisedUsers
8 w" {2 j* c* a0 w    {
, S5 W) F& W3 ^
# \8 Z: k; {. O$ E        //-----------------------------------------------------------------
  U; a6 z- v, S" W3 J* }% X/ R# s        // Constructor) c( v/ U/ s2 _( |/ o& f- W. D5 g
        //-----------------------------------------------------------------
7 b' O/ h! f6 i1 V' b) i# n. X$ }# ^. m5 \/ N# \6 c* ^3 R4 a! e
        public AuthorisedUsers()
$ R# _2 s+ A) U, L2 s                {
4 b" [. E; L# V% f( [                }6 x$ T6 R) Y' {8 t. C, B

7 T/ x9 q" G5 d        //-----------------------------------------------------------------0 V* K$ I( X6 ^' D  |: _8 I
        // Method for testing that class has been reached
0 Y8 V* ^- J; H! M9 N4 g5 o        //-----------------------------------------------------------------        0 O! d' B- D+ U6 K3 n; U
        public boolean AuthorisedUsersReached()
2 d3 a* ?& Y# ?/ Y3 i. _( J3 G                {# I5 i& ]. J% G# i/ E" k
                        return true;                        + v* G) f- h1 `% \7 m; g
                }# i: q3 b9 f* n4 z4 h7 V% G" W  k
                : H" f/ h- A6 S! G/ U0 y
    } // end of class AuthorisedUsers
( z) [/ [* \6 Y7 D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 B3 |8 \; J! V  u: k9 ^+ Q. KShanghai - 20073 b( K0 V; y- I, d5 F' D. w7 v
Assignment 2" D7 A/ u2 A5 y9 Y+ p% a5 D
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 f" B9 H' F9 o. S5 Y: a3 y2 x1. 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.
) _5 J4 L; `7 S! g! _. C! gThe staff must be able to:
" X! n6 [4 C- r, p3 U Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. S2 {. c5 B! t+ B. S, j4 S9 G
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.
! ^) Z9 _$ e- p: y$ O) X The interface should provide a menu so that the staff can:$ W! I2 A2 d3 }3 g& y% f  i7 D& B& a
a) Enter the names of the two Java program files to be compared
' O3 {+ M7 D" n6 \) c: Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! h# l! [& o+ h2 |0 S$ I* t
** 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).
' h0 \, ~; {3 G% g0 H+ nBSA104 Business Programming – 2007: Assignment 2
$ b2 V. F0 [7 J' k( M: TPage 2 of 5" [7 L7 Z8 W7 `$ u, A; F
b) Print out to the screen all the lines of code that are the same  N5 \3 `2 z- b" j& ]1 ^/ H2 m# o' n
 Include the name of the file and the line number of the code being printed for each of the two files
2 [/ b/ A4 c( E% Mc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 z* ]2 Z& O( ]3 b2 \/ D
 the name, username and department of the user
  m1 s( T( a! `+ X4 J( l# j the statistics of the comparison
7 Q9 u) N$ J& N; [( {3 u- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 z5 ^; g2 W& ?( c2 R% B/ |4 B- H
 the recommendation for further checking) R* ?8 E' d! I4 n# q$ T
- 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
. b! Z" k, s$ ]( h: g6 E the names of the two files compared: T  M& c- g# |" H% g7 C- E
d) Leave the program (exit)7 m+ ?0 m6 _* ?+ K4 y; i, S
The ProgramCompare class: (Total maximum 20 marks available)
" u+ v8 }2 c0 D/ J4 N" Q3 d: ^6 Q2. 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)
% M7 [' l: O' A2 Z( w7 k1 da) provide an error message if the files are not found or there is a problem opening them
2 f1 U5 b5 J+ j3 k3 w' p! P- `* kb) compare each line of code  r) ^7 `& [; w3 t+ ^
c) print out the lines that are the same
/ l- `. ]' Q! t- {6 h) Z  ^d) count the number of lines compared / lines the same
8 B6 X8 W4 ?- g. T5 u( A6 vThe AuthorisedUsers class: (Total maximum 20 marks available)
; S7 }: |" `9 b# L! t3. 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)
/ c& P1 f- n, s9 H- U3 B4. Provide methods to:
! q  g+ c- k" v/ ]: a6 ja) 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, L7 \$ f5 T; E: b1 _$ B  \
b) return the name of the authorised user; J! e" H: ~" I$ r
c) return the name of the department of the authorised user
# u8 ~1 |0 u. E8 l/ K8 n& J: x0 e5 |7 {Individual Data (Maximum 20 marks available)
/ }5 Z( _# |! ~7 v2 c1 ?% t5 Q5. 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.+ g9 Z& s' D8 |- B2 X" u
Documentation (Maximum 10 marks available)
( @4 {0 D2 H7 f* k6 x+ 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.0 Z5 ?7 |2 y0 U
BSA104 Business Programming – 2007: Assignment 2+ {2 I9 E7 O) p$ y6 A
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: O6 ?3 B1 T6 h& S. J
不过你要翻JAVA的类库说明。你有下载没有?
2 y* K  t- S+ u! m  `5 Z查询关于对比的函数。貌似关键字是contrast,还有compare
7 p2 G8 H. Y6 q$ D
( z, @; Y9 `8 S[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" l3 p8 \! }& l6 n5 k
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: Z' A# I& e2 k- c1 Y0 B0 k可以下载到的 是 jdk-1_X_0-doc$ F5 X! v( t, V' C7 p3 G6 O, P

' A% c7 B# \; ?; t[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-21 18:46

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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