找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1464|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 Y0 y4 @/ m4 v2 g+ Q ! {* }8 N' H2 ]$ h/ v; I K) b# _
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% B. M$ k! t3 Q//  ProgramCompare.java         Provided by: DRS
$ Q% Q; A: n( c8 y9 p  |//6 |" q3 z  u8 H2 ~- t( e
//  Program shell for Assignment 2- k  W1 H! s! Z  \
//
( `9 U7 k" l3 F: j% k2 q: u. V//  Compares two text files line by line9 _$ K* v" E) R( `. N( x7 S6 n
//*********************************************************************
4 D/ B4 ]: {  V4 f  X' Z. |7 u; F  p6 T5 y) ^. s8 F, W1 g" ?: p* f
import java.io.*;
5 }( A8 ^  Q( W. d! Z* h- p
% K; p4 Z+ h2 ?, @% c: Jpublic class ProgramCompare
$ P- n1 `/ e$ G- L4 f* I; X{0 c) T8 d  K3 v$ e- ?9 ?7 W$ @* v
        //-----------------------------------------------------------------7 M( X8 C, h. E( K5 g5 G
        // Constructor
0 H: W7 @+ }& I  h0 e6 g        //------------------------------------------------------------------ n7 A! H" D5 T: e" V
        public ProgramCompare()5 V+ K& @: z- W" ?4 ?4 @0 o& _
        {% H, H( |4 b' Z% z$ T9 b5 S
        }
" w, x! b+ h: n- m  Q5 C$ \1 R$ I3 p( @
        //-----------------------------------------------------------------
; K7 E3 ]$ }+ q. l7 `        // Method for testing that class has been reached
7 S8 A) k7 v; c6 I! ~4 E8 M  P8 g        //-----------------------------------------------------------------        0 a4 I# m# e7 {, Q4 p
8 v+ ~: B4 S8 @4 D, Y/ L8 W; g4 R
        public boolean ProgramCompareReached()        
% ?8 s* D2 {4 f1 u0 R4 D        {
" f0 c6 B) Y( J" I      try
( I+ G8 L4 M/ F   {         # ]2 a3 o" X4 t5 t
                       
, a5 R( G8 j: Q                //********************************************************************, X0 A9 V) F5 k# p6 W  o! x9 a
                // Try-Catch Statement is used to handle exceptions - such as file not found ) D" g# S. M5 C
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, i2 A8 Y5 ?, |' ^                // For more information see page 534 of the textbook
- _4 {5 G: l: \5 W- e' I                //********************************************************************
, [" M+ g7 ^/ G1 }6 r                    
6 l- b5 y( p% u) {% F        }
; `( [( s- ?: I$ S  ?( p% [; i             catch (Exception ex) // Exception caught here and message displayed to the screen
- m4 n/ M5 h# q- d# N          {2 R  ]% W, C# L1 N: q
                    ex.printStackTrace (System.err);
! D; ]1 d/ T' o* P7 w           System.out.println ("Error message goes here"); // Replace this error message with your own         
3 \9 t, i, e! n* X5 i        }
5 y( m" t  v( t& B& B7 b                return true;( n( `* y$ T+ _1 d% \0 t( K5 s
        }
) H$ |3 q, w( m9 m
1 G0 J8 W8 n2 W9 ~/ M% G} // end of class ProgramCompare
! i8 H9 z+ }! q
) f$ i- E% ~$ c2 r* q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, }5 U$ a' l( A) L1 ~4 H
//  ProgramCompareMenu.java    Provided by: DRS" _9 E9 A* V8 J  J3 J
//: t, U6 r8 F, Z' M0 K
//  Calls AuthorisedUsers.java and ProgramCompare.java- M# a. H& j& i6 G) J9 F3 N
//
9 f7 F0 ?: ]: M* A//  Driver shell for Assignment 2.7 C! H: J/ j" k! _
//********************************************************************
, [. _! H5 {/ t( f4 t& H0 P' S, h  N
( ?$ m8 }/ F$ U& C9 t$ e$ S9 `2 \class ProgramCompareMenu8 Z5 P+ \0 [1 |* ?2 M9 w" q7 ~
{
6 h, D9 m: p. P( i" F( U    public static void main (String[] args). N6 l& `3 I+ ]0 T6 O$ m& i7 n
            {
  z4 |# {* a$ J. }                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: u: s, M  u( E8 a                ProgramCompare reached1 = new ProgramCompare();
3 @, s/ v2 U8 i( U- T                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 H3 k( m( h# f! `- U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());/ u* U2 b5 _8 T  @2 `
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! D* Y$ v% a' R) H' t; D% z# h        }
9 ~: A9 ~7 f8 a  @" }0 A! F}// end of class ProgramCompareMenu
" j  D& n5 [! X
* x8 Y+ M' U/ _4 s8 G/ f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************2 ]$ d# {/ H& i, X9 h
//          AuthorisedUsers.java          Provided by: DRS  v& M7 V) O  a! H: l& |: ?% |
//                1 k" t/ G: S/ V9 o5 N: g7 _
//         Program shell for Assignment 2; y( L1 J2 \  P: ~( D
//
! _& S4 C/ [" _! d5 U//         Represents facts about an AuthorisedUser5 e7 ^5 }; C- j( n+ p7 L
//********************************************************************
% e& p6 R( p2 k4 f0 B: }6 I
- `( L, A/ J( d5 Q" tpublic class AuthorisedUsers( @& M* Y$ ]0 h5 f' C* K" s' a
    {$ A1 I: e+ ~! t5 |' S+ H; K, _
+ A3 M" K. s. H) R6 [2 H
        //-----------------------------------------------------------------
! G: h6 f2 N  b# g        // Constructor
/ L  D. F- ^) g" A1 f+ Z1 c7 U3 _        //-----------------------------------------------------------------
% O) d7 c- f/ L2 p9 X" k4 d( Z. y8 A) B: M. y" K3 Q
        public AuthorisedUsers()" U" r; t$ G3 E8 M# B6 v& w6 q* i
                {) B. j) l: x6 A9 w: L; F* }
                }
3 ]& T7 _' V; n" A7 g2 M6 x4 v
$ L3 q8 @( k" Y7 U+ g        //-----------------------------------------------------------------. T' h5 o% a* J. x. A
        // Method for testing that class has been reached
' c% s6 c$ L  Q# W/ Y. `        //-----------------------------------------------------------------       
5 w, s0 C& b' }+ u) e        public boolean AuthorisedUsersReached()
5 S" T4 h# Y  j, j" K4 O+ B3 n                {
1 d  F4 ^$ V, B4 k( K! h# Q) u                        return true;                        % x5 d/ i. `/ U9 J  Z$ w/ u
                }
8 b( O' S( O0 u               
: j( \6 R7 T' P- `" r. ^; Y    } // end of class AuthorisedUsers. y; a4 G3 E, b6 P/ T! M- g  C" d
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 s: @9 I! X, u7 W* ]Shanghai - 2007; J2 k' b2 Z$ g) a8 {- [9 |3 w2 i
Assignment 2' `: a7 U! P/ V6 f$ g/ ~0 v
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)
& \" o6 p5 W4 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.' ]' t9 `: E3 i+ ~1 q$ q
The staff must be able to:* I# {7 e$ b$ t
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 }2 L0 Z" U8 c: S4 V: G
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.( h4 e) O) @: s! F! Z+ D
 The interface should provide a menu so that the staff can:3 I' q: J  w/ [0 b
a) Enter the names of the two Java program files to be compared
1 E2 O2 S2 u+ F# n( s, O6 h For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 a; Q4 l0 G& S4 P" g** 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).
' \2 E6 b+ D- M' k5 mBSA104 Business Programming – 2007: Assignment 2( m0 v) }: E( p6 G0 C9 g+ a9 |- n
Page 2 of 5
9 Y3 {' ^8 [; r* Lb) Print out to the screen all the lines of code that are the same
8 U9 P2 L5 R, ^' K' C+ c3 ~8 t Include the name of the file and the line number of the code being printed for each of the two files
, \8 }6 Z  F0 X" L3 Kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared' O) X$ ^, Y. _; G
 the name, username and department of the user/ |+ Q% n; r6 @2 x
 the statistics of the comparison& ^2 T* [1 P% v( B  U6 G: G$ L
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
; }' `% ^& v8 S3 l# Y" h the recommendation for further checking
4 A5 B9 k+ X9 t* J, z2 y, w- 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
8 ~" P. I4 w% {. \ the names of the two files compared
* k3 Q: z+ U0 ]" t( @d) Leave the program (exit)& q7 [! X% y) m& b# Y- {) W
The ProgramCompare class: (Total maximum 20 marks available)7 |4 F5 ~" W0 L* t& `3 l
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)
  M& R0 a# Z; k% \a) provide an error message if the files are not found or there is a problem opening them
+ G8 D  c$ _/ E0 @b) compare each line of code
1 `' f& f  O' P3 B2 hc) print out the lines that are the same
2 t& h4 q: S) j+ y4 z/ f9 Zd) count the number of lines compared / lines the same
* d' l6 R6 I+ u1 @  WThe AuthorisedUsers class: (Total maximum 20 marks available)! ^" Y- v3 A! R2 R% _9 `" w
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)( b9 P0 X" t* d( A9 l' p1 p4 M8 K
4. Provide methods to:9 A3 z. k. f4 ^1 l
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) {( Q6 K! b9 [, J' `
b) return the name of the authorised user
7 i- V$ X8 V$ H( X, D- E3 l2 Ec) return the name of the department of the authorised user0 |: {3 T, |2 X) X# \" A- B
Individual Data (Maximum 20 marks available)
$ a& L) |* ?! a5. 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.# Z) k3 F/ k+ \* s3 a
Documentation (Maximum 10 marks available)% O* A+ M$ v9 w# T7 n
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.
2 Y2 ]9 I6 M8 e$ mBSA104 Business Programming – 2007: Assignment 23 ^5 B8 L! ^' `+ W- k
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( F# y/ y3 L8 V5 \! v* k4 C不过你要翻JAVA的类库说明。你有下载没有?7 R; B2 N1 O+ H- _3 A0 A
查询关于对比的函数。貌似关键字是contrast,还有compare/ J/ B3 w! X4 }

5 M" |0 ?/ j1 j. }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( g9 ]5 J& i* G5 r0 K3 `痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 O" M9 l$ P4 ?) p3 U  f; q& E
可以下载到的 是 jdk-1_X_0-doc
% P5 v  O6 _, [6 V; b0 b+ P4 @& j8 u
0 U* @3 ~; V1 }- B! j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-18 11:20

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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