找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1639|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 % U, z! `/ M- q. e2 @4 g, O 4 m* K. ^+ y6 w# U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' X( s6 J5 a. o, v
//  ProgramCompare.java         Provided by: DRS
+ q: K, D) e* {) b* c3 n) W! R//& `# Z/ t8 }& l2 J0 k
//  Program shell for Assignment 2* `& R+ K# @& G  y% p6 |  e
//  V' I, z* ^  Y- ?
//  Compares two text files line by line6 W6 t. f. ^& o2 X
//*********************************************************************: l* l1 l+ |# U+ o1 q8 p$ F

. L! D5 t/ B+ H. v: aimport java.io.*;/ V3 u( ~4 S8 l6 B3 E5 ?

7 B6 U9 j0 R) u. k5 `public class ProgramCompare
! w6 B' o  ^" g8 t& M# D# k{
2 Q  X4 L9 y- Q) Q2 q, N0 f2 f. @        //-----------------------------------------------------------------: Z0 w2 j) d' R
        // Constructor  a( v/ ^+ U9 L* H, \1 W
        //-----------------------------------------------------------------) V: P6 Y: U+ A8 `% K" p
        public ProgramCompare()& A7 C# v& |) ?8 Z) `
        {: p3 k. w' x' p. f; ?* k2 {
        }. E9 Z' s: n8 ^+ G( k- N9 J7 q  g

% G7 b( U1 P7 M" K        //-----------------------------------------------------------------4 S) N& i- i; m& D
        // Method for testing that class has been reached( W& w' ~+ @2 a
        //-----------------------------------------------------------------       
3 Y* r! v/ e' `2 `  s1 i  M" x4 ^1 \* W9 d; Q4 G9 Q
        public boolean ProgramCompareReached()        
" H: \/ L- L$ _% T1 c8 {. [4 ^        {
% f& f0 _* N8 q( L      try 3 }( }9 ]" I1 h$ e3 o
   {        
* k4 l0 R" ?! Y: K5 s- n                       
% u$ }  l2 X  B" E                //********************************************************************: R* c$ r: F9 Q6 d3 v' j
                // Try-Catch Statement is used to handle exceptions - such as file not found
- X! X- u8 u" A* K6 B4 [& ]% d: }                // Reading the files will need to be placed inside a Try-Catch - just like this one!: ?! q' D+ K0 ?7 Y4 e7 e  C
                // For more information see page 534 of the textbook
2 v3 Y4 W5 K+ ^/ M- o( M2 J                //********************************************************************
9 g, I( t6 J& C$ J9 z4 u: Q& l                    
9 }% k2 S! S  l2 x( n6 M3 o& Z        }- C/ ?" d- a: f; ?0 E
             catch (Exception ex) // Exception caught here and message displayed to the screen * j) d' f. N1 L2 z+ E7 c; ]3 ^7 Y+ t1 x
          {
+ K4 c4 J, _  T' Y, @% Z                    ex.printStackTrace (System.err);1 a, \" Q% u) E: x, R" y
           System.out.println ("Error message goes here"); // Replace this error message with your own         
" e+ [: q7 i! k5 r) m! |        }' M$ k9 G. a* ^4 r3 i3 O0 b; p
                return true;. O) p4 W* l( k# [
        }) x7 D1 w/ W# I& Y1 D

! S5 _/ S9 z9 J+ f  P' h! @/ T  X0 M} // end of class ProgramCompare' h1 Z! F2 N9 E% i& X8 p- k+ P- ]

  ~8 h! W# r% m2 {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
  s$ d5 c7 e% F+ k) W//  ProgramCompareMenu.java    Provided by: DRS
