找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1414|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& u5 I# s) a& W; Y: V8 r1 p) b 1 I6 v' i$ B* p, t) f1 R. y) m* }
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
! _7 e5 P! G% V! c//  ProgramCompare.java         Provided by: DRS( D2 x2 x# H3 }. z( _
//
9 ^- `8 c+ M- h( f, q//  Program shell for Assignment 2
4 ~8 i+ L' K  r! j" n* D//
+ p/ r2 ?5 t6 X% V( \//  Compares two text files line by line
0 U1 l! z" \  H$ J//*********************************************************************
) u2 q, l- _% Y; Q8 ^0 T* g' r: H. M
import java.io.*;
: ~& b; G6 ~8 M) O. o' J+ Y' @2 {0 z' I( A0 p
public class ProgramCompare
7 ^* q7 e8 [% q- J$ i" @* I$ V6 m8 w+ ]{' B, @- `2 K+ T1 _
        //-----------------------------------------------------------------3 l! J) A) T, B2 p3 d' a3 ]% L$ t( b  v
        // Constructor6 R( O( D; Q, @0 Z
        //-----------------------------------------------------------------
! I' o/ u% }1 G, @$ d) f$ _; k        public ProgramCompare()" W  `8 {- H: V! L
        {
* m  `/ q7 Q1 `5 D: S# e        }9 e' `0 g- p, Z( I

$ F# r  d  H! X, c* h$ ~/ ^0 q        //-----------------------------------------------------------------
8 ]1 q! g* N# N: Y4 n" Z        // Method for testing that class has been reached. G1 l7 X: v8 T" C3 c" L* n1 r
        //-----------------------------------------------------------------       
