找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1335|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ a, B& j: j" d& X 3 i* z8 d' Q7 b- O' V" N: e, l; t
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( j3 n7 e' X8 W) T4 R" k& N//  ProgramCompare.java         Provided by: DRS
  b  X0 W: v7 {1 y3 V3 g//
5 e% E) p, q' k//  Program shell for Assignment 2' H* c6 j) x  {# _: Q- N
//
! }9 v& g3 M, ~8 u! Y7 l: o7 }8 u' R//  Compares two text files line by line& t- \4 q) E5 x/ j2 V
//*********************************************************************5 |5 h" O9 U6 [* {7 g$ J

! H5 j2 m9 V7 |4 k2 @import java.io.*;. \$ t9 l6 o5 S5 t- I5 }3 H
( C  X' m# a' _0 b+ `$ O+ A
public class ProgramCompare
2 Y) A3 Z6 P  }! r+ p{$ O8 v  j5 L: z
        //-----------------------------------------------------------------
6 H( e  Z+ l; f  A7 ~        // Constructor
1 ^' N& }, Y: e$ p        //-----------------------------------------------------------------
- ^, j' Z9 f( s% t        public ProgramCompare()
: A+ t; P3 a% z* e        {/ x* X% \4 z- X2 G
        }1 b7 b+ w) s* y2 s
) O" @" [. j* U  k
        //-----------------------------------------------------------------
% x+ A- j# e- {8 ?1 r) z/ g        // Method for testing that class has been reached
4 K, {1 Z# a9 O5 B# N1 x& s$ X        //-----------------------------------------------------------------        ) U' Q9 M: G- ^
1 b$ ~/ G( G1 [9 |- F) K4 Y4 y: ~
        public boolean ProgramCompareReached()        
+ i) e; T0 i0 B' J) P        {- }0 K5 o7 |0 Y( A5 d/ N! A! ?; j
      try
0 d' z( F6 i- \: i: c' `   {        
, z+ X( G& Z: S3 x& [3 T                       
6 }& v0 q' }, F, q1 j                //********************************************************************* f# {, z/ }* Y" c, Q
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 P: |9 |3 ^7 o& B1 k                // Reading the files will need to be placed inside a Try-Catch - just like this one!; |. T; K/ V& V0 @6 `
                // For more information see page 534 of the textbook2 a# R: h% g6 \4 O. c4 O
                //********************************************************************1 x7 K2 Z: I- H8 j5 j
                    
6 T% g0 y2 S4 U- v" z. g9 U        }) @8 r) G7 E; P; I, k" Y
             catch (Exception ex) // Exception caught here and message displayed to the screen
" r, @- a+ j: D2 \; y          {
: w3 y# D* r' O) _                    ex.printStackTrace (System.err);  z2 U& D" H8 C3 a, L  R: X
           System.out.println ("Error message goes here"); // Replace this error message with your own         
, B( M& w$ |0 a: J9 G" F        }  x$ R# |! b8 S0 w; v* N5 C( A8 C. ^
                return true;6 w, g. |! ]4 |3 a3 @0 Y) C; S
        }
; `" ]# V# Q9 M- Z+ ]( e2 m
% k# o& N' {# M& Q, w7 B" K} // end of class ProgramCompare
, j7 Z0 s6 g0 }: p  |/ V  f: L7 d, m3 u& G. N( L4 _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# P7 F1 O! m; \6 J+ C. N5 b//  ProgramCompareMenu.java    Provided by: DRS6 o4 w: |: ^) B; `- R2 d4 {. F
//2 h- Y  D+ S/ K( o3 K" g- I
//  Calls AuthorisedUsers.java and ProgramCompare.java
; @9 s: K$ @- n+ \7 P//& n! m2 T3 B! C$ c
//  Driver shell for Assignment 2.: d, p* b( V: v; [1 f7 U, ?2 n' A
//********************************************************************
) I2 H( t* D5 e# Z+ l: x
; l9 O! `) I( ?) f7 u. V3 Aclass ProgramCompareMenu
7 A$ R1 V: w. e$ l{4 X' {2 [4 u$ _% d% O, P
    public static void main (String[] args)
/ F& A+ n2 k/ R            {6 ?" p7 _! R& |; ~* Q5 @* C- }; T3 R# W
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 o5 q0 Z& |% n( z                ProgramCompare reached1 = new ProgramCompare(); , l+ H+ o* K! `) ~: G/ i* ?
                AuthorisedUsers reached2 = new AuthorisedUsers();       
# n( l3 m0 N* ?# E4 `                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 w) Q. x! M9 H. I5 e( d+ y' {
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        " {, U$ y8 v4 n$ E
        }
' B0 }; @" c7 c( r+ q2 Q}// end of class ProgramCompareMenu/ _. H8 Y0 e- N+ u9 g. V8 Y/ V' M
) n8 f/ j" p$ `8 h; z6 j( o5 Z1 W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; U% _* u1 @9 T% H, l; k( c//          AuthorisedUsers.java          Provided by: DRS) l# E" F3 l2 O
//                2 _, E; \5 F5 s
//         Program shell for Assignment 2
7 g9 a# w% ~5 W( [9 P* s3 ~4 j//
9 Y/ h7 G! X2 I0 Y4 m; C//         Represents facts about an AuthorisedUser/ N7 x" w, E2 Y
//********************************************************************1 M7 I) f6 b- G5 }$ L  y8 _) K1 `
: b$ ~  q$ e/ g% i& V
public class AuthorisedUsers
  J8 J1 H' k# b, Q    {* B& e- B9 x! r9 X0 N

