找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1678|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * H; }* B( i; B% L. x& I + l! |3 x7 |) m+ {. n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************1 Z0 A/ M8 G, L
//  ProgramCompare.java         Provided by: DRS
, [% W2 K& r. s$ H//, N3 R" V, K6 }9 ~  h! Q( y/ _
//  Program shell for Assignment 2% k; X! _& x- _. a
//# ~& I# t/ t4 D; z1 c
//  Compares two text files line by line
  f! J2 O4 H5 e. Q8 `//*********************************************************************
. C0 q# Q. x* M) h0 p; X! K$ Y: m; H% M: \7 {5 V1 H
import java.io.*;
# u1 H8 R' Y. e8 z- P2 a; p( c( p, X- q  J: @0 X! V9 m
public class ProgramCompare
$ }" b/ L" Q4 g* o8 h/ V{+ P2 P/ B9 L( x. d4 G% z3 J
        //-----------------------------------------------------------------
" q  _! |8 d2 c1 `% d: r/ v        // Constructor; w: H6 L) N! `! _% J
        //-----------------------------------------------------------------3 O% L) S" A2 o+ W7 M) |5 ]
        public ProgramCompare()
6 J3 q. g: V, }! ]" Q        {1 l6 ^7 L$ W0 p6 n5 z+ q9 }
        }
