找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1217|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 7 M( L8 f: h/ [8 F# y: _6 z! j- N: }5 P
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
2 L7 F3 [4 U7 d$ e) n" O0 J//  ProgramCompare.java         Provided by: DRS" r" x1 \- [1 S' O6 r
//  a6 l5 m. c6 Z' Y: W6 G5 @
//  Program shell for Assignment 2+ j4 o' E% f2 ]  \6 A
//
0 M4 R2 f/ V/ W( p' a6 `, ~, b//  Compares two text files line by line
* e. M8 M! n+ _  f$ @/ }# J//*********************************************************************
) G8 t" q, x' i: b, ?' p, p3 e! [: Q: e4 ^) T  }, ~2 [
import java.io.*;" Y6 o; h9 D1 z& C
' z; {# q% W( Y
public class ProgramCompare
8 f; L. Q4 s! O: d{
9 r! J" E1 D  A0 M        //-----------------------------------------------------------------3 _; m2 c# p& s1 }' I
        // Constructor
4 r' p% a# c7 e* a4 m        //-----------------------------------------------------------------
; r. v( ]; \6 O" J. y4 i; L        public ProgramCompare()- |8 w! S+ j/ K9 h
        {5 E6 j/ n3 }/ i7 M
        }
/ C. N3 N( `6 v3 `/ Q/ _% z( m7 F  E
        //-----------------------------------------------------------------
) V! |, O+ }3 a- e, o; X2 c0 Y        // Method for testing that class has been reached
+ f5 a6 h2 r$ D/ c: j2 x9 o* q        //-----------------------------------------------------------------        / F& l5 S/ C. c& Y: }1 Q; B/ j

- u6 T8 I- p% _+ `" i* K        public boolean ProgramCompareReached()         2 ]8 ]! \/ g; l( b* D
        {
2 u. P) i" k3 s5 a; ]' U8 |+ q      try
' A$ {3 X+ [+ g9 U7 \% ^   {         # d5 V# l: w8 Q# _! G6 T5 z2 Y0 C
                       
7 ], e% g, C; a5 G! g' k7 s4 Y6 R                //********************************************************************
7 U- \$ g! h3 l6 D, \3 s3 m8 D                // Try-Catch Statement is used to handle exceptions - such as file not found - P+ U3 E+ t; G" i: z/ G6 r% {: G1 ~
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
7 N) x* w* u+ d                // For more information see page 534 of the textbook  x" u- G! k" K+ k4 f5 m# `
                //********************************************************************( G5 q, S, ?2 n  j4 o
                    
5 v, b) j. {$ s7 }9 o9 X. z        }' x. Z8 K; a$ Q& o
             catch (Exception ex) // Exception caught here and message displayed to the screen
/ i' P" d- o) c1 y+ U4 G          {$ i2 z  l+ ?- a9 L9 [# i
                    ex.printStackTrace (System.err);6 y' _- H% M3 B2 Z" I) [
           System.out.println ("Error message goes here"); // Replace this error message with your own         
+ L  L! i! y7 Q- V. g- d        }5 p/ D. V4 T- S& a) ~3 k' v: q8 |
                return true;
8 }8 ]* U  D/ s$ [' H+ ]        }
6 l" W/ R0 {6 E+ {
# U# ^4 z: g' w4 e} // end of class ProgramCompare* g1 R* s+ \* E6 D/ Y

  M" F+ u4 m% z* o, A: O1 S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, R4 ]/ m+ ~' O! d1 E
//  ProgramCompareMenu.java    Provided by: DRS
5 A% ?( N) F/ y! M3 w) a8 \//
4 z) p& i3 V: S- m+ l% G//  Calls AuthorisedUsers.java and ProgramCompare.java
: C* Y0 b  j& S4 `  U//2 v3 }6 c0 U5 ~! `. ~, b& ~
//  Driver shell for Assignment 2.
& Q4 y# e! E* s+ U5 ~//********************************************************************
. o: ]& @; ?8 a4 y
- m$ P# B. v) F1 _class ProgramCompareMenu
5 p; b+ u- W8 I' |8 O) ~{! [8 U. L2 L, r4 b
    public static void main (String[] args)) L# h* O6 U" x
            {) B( }, e+ H" Q# d0 r8 G
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! P/ i+ J- o+ K1 _" b) s
                ProgramCompare reached1 = new ProgramCompare(); ) z/ B8 Q% j  S! c* t! j
                AuthorisedUsers reached2 = new AuthorisedUsers();        4 f, s& e# n! s- b4 Q+ Y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# ?2 K3 Y' b. u- h' a" l4 u                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( n' Q( r7 e- _& ?$ h$ `3 b7 f        }7 I; F" S4 v' l  \# g
}// end of class ProgramCompareMenu
% r# B  J! m4 G/ ?5 }4 A9 H0 D! n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 Y- e$ T  h1 S//          AuthorisedUsers.java          Provided by: DRS
$ e8 @+ y) `# f- k8 s//                : {+ F- X1 U2 j1 L: l  M
//         Program shell for Assignment 2
! C( ^2 l5 c0 G/ l3 X//
8 C4 l3 q- u# L  B5 j) b8 o1 s2 t$ }//         Represents facts about an AuthorisedUser
% Z9 k0 X  A3 n- Z//********************************************************************0 i" x: ~2 I# d# M
$ v- i, U! K! ?, V, M, y$ b! l
public class AuthorisedUsers2 f1 O5 O; r% n: y; ~) X' W5 B
    {. H  J, \; h) G+ ~: {' Z
9 D8 Q1 }& |) |3 M2 w0 l
        //-----------------------------------------------------------------
. |( y: U8 r5 T) g        // Constructor
* R( Z9 ~! R; i: n" U" [7 t* C  c        //-----------------------------------------------------------------
8 C/ t" M1 e* {  p' v
! l0 E$ a$ v; k3 u; l        public AuthorisedUsers(): l$ h2 ?$ e3 }7 R) W8 \
                {2 P/ X: k: t; O$ p7 g0 Q2 f( H
                }
, j& Q8 W0 D; v; t( J6 p. r8 L5 N! L% h- D; B! L2 |
        //-----------------------------------------------------------------+ l7 F; \% h; I( O' W
        // Method for testing that class has been reached5 |; v5 t- k8 B0 U0 w( S5 [/ P
        //-----------------------------------------------------------------       
- a, z  F$ s. M$ [& v( v+ C) G/ i        public boolean AuthorisedUsersReached()
% i0 O. ]4 }1 g/ M0 G, Z                {
3 ]- E$ C5 g5 M; o: k$ u: \5 {9 c                        return true;                        ) _' l' u+ b2 n5 S
                }5 H" C( ]3 O! j( x, `
                5 o: ]& a$ g. q; L2 X; O6 o& ^2 q6 [
    } // end of class AuthorisedUsers+ ~+ r; N3 R$ [) d; Y% I0 `0 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming6 f& |7 c& V* D
