找回密码
 注册

QQ登录

只需一步,快速开始

查看: 958|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # y+ [# H9 z$ @! ` + s6 _+ }5 n4 |' ?
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
! n. i0 @% c1 `//  ProgramCompare.java         Provided by: DRS
/ B. G) m4 V! D+ @8 R( ~8 i# N; }//. r7 J1 b* l) ]% }/ q
//  Program shell for Assignment 2
% Q2 g$ u6 B5 j//% @: e; _  k$ L' s- Y/ ^: p
//  Compares two text files line by line- m5 x  k3 U/ l& `! p" T
//*********************************************************************3 k5 r% \( H  I+ i- J: p! Q

% D% _1 I8 h7 b7 Mimport java.io.*;
" F# z3 ?3 h; o& k5 T& c! H- N% ]+ ^2 t$ z
public class ProgramCompare  p1 j6 u* J7 ?/ h! b, k  X
{
% A# I3 b, \# l- F, @        //-----------------------------------------------------------------& x% h' ?  C% K3 |
        // Constructor9 `( J, ~8 g3 C' K: Z
        //-----------------------------------------------------------------2 b4 I" @, R& X( s& ^; ^, Q/ D
        public ProgramCompare()
* ~% H3 ]  \/ d        {
$ g$ Q, N' L/ ]" n* U$ A2 H' a        }5 M. Q& a9 \) ]5 `1 d. {

) m8 N- g! h, E3 C- D        //-----------------------------------------------------------------( A# a# _- h3 J$ y; q2 q
        // Method for testing that class has been reached5 Y# `# d6 M9 W8 Z, h+ \
        //-----------------------------------------------------------------       
( @7 O; z0 Q8 t2 g; M) f) Q0 E" _
        public boolean ProgramCompareReached()        
6 j6 J% Q" H3 e) ]% ?        {* s% V  i6 A( w( I
      try $ x. ^5 Q4 t6 `
   {         ; J1 C, Z1 v. L
                       
2 b+ u, w+ w+ T7 @6 B4 T                //********************************************************************
. J, G7 v; l5 x1 {- J& }$ h                // Try-Catch Statement is used to handle exceptions - such as file not found
. K! }# X+ M( E& [2 X                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 E' C; @5 r) D5 c' k( ?8 X                // For more information see page 534 of the textbook
( @; u0 K1 h! h2 X7 Q) [                //********************************************************************
: U" k. i% {0 a0 d  v5 h: |9 i                    
+ y1 R$ R. N' H0 ?$ i- ~        }" L: }' i: O2 Q5 q+ \% G9 |. F. C
             catch (Exception ex) // Exception caught here and message displayed to the screen
' E- [( m$ V+ _( }( B/ w  X" V          {6 X# }+ `6 {) V' r9 b4 K' Q
                    ex.printStackTrace (System.err);
- V9 `3 N$ G7 w2 l! z! I8 b( I) k) ^( `           System.out.println ("Error message goes here"); // Replace this error message with your own          7 M6 T/ L7 p4 p* g6 ?) k1 r$ j
        }
  U) B( _. m4 ]& H+ u                return true;0 @& K3 r! \1 B0 ]. B
        }! p3 G5 C; D; e/ S1 s

& h* i0 i. p( J2 a9 H% Y} // end of class ProgramCompare
7 o% F5 Q# q" z& r, t  b, X& V' t7 O* g! C# F9 }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. P5 N3 E1 @  v//  ProgramCompareMenu.java    Provided by: DRS
; C3 }9 ^% F$ h5 |0 F5 i+ H//5 K0 C  h3 L, v
//  Calls AuthorisedUsers.java and ProgramCompare.java
2 h7 w; E" |; L! {. W//
  m  F1 D, V* n* p/ i1 b& ?* E//  Driver shell for Assignment 2.
