找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1751|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" c6 o8 V5 R( ~* T* t - s: d" Y5 m$ N( R0 \! 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 | 显示全部楼层
//*********************************************************************
0 ]2 g- A1 P5 M6 {* H//  ProgramCompare.java         Provided by: DRS
4 U. O8 t2 W; B# U//6 o" x' Y% ^9 d. c. n3 z
//  Program shell for Assignment 2
2 @! F) a4 O& a: Y- }8 J//, i6 |/ C1 A* k* N, Z& m
//  Compares two text files line by line
, f/ B9 f$ P7 U' H/ w) C//*********************************************************************
; N1 _( U5 `& i& e; T9 A$ ?  O& s6 p, n, R/ `/ _+ ~
import java.io.*;" s' n1 V4 l/ k, L/ v
6 D; Y5 O7 E& I4 r/ b" Y
public class ProgramCompare
$ l6 [. J9 x; ^/ v{
, Z1 R! Z( Y3 V' m1 E, [        //-----------------------------------------------------------------  s- A0 N3 V- n' m& f$ I4 @
        // Constructor- h2 x1 t6 \9 \) D& y6 ^
        //-----------------------------------------------------------------/ N' K% C, O# z" W& H
        public ProgramCompare()2 h" z# r& i9 u" K# A/ U
        {
1 M* l+ l8 Z; N6 w$ S& ?        }6 V- C0 G. f7 I6 x5 ?
  G  ]. {: B9 V6 X. D
        //-----------------------------------------------------------------0 D3 C. F4 B$ ^8 C4 [
        // Method for testing that class has been reached/ B9 j: e5 D* A
        //-----------------------------------------------------------------       
9 O8 l$ Z# w! t( g! `: \3 A" T
( n3 Y$ Y7 x3 H' D        public boolean ProgramCompareReached()         # ]$ o& m- Q4 O; ~. n/ n
        {
+ C& o! L$ b1 i% ?      try . E, E5 K( N3 V5 B
   {        
5 Z# Q' B, Z: A+ g6 u2 S% n                       
0 A, K0 S# n+ O8 q" G" u                //********************************************************************3 p0 u" |  X) ?6 e
                // Try-Catch Statement is used to handle exceptions - such as file not found
, A. ]& l! q9 N* b0 [3 Z                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 S: Q" Y) J0 ?. x# ?7 E5 x# r                // For more information see page 534 of the textbook6 G* ?- G) B8 {, _
                //********************************************************************, `. v1 j* ]4 e3 y9 n5 J) Q" j& [
                    
9 M. u5 [2 v% x3 }( c) k        }7 ^& ]8 @% ~' U6 k6 k/ M2 D
             catch (Exception ex) // Exception caught here and message displayed to the screen
5 L9 V4 e) ]( {. a% P) {          {+ r+ R$ ~9 n, _( }7 ]" R
                    ex.printStackTrace (System.err);9 ~. W# c  y+ G7 y! S
           System.out.println ("Error message goes here"); // Replace this error message with your own         
) S' u6 k! Y: Z' W4 |        }
4 b4 r! m, Q( \; k* I' j                return true;2 u) w$ M* O5 d0 C7 Y
        }! p  t" @5 i, c  w
( o* p' F. ^$ R( i. d
} // end of class ProgramCompare* }% }0 R, E1 C( L+ x" S( W
) F8 p% T" M; H: }: q/ ^) ]2 h2 N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" Q2 M8 K5 K# |6 F9 G1 [
//  ProgramCompareMenu.java    Provided by: DRS3 q: @7 r6 @* O
//% m. Q8 b) U! I  a1 e4 _6 k
//  Calls AuthorisedUsers.java and ProgramCompare.java
: g7 Z! T, o! x% i7 {  k; b//
: P& p1 X. M3 Q! }//  Driver shell for Assignment 2.
) l8 W; U4 t- P2 ~# U5 Q//********************************************************************# O5 m5 x) p/ L, S2 f# `
; ~% [; Z, r6 f' a
class ProgramCompareMenu( _- `# H6 t) ]# s. e" u6 c; n3 ^
{" {9 ?4 r, X0 U+ \8 \& C
    public static void main (String[] args)1 Y) A) V/ R% e) y& g! x3 q1 t+ H3 u
            {; ]2 D: V- p" L; g- \1 T0 t
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& ~0 J, g8 Z& R' e
                ProgramCompare reached1 = new ProgramCompare(); ( o% V$ {) B9 O
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 F3 Z5 e! ~& z7 [% p9 W                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
8 M  ?# G5 |1 l, Y: ?2 v                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          d; M2 ^9 d6 L. e1 ^* d, J
        }
% |$ z0 V6 l# s4 E0 {}// end of class ProgramCompareMenu  Z( f- y" X6 w9 i, d& J

9 M& C: d3 L; Y) x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. D+ O3 q/ `, ?& ^//          AuthorisedUsers.java          Provided by: DRS  E7 A5 c4 @, d7 D: t+ f- d) J* ~- K
//                ) \9 J" s, e% V1 l. h7 `1 w5 [
//         Program shell for Assignment 2
" A6 ~6 F/ Z' W! c# i//$ A, z+ d$ l, d3 s0 v8 a
//         Represents facts about an AuthorisedUser. K% R( E% c& Y
//********************************************************************4 y& O* P5 _% ]
  _. r2 d1 r5 P. V; _) Q
public class AuthorisedUsers
, w/ G: z! s  x' P/ K0 t    {
) V1 ~' {$ E+ O9 S0 w; y) M' a* Q0 p8 w  a. U: ?0 `" W
        //-----------------------------------------------------------------
0 Z! P- T; R9 F7 e2 m1 F) w        // Constructor2 j, G. j4 z0 H- f- h! _, B
        //-----------------------------------------------------------------
9 p' K+ g2 ^% I- L$ U+ T; i4 Q- x- H3 d- F# J% Q
        public AuthorisedUsers()
, H* P+ g4 T( S# ^# @                {
. ^6 J. b# O1 c( D                }
' f2 o& l0 Z- L4 _$ E
, o' z" G% A4 T0 q0 z* C2 z1 R0 n        //-----------------------------------------------------------------
$ T+ |+ t7 K8 ]$ U: r  G        // Method for testing that class has been reached
+ k+ I9 K. m: ]: \        //-----------------------------------------------------------------       
# t: S4 r) s  v% O2 F' g  ?% Q7 c* Y) F        public boolean AuthorisedUsersReached()
+ q7 q' z& e2 e/ D0 k& Y4 ]' z) G                {0 j& f; f6 b  Q/ V- n
                        return true;                        & K' X" y$ @' u+ s
                }
0 K" M9 F1 y# @2 z: z0 Z               
% M1 Q3 B. _% y, i    } // end of class AuthorisedUsers
- v* G) C/ R! n! e$ j1 B" \+ h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" p5 ?9 s' a  @" lShanghai - 2007# J$ q' q3 S. Q- y& |5 ^* q
Assignment 2
( Y- y1 ?  J3 ^- @& N9 pDeadline 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)
+ Y* w( |+ q3 i8 n1. 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 n% w) V2 C3 G( K# B8 @9 I
The staff must be able to:
% D2 n# s' M6 \+ C, G; V. ^ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# O' E! q+ W+ G/ a5 h' H1. 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.; q9 k2 V" F, ~8 J. |7 X
 The interface should provide a menu so that the staff can:
# M) O/ D! [! La) Enter the names of the two Java program files to be compared
# N7 n, O. i1 R For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' v) K* G$ }$ f
** 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 J& n. D7 c& V, F/ @5 ~: Y
BSA104 Business Programming – 2007: Assignment 2  o: ]: H  ~% Y; U: V) {, L8 q
Page 2 of 5
; ^. q( E6 n# ^. z% F! Pb) Print out to the screen all the lines of code that are the same* N8 [- F7 M3 F7 |$ W0 j
 Include the name of the file and the line number of the code being printed for each of the two files
( g4 }( Y: O5 N. I% \8 pc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% \, v: Y; @$ g2 y
 the name, username and department of the user
' c+ J& M! O+ M. f$ c the statistics of the comparison
1 s+ O3 }5 k' s0 Z  R7 _- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" Y9 H2 ~9 U; ^$ ]
 the recommendation for further checking) z& @% J3 B$ N* e, 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 closely6 r% g' {: X+ r, q; P
 the names of the two files compared0 Z6 y3 B9 X" t. A  ^6 s: G3 g, d
d) Leave the program (exit)& p6 e5 K2 I! N+ i8 K2 `( c
The ProgramCompare class: (Total maximum 20 marks available)
! }* q: ^# ]  [5 `' J2. 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)
7 Y4 g4 r  I6 }. u, g2 R5 k+ l+ Qa) provide an error message if the files are not found or there is a problem opening them$ ~: e5 a. `4 u, n) J8 F) }
b) compare each line of code
& W% t, X  R: ^$ O) r! X9 jc) print out the lines that are the same9 ~# u& F! k8 y' B
d) count the number of lines compared / lines the same
" ~9 V. {$ Q- P  YThe AuthorisedUsers class: (Total maximum 20 marks available)
- [: E3 V* o9 R3 V; 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)9 ], w  T3 A2 m* v
4. Provide methods to:. Y( U5 [: B: O2 w% z
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, N) e: A# ~- E+ n' H0 Y$ e
b) return the name of the authorised user4 k; z* I  s; e5 ~
c) return the name of the department of the authorised user& E4 m6 g$ E; C) O& Y0 f0 L
Individual Data (Maximum 20 marks available)6 B/ u1 `0 K" z3 G7 s' n. U
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.: l. N& x$ X; \% m
Documentation (Maximum 10 marks available)
- S  H6 f4 ]" `! u7 `* x9 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.
3 m/ s' Y* M* a" A5 }- }& hBSA104 Business Programming – 2007: Assignment 2; Z" \9 x$ @, E4 z
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 D. q: `: P9 N+ N不过你要翻JAVA的类库说明。你有下载没有?* i" }3 M3 j5 g
查询关于对比的函数。貌似关键字是contrast,还有compare2 W& Q+ M/ i- j; @3 t+ E; f
. u: S/ i3 {* g% U
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: h% |$ {. w1 S+ A痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
( `8 c; l+ s7 o6 L+ n- M! v可以下载到的 是 jdk-1_X_0-doc
. t5 s7 O* T5 I" q5 r* p9 z* c& D: J4 d2 {7 @6 F: U1 v  h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-23 18:36

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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