" `- u/ x- M& x//6 p7 D6 M' _. G3 H4 A/ ]
//  Calls AuthorisedUsers.java and ProgramCompare.java
: Q& @9 T% i, ?! Z& S//
" U* l1 h; {+ H- W/ F//  Driver shell for Assignment 2.6 i" @5 E& J" w$ `8 S
//********************************************************************% z7 g( X; S7 r6 N# C
; e/ H4 P( e* L: n
class ProgramCompareMenu" T5 H- s& u; c- J; m. v/ p3 c6 U/ g/ i
{6 @7 T! y, J! d) M4 d
    public static void main (String[] args)
1 m' \. ~1 J/ M) C            {
# `: ^- d5 H! A2 n+ Y: ]& Y: |                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable, K0 V3 @6 u$ D- b5 J8 P
                ProgramCompare reached1 = new ProgramCompare(); + M6 F* h+ x- M3 e9 m1 h6 {! N0 o
                AuthorisedUsers reached2 = new AuthorisedUsers();        " |) e2 \3 v0 ]2 G% m
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  l' P- j) O0 z, R0 F; q+ u                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 T. p$ J% p! ]9 Z% k        }
- r* h3 C  m& e# p}// end of class ProgramCompareMenu2 c* m; K! S8 a3 }

) @5 R: U# |- k+ f- I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 R( S' H2 U8 [( Q# j; e( E0 j
//          AuthorisedUsers.java          Provided by: DRS. T2 M# l# p- ^. S9 n. N' E
//                ; D0 h: {4 p$ [
//         Program shell for Assignment 2
( ]  x: q1 K/ ~; S  Y//
) U0 p) M! p) s//         Represents facts about an AuthorisedUser
% z1 K1 r1 B2 {' A& r3 K//********************************************************************1 n; I$ W7 y: z# {: j
4 v# y/ {1 `0 l) `: C  x
public class AuthorisedUsers; @" m4 I0 M  H0 G
    {
( V# O4 m# t" U# ]8 a' s7 d* \
$ M, L& g+ M0 f4 F) c" y        //-----------------------------------------------------------------
# [6 c3 [3 {  g* @. S( K& q0 K        // Constructor
* \4 I. J& l6 n8 i+ z        //-----------------------------------------------------------------) A% R" H7 X% J7 h# d4 r! m7 c+ i
! C* V( ~* I2 }% c: R
        public AuthorisedUsers()" `+ p, b( D3 g9 |% J
                {% ~( o8 v9 o. A  Z, U' n. ~' \
                }1 u! i4 U  Y, m; J  F. m
& Q) V! Z3 d+ t; G6 j* Z) h# v) {
        //-----------------------------------------------------------------, q- r, S/ v/ A. U
        // Method for testing that class has been reached; ?$ o2 R# }( P, X' r7 L" R
        //-----------------------------------------------------------------       
8 b8 Q7 q0 A$ ^" y        public boolean AuthorisedUsersReached()' M& T: \: i! }- @& K
                {5 K6 [* `% X2 t- ~
                        return true;                       
0 u8 K* O( v, j9 C. F) m                }5 z. x; z+ W& A' w' e
               
6 v( k7 W( |" R7 e3 Y    } // end of class AuthorisedUsers
7 V! r9 u2 }! i% s6 N7 _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# Y/ w( }+ g. X' T  EShanghai - 2007& C& s; d4 ^7 a' }# i1 Q- i: Y1 h5 c9 S
Assignment 2) i- J0 V2 i- W. V$ M3 b! K
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)* B! q# G+ ?" T
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.
1 {1 L1 X& Q/ e2 R( NThe staff must be able to:
; O8 z$ [0 q: V$ k' S+ z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 e5 o3 L3 e# k( q; Q: ]/ [: x1. 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.; _4 v1 X5 @, F4 j" Y) d
 The interface should provide a menu so that the staff can:
5 `. R2 K  j. z3 |" H) sa) Enter the names of the two Java program files to be compared
( x$ ^! t  ~1 B  T9 A( Q For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( h* B/ U9 _$ I3 d** 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).
1 Y% v$ S, |  @0 IBSA104 Business Programming – 2007: Assignment 2
$ r" M" D. s' IPage 2 of 5& n# @1 o. I9 P
b) Print out to the screen all the lines of code that are the same! p/ A8 Y- n5 @6 V
 Include the name of the file and the line number of the code being printed for each of the two files+ y% l# d. ]$ ~& `2 ]& u: ]
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( R. v; m# {+ W& h) o" ?' F% n( y
 the name, username and department of the user
/ [) O/ p8 T1 h2 R. v4 z the statistics of the comparison
( u: C3 f! d( f2 G+ K- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 t+ C; h2 \8 K' S: `$ Y+ {
 the recommendation for further checking5 `* a  d$ g7 |2 ^2 m$ E
- 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
' _- i8 i- @6 w0 z the names of the two files compared
& x) F$ O/ t5 T2 {d) Leave the program (exit)
6 a' W9 G* ?2 p  W- V5 ~  \; wThe ProgramCompare class: (Total maximum 20 marks available)
- [/ o6 b- y( U4 E2. 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)% G9 g( Y4 m5 F$ P7 @
a) provide an error message if the files are not found or there is a problem opening them
, }( I& S0 [+ u& h4 R0 K2 O& Z4 v1 F2 |b) compare each line of code
, l  ^1 z& c9 J7 d% O6 Z9 Wc) print out the lines that are the same, M2 H* q# A3 h; M( A; n, M
d) count the number of lines compared / lines the same
! X; h% ~6 k; UThe AuthorisedUsers class: (Total maximum 20 marks available)
5 W5 u% ^8 I! }1 I0 b% {- d% 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)6 A# f6 j, g  s
4. Provide methods to:  K. S& h& t$ u4 h4 z7 i
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
# e3 s, P, T! t& Ab) return the name of the authorised user: U7 E$ e* s0 B; c* Q& d
c) return the name of the department of the authorised user
4 x, n# d( k( PIndividual Data (Maximum 20 marks available)
* q" X% K* H% n: m9 z" }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.
' `- x* _$ d- _4 {6 LDocumentation (Maximum 10 marks available), `2 {! [& F& ^" T
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.- I* Z/ r( q& X6 x' `
BSA104 Business Programming – 2007: Assignment 2& D9 l% q' c9 i0 O
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
0 ]. ~* {1 p" U6 k8 u不过你要翻JAVA的类库说明。你有下载没有?
. W; k! \2 B4 T" V6 M查询关于对比的函数。貌似关键字是contrast,还有compare
% W9 E' t" W  @
& l$ R3 R, D! o- G6 V+ ?1 C6 T[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* ^- C% [" T" e痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* |9 ^7 l% b1 J9 S6 K- V+ _8 U可以下载到的 是 jdk-1_X_0-doc
1 n) Y2 C7 P- p2 F
, J+ k! d; s7 I  t3 Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-18 16:19

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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