Shanghai - 2007
- E# a* j1 [7 s4 A; eAssignment 2' J/ r5 ~, ]) W& E. S& j
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)( \' N& D1 S* j# O0 N7 b& p9 n9 _7 ~
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.# Z) z& B3 C) w( Q( P
The staff must be able to:
; @3 g. {8 d$ A( b" M4 d3 o Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, h& X1 t, Q- D1. 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.
' Y. I/ Z. t4 r% o The interface should provide a menu so that the staff can:0 |/ r7 u( [. }( }: X! g  Y3 U
a) Enter the names of the two Java program files to be compared8 }) f! }5 |+ U% v
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- {4 o5 l# j3 p+ q" Y' q/ L
** 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).
9 `; _% p6 @- Q! ?BSA104 Business Programming – 2007: Assignment 2
, i9 e$ F6 Q! o% y  APage 2 of 5+ T% Y. S8 L! a7 z- g! a5 w# R! ~
b) Print out to the screen all the lines of code that are the same$ r, z& m' e" h/ H. z5 s/ I
 Include the name of the file and the line number of the code being printed for each of the two files- U6 H$ X- l0 C7 U) Q2 p
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* R1 r& e8 Z! |/ N/ v the name, username and department of the user
2 g; P+ U3 h6 a+ w" _8 W8 o9 T the statistics of the comparison# z: Z* e2 K( G: E7 E
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different9 k  |6 U4 D( d6 L8 B; j
 the recommendation for further checking
! t7 r$ S8 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
: o  H- J3 z/ D& p' E the names of the two files compared+ z/ d% K6 n# u  G$ N5 w" I$ E& \
d) Leave the program (exit)
5 }5 A$ I% S! X; zThe ProgramCompare class: (Total maximum 20 marks available)7 u+ O0 q. C; k  Q- p) t+ |
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)
5 n7 L+ M* z, k$ F1 ?a) provide an error message if the files are not found or there is a problem opening them; Q* t6 b2 L4 |7 T9 M
b) compare each line of code
; K% {* x, T0 o% p, Dc) print out the lines that are the same
$ l+ D) N& o' U2 id) count the number of lines compared / lines the same
1 S) ?& K* ^# p, o, C' R6 LThe AuthorisedUsers class: (Total maximum 20 marks available)
+ G  m. v& b% f. J" n3. 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)( E. g3 X( m  a4 k+ h
4. Provide methods to:; F" D/ b2 C- `$ R. Y) `
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
3 q' ]* [" k+ X/ `, Lb) return the name of the authorised user
: X- j: F$ q0 ^1 H; {/ ^c) return the name of the department of the authorised user
+ V  x/ D0 {, v+ h) n" R& R4 NIndividual Data (Maximum 20 marks available)8 S% @: F% Z; K+ _" k5 c1 R1 i  p! M
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.- T8 M0 C* l. n$ q. Z2 A+ {: \2 z, d
Documentation (Maximum 10 marks available)$ b5 f% c! g  G9 k4 p0 }, _: M7 T' d
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.
! H& [* A3 \% x& H6 j% R- MBSA104 Business Programming – 2007: Assignment 2, G6 w3 ^: L2 l( n8 P
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 t- B+ [" l0 ^5 u* @+ ?, v; t不过你要翻JAVA的类库说明。你有下载没有?5 N! W8 i% X+ E4 U: R
查询关于对比的函数。貌似关键字是contrast,还有compare
6 V  a0 n# z, S& X9 Q7 {! u
1 N" J8 q; a7 N* K$ \$ H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( _: g! r9 ^1 ~8 h. e1 z2 ~) b痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
! J. \8 G1 _; j4 ?  x可以下载到的 是 jdk-1_X_0-doc  }$ Z! r8 q$ x

. ^# s6 T+ L- D! s% H0 R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-20 05:16

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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