: O! |" I4 k; K. j0 Q0 Z% R& F& W        //-----------------------------------------------------------------
2 a9 ?& P2 B1 p7 O- T4 G2 ^        // Constructor
* O4 L3 T' Q* v$ }( a        //-----------------------------------------------------------------# w2 T  K1 T: k& E9 D6 I
5 I4 }3 Q6 x; c1 P# b9 l+ T! Y9 V
        public AuthorisedUsers()8 J, j+ T- \& p' L- r, P$ d1 B
                {- l5 ^1 ~% s3 p5 q0 m, y( j% j9 h
                }& M& Q' R$ e& i6 p, }; M6 K

9 p% W9 k% h! ]1 z! }" U# d        //-----------------------------------------------------------------9 F; Y, A* U+ s* V1 k
        // Method for testing that class has been reached
- i% M5 @) J9 o7 `5 }- l9 l        //-----------------------------------------------------------------        2 [' X. l0 D3 l! f" {8 H
        public boolean AuthorisedUsersReached()1 o+ d; V$ I! E) O) u1 q8 g+ v6 L
                {
  n  B' n; ?2 C% n2 K1 G                        return true;                        3 b& A8 T, m! }) @) j0 M6 a1 y9 J5 R  y
                }. [8 W7 K; N$ y- q4 @
                % `3 E& x7 a% |! q. u0 |, Z0 R' }
    } // end of class AuthorisedUsers! [* w$ v% \( R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# Z6 M6 z6 i. _" t+ ^Shanghai - 2007
  c" Y& f& p; d1 VAssignment 29 t) r: r: T4 O" t
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 i; ]& k$ Z6 ^+ b) G0 V
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.
( K: N: ~6 e% F1 \5 u/ |The staff must be able to:: H# v2 n3 |! \5 [
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
$ t7 O4 k7 @3 ^& b7 r! G8 ^$ i$ Z4 C1. 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.
/ _! f+ C1 \1 i The interface should provide a menu so that the staff can:2 Q9 }6 K7 v; @0 l! ~4 f
a) Enter the names of the two Java program files to be compared# |7 N) J0 T# Z  A# s1 s
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 z0 W: W& r2 i2 W$ C3 ?** 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).
) o% d. j. t- U! D4 oBSA104 Business Programming – 2007: Assignment 27 `1 y! T$ k6 |3 F+ Q; X; a, g/ x  T
Page 2 of 5( `. L& n; v# v, i+ G/ S
b) Print out to the screen all the lines of code that are the same
% P; a& e. T5 ^  `: I$ \! } Include the name of the file and the line number of the code being printed for each of the two files6 [; A, {' W8 @
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
5 s+ j. v% Z+ h, L9 U the name, username and department of the user
, z; B9 o; X7 b2 T the statistics of the comparison
& o% Z% G! x7 d* ~4 V- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ D* e4 K8 O( ^" i
 the recommendation for further checking
& i/ T4 z- O/ u9 ~- 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
9 b0 u5 y' l) x% Z- R$ n9 Q% e the names of the two files compared
- _* ^/ f8 p% U2 J( J+ \d) Leave the program (exit)
" h' Y! @9 ~( C2 m5 cThe ProgramCompare class: (Total maximum 20 marks available)7 e4 E) z+ }7 [1 d& f2 z
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)& C- x0 _6 Y) H( h, Y; h& h2 l
a) provide an error message if the files are not found or there is a problem opening them
7 \- i% T) w* L' `b) compare each line of code2 `1 t0 c- o! c. W- B" O
c) print out the lines that are the same
& y+ {3 ^) I  f! u% T; E- s/ I" ~d) count the number of lines compared / lines the same6 H3 m$ C( j  o, K
The AuthorisedUsers class: (Total maximum 20 marks available)
4 A' F1 }6 d' L5 b- j3 h3. 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)
1 M6 x: s, O' \+ G# C& {4. Provide methods to:% q7 O: Z* r, X- j% k
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
1 D9 o% `% O/ L" g) x8 x! wb) return the name of the authorised user4 g: \; S7 M. G, g& d& {. c* \, y
c) return the name of the department of the authorised user- j" q5 w% ~0 t9 z
Individual Data (Maximum 20 marks available)2 y9 E& I4 Z, V( 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.
# w7 M1 g% D9 q# h1 qDocumentation (Maximum 10 marks available)/ q4 f$ L! a' J
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.+ u; L$ \) H9 l3 n( T) S; W( A* r
BSA104 Business Programming – 2007: Assignment 2+ q- H+ a' }! @' [: I" s
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
, }' Z9 }$ P" Q+ X; H' D1 n不过你要翻JAVA的类库说明。你有下载没有?4 V; e' A7 V- t8 y
查询关于对比的函数。貌似关键字是contrast,还有compare4 }0 E! `4 b; q
' W& e1 z% Y" p" @' l( n( K  V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -) C/ }$ w: X5 l! v9 X" A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ H  G# f+ _% u  w8 L7 p3 K可以下载到的 是 jdk-1_X_0-doc' D! Z0 r( X7 p
: s9 y: I2 p1 l9 G! n$ v! j1 ~
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-1 05:12

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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