3 ?% J1 Y, U# c& R//********************************************************************
: O) l- l) i9 Y9 V! u! H2 s# @! Y2 B$ ], B2 z
class ProgramCompareMenu
! u: @& E  v% h' v3 J$ \8 v( l! S7 h{; e& E7 N8 h. `( v/ K% ?! @$ p
    public static void main (String[] args)7 U, A7 {! {3 b7 F( e
            {5 l7 b4 t% \2 @  F
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: A9 c3 j( N1 J% ]3 W( k
                ProgramCompare reached1 = new ProgramCompare();
9 `# J2 v7 X2 C1 B8 [8 }" U7 H                AuthorisedUsers reached2 = new AuthorisedUsers();       
, G0 W+ Z8 ?4 {" M                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# ~# r' \7 L+ g
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
9 B+ Z* o. e& G        }
" m, t7 W. v2 h: c}// end of class ProgramCompareMenu# O" B, Z" E) \9 i6 K9 g

, @6 `5 h, q4 K) l9 e  T6 s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************& `* D6 V! f9 `9 H# f4 @
//          AuthorisedUsers.java          Provided by: DRS
1 @/ x1 H2 S# f& D3 J+ h3 M//               
, b0 k3 o0 T+ K& _% m//         Program shell for Assignment 22 r9 X& ?! U' l- N% I3 `1 c
//
& I% x. ^' r3 Q4 \: w//         Represents facts about an AuthorisedUser# m7 ?" r1 E% z) V" q; f
//********************************************************************
- p9 Q% G; v% u+ o; I$ ^
, A3 ^% g- X6 D2 b+ }0 Zpublic class AuthorisedUsers/ |! J! ~9 c: W+ I" x. L4 I
    {
: j- C4 T7 z! s' O% d& C2 g+ }& l% n$ n  G
        //-----------------------------------------------------------------$ C# d+ ?; {/ S  a
        // Constructor
! U- {: p8 {+ r1 _1 O) P& W  V        //-----------------------------------------------------------------! T9 n. C9 ~# C3 V# j5 o

& w1 d" E: u! E/ s        public AuthorisedUsers()+ b5 k6 O3 O9 o( b; G0 L
                {4 ]6 I/ u8 N% N' P  C6 a
                }
7 n% f' [2 x5 |! g! f4 u! |' h2 _- [$ w  l3 L/ `
        //------------------------------------------------------------------ F7 i$ E' C' G# S. ]
        // Method for testing that class has been reached( U0 u1 ~2 O& E& P: O. K2 T
        //-----------------------------------------------------------------       
- f( x! \: x# a% o7 U/ U        public boolean AuthorisedUsersReached()5 I& O5 J6 `4 C4 h. @7 O1 w
                {  h+ {( J. h1 |5 V" G
                        return true;                        # H$ v6 O6 G, q: C5 \
                }
! L: s2 {4 A2 J& G                5 D( V: i' ^9 h6 i; _' W7 k8 o
    } // end of class AuthorisedUsers
/ A  H: d* u% Q' W8 z# c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# M2 }, O$ v, O6 BShanghai - 2007; g  s3 X  E; s, s- A4 W; R) @
Assignment 2
! ~7 A0 e' R6 b6 M- U% V8 UDeadline 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)
2 `/ U8 W# v2 `" _- a0 f( P# p1. 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.% P* a' o9 `" P; H
The staff must be able to:/ k2 a4 G6 k6 X* t9 C+ h/ J
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# J" Y$ P& m1 ^9 c
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.& X: i0 V' W# V! t; n  o
 The interface should provide a menu so that the staff can:6 A7 H6 h& s- S) j2 f6 Z
a) Enter the names of the two Java program files to be compared! o+ a4 k5 `, ~# f8 }% P
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
8 B, B" _; ~+ X" i3 J6 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).
. B0 ~1 n3 {0 |2 h, n0 p% CBSA104 Business Programming – 2007: Assignment 20 h! a/ E1 J% K. ~* L% G1 ^
Page 2 of 5" h# l  a; v0 T/ U
b) Print out to the screen all the lines of code that are the same
6 k+ ?- v: b  s+ H& g Include the name of the file and the line number of the code being printed for each of the two files
0 N/ ^3 N1 K6 Q, fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared: [5 V, E' p+ I
 the name, username and department of the user& a- E- N  a- x% Z* b
 the statistics of the comparison
% @* B* g2 v5 K8 V2 d& w- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 D: _& B- P( ~: J  z& c: c* l
 the recommendation for further checking/ b- v* M  I# c  G/ `
- 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
. Z, Q, m2 `/ u8 m/ X the names of the two files compared% Q* m$ A" U+ l- s# `; ~0 _, a+ h
d) Leave the program (exit)
5 g; B4 G' B) q! J! Q- qThe ProgramCompare class: (Total maximum 20 marks available)- M. p" e5 e% U4 S* u
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)
" f; R* S  I& ~a) provide an error message if the files are not found or there is a problem opening them4 d0 J- {9 b, f5 P! U6 v
b) compare each line of code
1 ~: T9 C$ Y& Kc) print out the lines that are the same
4 H4 A$ R; g4 f$ y9 r5 M9 Jd) count the number of lines compared / lines the same4 ^$ ^! z) M& W  @
The AuthorisedUsers class: (Total maximum 20 marks available)
5 x: g, Q' x9 W/ g# C3. 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)
2 @+ e% f) F" D4. Provide methods to:, B& |0 |# P6 F! E( Z4 h# r
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( V' u8 m6 A# j1 b8 s  c7 R
b) return the name of the authorised user1 g$ [  T+ J' v4 w' w
c) return the name of the department of the authorised user( O9 t) s' }  C9 S6 q: b
Individual Data (Maximum 20 marks available)
. {. a  p' P, }7 [* X5. 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.
+ Y4 P$ W# v! h* w$ h, FDocumentation (Maximum 10 marks available)
) Q' F+ X3 ]; S6 |( I4 z+ w6. 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.7 P% F0 j+ Y; Y3 g' h9 q8 c; U
BSA104 Business Programming – 2007: Assignment 2
3 V3 E% N/ Y$ A( L4 E- nPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 p* }  h8 ^/ ~9 d: V2 U不过你要翻JAVA的类库说明。你有下载没有?* q3 z9 ~  g! f' P! m$ G
查询关于对比的函数。貌似关键字是contrast,还有compare
3 ~. c! J9 X% D; {' D7 x+ O1 f7 S" M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 r% C- a' |# Z& j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。$ w8 G: g& ?$ h% ]2 S  h
可以下载到的 是 jdk-1_X_0-doc
+ Y9 Y% z; B4 R* g6 `- G
7 t  Y( ^0 {* u" W+ A- o[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-22 04:00

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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