( V8 v  e$ {& k2 z4 }( Y, ?' z& f8 |- x. U/ L
        public boolean ProgramCompareReached()         ( Z- t0 M( j& o0 J; @0 h) r
        {
( Z; Z- N& C. B  G* Q. ^      try
6 \' }4 z. V! a1 }' ^   {         3 v- Z- V( z6 a. X3 u5 ^
                       
7 S/ N; E: ~3 A, q% C: Y                //********************************************************************
6 ^" d: t2 A/ C7 r* J                // Try-Catch Statement is used to handle exceptions - such as file not found 0 Y! \3 y2 e3 H+ i" c& p) I2 G
                // Reading the files will need to be placed inside a Try-Catch - just like this one!# E* e3 y* Y/ R* {* }1 w1 d
                // For more information see page 534 of the textbook
: p" U! |/ ~- l6 R# l4 Q5 t                //********************************************************************* g' u6 |! ]- Z3 G5 S
                     ! K; O* `+ ?% p
        }$ {( V8 B: t3 E9 {, s8 @
             catch (Exception ex) // Exception caught here and message displayed to the screen
  o0 r2 X0 C9 q          {. g6 V$ u8 a6 B6 a
                    ex.printStackTrace (System.err);
3 J5 K! y( s2 ]" i$ f: b           System.out.println ("Error message goes here"); // Replace this error message with your own         
3 Z6 w& K: x& [# l        }7 F! Z+ Z4 h. O# r
                return true;
# x+ m- }9 V3 d        }1 ]& u: \; K3 y, c/ }

+ C, O8 J# M$ N( _} // end of class ProgramCompare& p5 `2 l5 p, Y! B$ S

0 L" Y& x: I) Z* @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) X0 `% b/ [+ G4 H. j" Q/ g  O6 f//  ProgramCompareMenu.java    Provided by: DRS
6 C/ B. Z, p% b! ]" [, ~3 Y) F//9 l3 `! c; B8 A8 ^
//  Calls AuthorisedUsers.java and ProgramCompare.java4 L& D9 c! Z6 J' H5 G( o3 i
//
5 v3 I8 M; g0 _! S2 z6 d/ b//  Driver shell for Assignment 2.
& v0 ]! m  T% l( u6 ^' ?, G//********************************************************************0 Y0 c" f  R) x

' K7 F: U+ g9 P- a# ~$ O( vclass ProgramCompareMenu; B, U8 U2 l8 I8 }: h
{6 z: w% I- r/ r3 C) c
    public static void main (String[] args)
" B+ D! @0 v8 \( C            {7 |; O% o9 p; i3 q* F1 {) z$ e
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 n* z  m( R5 Y! q
                ProgramCompare reached1 = new ProgramCompare();
3 Z% \" i2 q. \( b; B1 O9 [* r7 l6 t" O                AuthorisedUsers reached2 = new AuthorisedUsers();       
, S; ?4 M) K7 H0 K& s& Z7 i                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 F  ?: y( q1 K# r
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ ]0 t( }9 [/ b9 c( _9 N) V. D8 m" @! T* y; r        }+ _' a+ K5 X: R
}// end of class ProgramCompareMenu
9 l7 g8 ~! q7 L  c- n0 D. ~
' E" n& ?3 i/ u1 A3 Q! q/ r' V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 r7 {, H) I" G/ {( c% \
//          AuthorisedUsers.java          Provided by: DRS
) Q8 I! `" y& a; ]: I//               
8 f2 |  D' c3 e//         Program shell for Assignment 2" N0 S% ]' [3 R! H" ]
//
3 ^/ C  ?! b" e6 t//         Represents facts about an AuthorisedUser
1 W1 c2 e! s, Z1 J//********************************************************************
' t7 z; F; R$ x) `3 f; ?0 i8 N, f3 K' p, _) Q+ t
public class AuthorisedUsers
  F" |" ^6 _3 m9 _    {/ {- O* U% i0 K8 o( L! F

6 Z* k4 _0 ]; s8 f; l        //-----------------------------------------------------------------
/ N3 M/ {0 Y9 G/ Q6 ]2 M- j0 t8 o        // Constructor
% v0 A4 t- s9 b3 U7 T4 `  m        //-----------------------------------------------------------------" `: f8 Y, h, T+ `- c+ k- k
% {: o' v, p) f  B
        public AuthorisedUsers()
, S' _# s) b- C1 u4 E4 O2 W                {
. `$ L1 `0 j* I! z                }& u8 }8 U, O3 N9 w, J

- c5 T5 J" @- W& G# i! w! O        //-----------------------------------------------------------------$ u( D+ J3 N: U4 b; }% o
        // Method for testing that class has been reached
9 i2 S. u. Q7 p% c; M; y        //-----------------------------------------------------------------       
$ X2 Y  J: G& k/ d' j4 ^8 G5 P' x, b        public boolean AuthorisedUsersReached()
) c  e" d, r1 P" V                {- O2 N; E4 Z8 r8 A+ e1 I
                        return true;                       
7 ^# L9 ?% n' }4 a. G- f                }
$ g4 p6 B* X2 q1 Q* e                3 v! l; m& \& Y
    } // end of class AuthorisedUsers* \, f: m* D7 ?; h& A" r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
& g2 ]% N6 Y% C+ VShanghai - 20079 P7 h8 c: Z: H# }  \
Assignment 2
- I* S( q* G: [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)
$ @; W4 t! `) P0 D# v1 \* v. q1. 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.
# ~2 q  Y4 h9 n: \1 QThe staff must be able to:+ [+ q8 s7 h" \  k( I
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 C! x* g: I/ _3 b3 @: z, 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.
2 |7 @; @1 ^  h* K( ?' C' y4 o% m The interface should provide a menu so that the staff can:
: l( O$ T! F" a# T4 v7 Z( Qa) Enter the names of the two Java program files to be compared
: G# H. {$ t5 B: V1 R5 Y9 k2 b For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
* j" t* k! F$ K8 q6 w2 t) n+ ~6 {** 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 z/ I1 {$ ]. P. vBSA104 Business Programming – 2007: Assignment 29 _6 E6 y$ L( W$ W
Page 2 of 56 I5 I6 |! w; ^  L6 S
b) Print out to the screen all the lines of code that are the same( E- f8 ]+ h! q' p' v7 ?
 Include the name of the file and the line number of the code being printed for each of the two files" D+ j; k/ a; c
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. D- g6 t7 b9 k! U
 the name, username and department of the user
. c9 R- M, c$ ^ the statistics of the comparison; b" |8 a$ u6 o# S( e+ p
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 Z/ `( n5 z! A the recommendation for further checking1 b- A7 j& [& I
- 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 }- Q/ y; `* H the names of the two files compared
7 y9 a  x: l, R( sd) Leave the program (exit)
' f2 g! g' q% z' ^1 h  qThe ProgramCompare class: (Total maximum 20 marks available)9 c- [  v' Z0 _" j
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)& L; j( u- }: z9 `+ `
a) provide an error message if the files are not found or there is a problem opening them* z* |* K' L4 }" i
b) compare each line of code
( m$ [( T2 ~0 `% Z( v1 o! w( Tc) print out the lines that are the same
, }+ I+ B# T% }7 nd) count the number of lines compared / lines the same
, x+ I* A& J# M7 v7 g& p0 CThe AuthorisedUsers class: (Total maximum 20 marks available)# ~# \1 q5 {4 U% @
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)+ Z: d6 ]7 o1 d% G; r' k
4. Provide methods to:
+ O. e& x8 i" G& y+ |- G2 s/ Ga) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match9 S% t3 o( t- q- l
b) return the name of the authorised user/ G) {, q5 ~8 o/ [
c) return the name of the department of the authorised user
0 H) b/ T5 e& EIndividual Data (Maximum 20 marks available)$ G. \, \1 Q* V) ]" u1 p8 c: @$ ~
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.) V/ f1 c, n! o, G/ [; B: c/ d1 ?
Documentation (Maximum 10 marks available)$ T6 F3 n, X& Z! l
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.
0 j* A6 [" b: D# x) N0 cBSA104 Business Programming – 2007: Assignment 20 V" x4 i6 c3 B' ?; T
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
' P, Z. ]6 k  |' m2 f7 B' }  Z不过你要翻JAVA的类库说明。你有下载没有?
- H; `$ e% d$ C/ l" o, G( ~$ U查询关于对比的函数。貌似关键字是contrast,还有compare
1 Q0 @8 |3 t% Y4 w6 ~* o2 V- i4 S4 K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& p7 X  ~( a$ k' v- F3 ^3 K
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' Y7 E; |/ N3 e  Z4 d3 K! t5 h7 d
可以下载到的 是 jdk-1_X_0-doc
( S. O5 r# ^3 T' ]# J/ E& l# Y/ I, \  N  x5 N7 N8 F7 H: h  J! j2 Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-25 00:24

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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