8 I$ ^; ?$ |+ I8 k; M0 y) {
8 D8 v7 l/ t/ e% Z        //-----------------------------------------------------------------( F/ t& J1 G$ C) z) x: {8 K
        // Method for testing that class has been reached
4 E  }; o' G0 d        //-----------------------------------------------------------------        . F6 K1 i, x& C# s8 ^. t
( d6 |* H+ h6 ]/ u
        public boolean ProgramCompareReached()         , B0 ]) x- \0 e. ?: R4 \
        {$ `" Z4 R. b1 _6 |& s! ]6 m
      try 7 y+ f7 A; C8 @: d+ _% Z1 Q- i
   {        
7 ]& k. l  j/ Y1 Y& ?* W                        # [% p# ]" r7 y  J
                //********************************************************************* U" r! S; K" }0 ?" o* t- x" N
                // Try-Catch Statement is used to handle exceptions - such as file not found
3 o' e, ]) G# m. z+ T                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 e; f% `, c( q2 t* s7 C" Z- B9 ]                // For more information see page 534 of the textbook1 k! t( S  {- h5 I
                //********************************************************************: q( H2 V! g. M$ O" O
                    
. L& `" ^+ D9 N" [4 a6 |        }' y1 x% \7 e( w. h
             catch (Exception ex) // Exception caught here and message displayed to the screen
  G3 b' G3 ?4 b3 g4 E" X; Q2 U          {1 n; \6 B* A3 _% k
                    ex.printStackTrace (System.err);+ F. r1 e# D( d8 D, P9 w* i5 M
           System.out.println ("Error message goes here"); // Replace this error message with your own         
) N- |1 z' b  _; T        }
  T& h. G% ]. W                return true;
8 n+ y4 Y/ ?5 H! s7 s0 B        }- r+ s, z/ F. V! y
6 k6 O. d( L, ~) G2 R7 y% [
} // end of class ProgramCompare4 Z) |# ]; e" w- |

, q) n6 `1 ~. i' |: X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' z- C3 I7 V5 U
//  ProgramCompareMenu.java    Provided by: DRS
8 _# ^/ L1 |: D, a3 i4 x4 N3 _//6 S4 j; L% b+ Z
//  Calls AuthorisedUsers.java and ProgramCompare.java
( {! J7 v& U# \. }! r//
$ _3 V% f7 n& L: |( L* |% z# g( ]0 I//  Driver shell for Assignment 2.
+ K0 P+ v  m# {3 k: K2 P! n//********************************************************************! S' S* d5 p- i" m

& ^' d0 h6 s2 g, t) u$ pclass ProgramCompareMenu; B) J- X6 Z; I. _' O( A9 H
{5 l2 g- v! W! m$ a3 }2 s
    public static void main (String[] args)
  y7 U! |9 {$ ~# \2 o            {# }/ W6 f' s: X( F3 A8 u$ N9 j1 B
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 B8 L. x7 I! v/ r: v4 E
                ProgramCompare reached1 = new ProgramCompare(); 4 z1 {4 ~7 n% x2 s
                AuthorisedUsers reached2 = new AuthorisedUsers();       
" K! |) t2 G4 A                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 X( t& c, C! ]0 s2 L# N- m
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ x# z- ?9 V5 X; Z        }! h, v$ \% l0 q8 g8 d* i
}// end of class ProgramCompareMenu
% j9 c) H& x) B
2 E- b4 J' C& r6 g- {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. ^( `7 v% o8 G; ?
//          AuthorisedUsers.java          Provided by: DRS) N, K! @% c, Y( h% @
//                . `3 G9 `' D% [. R8 N
//         Program shell for Assignment 2/ N4 A& I( _+ n* }  [
//
( u0 q9 X6 H1 y//         Represents facts about an AuthorisedUser
9 p3 N9 W1 m/ U" j//********************************************************************; `/ A! ?- x3 J

( ?2 T4 n3 W( L! r; N' b( Ipublic class AuthorisedUsers0 p# m5 v' A( M. ?1 Z" Y- q1 @7 V
    {
% O3 t6 ~7 Z2 X! m/ O+ |/ ~! e& U" E$ \; u# S" j
        //-----------------------------------------------------------------  R( N# `5 _# M" l
        // Constructor
# ]0 k; W0 F- u: x% [        //-----------------------------------------------------------------
$ r# r( U# x' e6 B+ {
. n' R# g) J, m/ w+ j% g        public AuthorisedUsers()8 F" a, V9 T3 `$ K
                {( c+ Z2 k8 r* T
                }# w. ~: `6 Q' \# Q% s! @" T; ~
2 j7 {$ N0 V! \) F& ]% z" e
        //-----------------------------------------------------------------; b$ ~6 U  C1 @5 Z) x: A( t2 S8 K
        // Method for testing that class has been reached5 z. v( B( Q) c2 @/ U9 o
        //-----------------------------------------------------------------        ( @3 T7 v) V4 G2 s$ \& u
        public boolean AuthorisedUsersReached()$ B  c3 d4 f) {( h/ j; J1 w! o; n
                {$ I- s0 h; n/ s5 q5 |( O
                        return true;                       
' v" z! p8 |! s& ~% O                }
2 u7 j8 j. J+ U: ~6 t6 n               
% b8 I4 @  o$ u8 q    } // end of class AuthorisedUsers
! `& ]- i  K% G' E& F$ z6 l3 X( s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" @; I7 J6 k5 x! L  [5 i  x) x: M
Shanghai - 2007
9 F. N4 g& q! f; z- E1 QAssignment 2
# R# Y* P& P. J  C* MDeadline 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)
$ M& k8 s0 k' h3 g. D& T1. 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.
- _4 l+ @$ G2 e( D) Y8 MThe staff must be able to:3 f5 j3 N( Z3 d& [, L
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.; h# s7 h2 t( ]% k/ G  I
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.- z5 N9 S1 _3 y) H
 The interface should provide a menu so that the staff can:* N6 {# h, Z: E4 ~# u# O
a) Enter the names of the two Java program files to be compared& G8 W+ u6 ]8 z$ G) o" a; |. W
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 S! ?8 t' `2 Q+ i0 {** 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).
, u2 O0 E. _- R% j  i3 Y" }BSA104 Business Programming – 2007: Assignment 2" G* L, P0 W7 J* p
Page 2 of 5/ M  |8 c/ S* G, Y! M# E$ l
b) Print out to the screen all the lines of code that are the same2 ~5 C" v2 F5 z2 ]! y
 Include the name of the file and the line number of the code being printed for each of the two files
2 c( c* G' V- c* ]! K' R% ~c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared! F0 H% k, V8 `" \% v6 Q& n3 s
 the name, username and department of the user7 a+ @1 _( K/ s+ x' m) q# d* ?2 @
 the statistics of the comparison
3 p5 A; w& e$ A4 r& m- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 P* s5 f7 p; e5 P2 x7 V8 \. u
 the recommendation for further checking% o6 L- M( u# [5 f/ m$ j! W. Y' ]
- 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# w- X; |5 h2 v
 the names of the two files compared
7 m: e6 J; a/ a! ]+ R' C) hd) Leave the program (exit)
. `$ s& G) G* ?' \2 nThe ProgramCompare class: (Total maximum 20 marks available)) m: ]. O7 t7 _1 o) M" g! f3 P
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)
* G: L# [! P1 f3 B0 a! g, T% j$ z' aa) provide an error message if the files are not found or there is a problem opening them
  Z  }* f% P+ K* |b) compare each line of code* C3 A+ i% d. `: L, F
c) print out the lines that are the same
; ^' _+ J; x5 Td) count the number of lines compared / lines the same) Q$ R. T1 U* Z) [" d) M
The AuthorisedUsers class: (Total maximum 20 marks available)& E3 t* O8 I0 `  `0 \: S4 s
3. 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)
7 d2 R1 P" _1 G( t4. Provide methods to:3 }: y$ q2 P, E( L* x% _# [: C
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
0 U2 R( C+ O) |8 ]b) return the name of the authorised user3 W, p5 X. R7 R) F5 [
c) return the name of the department of the authorised user
. s: c* V4 d; pIndividual Data (Maximum 20 marks available)1 F2 @' I& h) j0 f9 I$ L2 d
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.
0 h( X% ]% h( l6 O. O5 B9 ?Documentation (Maximum 10 marks available)
( D7 p0 n  B7 f; a6. 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.
  Q5 E, c% U/ \; ?6 \0 G% dBSA104 Business Programming – 2007: Assignment 2
" K3 F# d6 ^; @  WPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ M8 [" E4 S5 |+ ~& G不过你要翻JAVA的类库说明。你有下载没有?
$ ]: B7 c9 U9 E' `! E+ e0 E9 w查询关于对比的函数。貌似关键字是contrast,还有compare2 M' S2 T  j6 f( ^1 n6 K
2 ~( D- _7 }0 v! A' m) p
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 |& V$ s+ \* s2 q痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% p: d! m* m2 E2 _  d5 y
可以下载到的 是 jdk-1_X_0-doc7 T3 I% u1 D2 d4 S
# z& w1 B  ^! c' v1 g/ t+ i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-28 14:16

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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