找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1488|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ; j* C( U( R& B) F( X, k1 v% v& L/ `7 t( p9 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 | 显示全部楼层
//*********************************************************************
" u: y) F* c+ @1 Q' h( T//  ProgramCompare.java         Provided by: DRS
7 {5 w/ ~9 M% |: ?1 r; c//
5 w7 S( C2 s5 u; D2 }6 n//  Program shell for Assignment 2
( H6 g+ O# S3 G//
* H" c/ u* ?$ k; R. @3 V' f# p//  Compares two text files line by line' H5 A, q4 H3 M  @. O
//*********************************************************************
8 T. W+ f5 E( _! M) G: n2 T+ C5 d+ H
% ^  t2 ~2 e. r+ {6 @5 z$ u# K' r( Ximport java.io.*;- c7 P1 x: b/ L1 n# z$ c8 G

0 X9 V7 [2 |: q1 V- `0 ^* Vpublic class ProgramCompare1 g9 }+ a' c* u* d4 _6 r* j$ X" |
{
& {  s% r( `( l- c& i5 a        //------------------------------------------------------------------ b: L2 d( \0 C' F& c2 |8 K4 H* Y1 v0 s
        // Constructor5 p9 H- b( H, A4 G$ O
        //-----------------------------------------------------------------1 U* {& \  N' C5 d4 Q
        public ProgramCompare()
) X9 k5 m& l$ l        {
) t4 D$ |. B3 Y5 F7 R0 E% V& g        }
. u! i% A5 x2 \$ [# M' R; F' x  J2 F$ b* j, f9 @" o
        //------------------------------------------------------------------ ^2 N, E/ S" t* J) X! L
        // Method for testing that class has been reached2 p' c+ ^4 ?' K8 s0 H
        //-----------------------------------------------------------------        8 v: x* A. K7 I8 X- L2 {& t8 x
9 C) b9 y2 x% f: j3 }" Y: L* x
        public boolean ProgramCompareReached()         + i% Q- R8 b" q/ F
        {3 T+ g! T6 v/ M2 t. n8 w+ Y, d5 k
      try
4 L' C# X0 O6 x   {        
" N) l0 L9 u8 }9 u4 j, ]+ M* \                        # X4 g4 q) Z! T( M8 `" U, _3 `
                //********************************************************************& i0 a  Y' |4 h  X
                // Try-Catch Statement is used to handle exceptions - such as file not found 4 ^7 R4 q$ r* [3 _% f1 D1 d% E& \
                // Reading the files will need to be placed inside a Try-Catch - just like this one!8 O( \7 v( v% I' `; `# S& }
                // For more information see page 534 of the textbook7 |, g* Y+ C3 N3 D! P7 x8 s8 m
                //********************************************************************
2 e( ]/ E- u+ z7 C. P5 ~; c                    
% _* }) `3 H: X- }        }
$ x/ b; y5 h% H: j$ y0 }6 }             catch (Exception ex) // Exception caught here and message displayed to the screen   }* i) @: g3 }- k* R9 ~' W6 Q
          {
% t; ?4 x" F- w4 ^                    ex.printStackTrace (System.err);
2 V3 Z7 J* a" S7 Z4 `3 r           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ _- d- ~; r% b# W6 @        }
9 H% X% ?4 i  x1 P9 w' j                return true;
. V1 Y. @2 ~/ B% m2 I        }: C: L' j9 ?% k# i$ j. m9 n0 F5 ]

3 w1 B  n4 D$ T0 @0 f} // end of class ProgramCompare
7 O* |- d6 z6 ?2 _$ C8 [+ T- O4 E; c5 D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
8 Y. d7 {; }+ s//  ProgramCompareMenu.java    Provided by: DRS
: x! E4 e- y- z. ~' @//
- P6 o( p" d' h0 N% Y" R+ a7 u# Q//  Calls AuthorisedUsers.java and ProgramCompare.java
. `& I" e  s! X# b' S% t/ b//8 \  g5 x* ~; a& z" D6 u; j! B8 h, C
//  Driver shell for Assignment 2.
9 F+ r  {' v# Y3 A//********************************************************************8 b; z2 N5 n' K1 E# S; l; n
/ k* e: l  z/ b) `% @
class ProgramCompareMenu
! L9 a) p9 g' `% ]2 Z1 d5 r{
( e) t. H; S, Y5 P5 B    public static void main (String[] args)9 r4 U% D9 `) s' m8 p. i0 r, T- ~
            {/ S( C5 E: x; I/ U6 w
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable. v4 n  Y& N! ]3 A7 f
                ProgramCompare reached1 = new ProgramCompare(); 3 t0 d8 n1 s8 a4 a
                AuthorisedUsers reached2 = new AuthorisedUsers();        # g8 R) D. l: b0 E4 G2 P  k
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 t" k' x& f1 g1 V
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 k% \9 N# z5 |+ C4 Y6 ]8 t        }% S7 e7 a# E8 a  G2 Q2 Y
}// end of class ProgramCompareMenu. v4 t& i: G# B, ^  X: a2 R

3 D) S& R# \- X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************& _( S/ ?: }1 x& [" ^- f, R% v& u! N6 ~
//          AuthorisedUsers.java          Provided by: DRS
; l4 x" O, \7 h( Q( m3 m8 d//               
: `4 w" S/ G7 A' p: ?6 T7 p//         Program shell for Assignment 2
. _8 {0 Y! s- G0 l3 Z0 G//
4 i; L% M* M9 p  ?- S1 x//         Represents facts about an AuthorisedUser
3 Q2 ?: G9 I6 r, R) A//********************************************************************
2 @6 P0 U+ n4 e4 D/ K' }! J1 x8 {9 i
6 d' y) R& T" ?, r3 r& kpublic class AuthorisedUsers2 Q1 V0 G7 @* P! @' Q
    {
3 A6 |& z) {6 [/ E- [# K* r1 H2 o( _0 H1 R$ v
        //-----------------------------------------------------------------$ g9 F0 e* ^  N
        // Constructor
4 _. W2 @# [' f7 E3 ]        //-----------------------------------------------------------------  ~; B) f+ D7 O" w
$ w# b! X9 c8 T( u+ t4 ^! \6 p
        public AuthorisedUsers()
6 d: b2 U4 @; V, R# M                {) M1 A7 z% K: {: J0 G' {2 l
                }
1 p+ B$ D6 ]9 w7 v" o
! _- O( O' N  ?0 }+ o        //-----------------------------------------------------------------+ N! h) ^- n/ k3 v+ E
        // Method for testing that class has been reached
- u# ?6 d: Z- B8 J        //-----------------------------------------------------------------        : g- j; [; }( w$ b( t* }& s6 R
        public boolean AuthorisedUsersReached()
' C* u& K; @; S' p8 n                {
& l( U( l- o: g* [; f                        return true;                       
6 }# F" I7 Q' D' o  O4 _                }' f+ X% c! Y5 H7 E$ M! f3 w
                ) }1 B. H  b3 ]- e7 X0 s
    } // end of class AuthorisedUsers) O3 l5 V3 D+ s, a( Q4 b6 n+ w9 t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming4 Q% S* r8 W7 @! X, Y! q
Shanghai - 2007
) x4 K3 x0 `) ^/ F* OAssignment 2
% P0 w7 D. i7 Y$ h$ gDeadline 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)1 B2 w$ S) ^/ B; B# ~( F
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.
" ?5 U2 p7 H' a+ D( E/ I8 lThe staff must be able to:
" I* |( j% q- D8 H, y  { Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  f7 a( m$ D- ?9 K8 W
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.: V2 R+ ~% U" V1 q1 g9 N4 t. f/ U0 R8 V
 The interface should provide a menu so that the staff can:
8 R- F5 ^' p' Ya) Enter the names of the two Java program files to be compared3 D9 y# @* x: V  i* ?* Y2 Q' f
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program." ~% l& y* O; @. [6 X6 v& r. `
** 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).
: K' t( A& u( j- \! j" TBSA104 Business Programming – 2007: Assignment 28 b2 ^) Q$ r( K* x$ z
Page 2 of 5
, |! g1 B3 f$ db) Print out to the screen all the lines of code that are the same/ P6 l; V0 E" O6 n
 Include the name of the file and the line number of the code being printed for each of the two files  `/ L" r7 _8 W7 c! A8 }5 W
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" a% z( O" v; f& m- z/ v: h the name, username and department of the user
) l2 b( H/ h$ W: K7 y) I3 p1 }# d the statistics of the comparison
8 I, e8 ~( h5 g% [$ _2 k; Q2 N- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different( k, G) p! X. W/ ~$ U# P
 the recommendation for further checking
% I* x7 M# j/ m- 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
1 b0 Z' {* I, W2 \" w the names of the two files compared
; r/ @  T+ a9 w( C2 _d) Leave the program (exit)7 j1 P) Y( i' ^" ^
The ProgramCompare class: (Total maximum 20 marks available)+ E. S) o5 Q- F2 A9 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)$ D; A& A; C+ p/ ^
a) provide an error message if the files are not found or there is a problem opening them( s# t% Y1 U7 S5 C  X
b) compare each line of code  T3 G$ h, R% J  R
c) print out the lines that are the same
! j  S5 B" J' I( `6 X7 a; V# @8 [d) count the number of lines compared / lines the same+ y1 Z0 _  S7 j/ M% Q+ F* b0 x
The AuthorisedUsers class: (Total maximum 20 marks available)+ W5 y  d. Y) Z  X$ s; z
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 A2 l" Y+ a& T, [* r
4. Provide methods to:$ S$ f' b/ P# D1 u/ c$ g
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 match5 r7 [5 ?1 I: t8 Q3 U
b) return the name of the authorised user
: n- M# A! ?8 ^; Zc) return the name of the department of the authorised user
6 z+ v4 C& E# A- p6 f7 `Individual Data (Maximum 20 marks available)  R9 Z$ F0 ]# X
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.& Q1 h* Q; i- ~  n* B) `8 y0 e" [
Documentation (Maximum 10 marks available)
( F" L/ F+ @. B; u6. 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.
1 C0 t8 t! A& X* UBSA104 Business Programming – 2007: Assignment 25 [6 _; x9 Y! C. B6 \3 o% @1 Y6 l
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了' Z! V& g9 L0 a7 C* I' F8 l
不过你要翻JAVA的类库说明。你有下载没有?
/ z6 z- K" t' S$ `& \8 M* B4 ^查询关于对比的函数。貌似关键字是contrast,还有compare5 x' G; }' o5 y6 W2 D/ B8 k& d  m" Y
2 v+ A* x: p( t& A6 J, f- _
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: o) `, R4 r. ?* G痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
9 p( j, V( e: |2 L7 M* W! z可以下载到的 是 jdk-1_X_0-doc
, v; _, l  k; k9 w  G, z, h2 R1 n4 ]* d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-25 12:27

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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