找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1456|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& L! c4 k" I/ ]( q; J# H% v ' g/ z Z, d8 V6 B' c
回复

使用道具 举报

 楼主| 发表于 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 H3 \: s6 O" Q
//  ProgramCompare.java         Provided by: DRS
' h/ D$ |; |; z9 t7 K//* Q$ w( ^3 j$ L& B! u6 }/ _
//  Program shell for Assignment 2, G; K4 U$ `4 b1 v6 q2 [1 U" Q
//
9 y8 [& K3 D$ F  y' j6 C3 g# q& B; Z( ~//  Compares two text files line by line: d, ~; j, i3 V' E6 G" f
//********************************************************************** R9 P$ v4 s' k  [
3 e$ ?! v2 J- T7 q8 t+ a
import java.io.*;+ N+ c3 v0 ^: `% q

$ F& [- C: N- e5 X/ Npublic class ProgramCompare/ H$ N8 A& D# i
{
5 V' {5 W( R  l; M; @        //-----------------------------------------------------------------0 p) T! n+ \5 ?2 r1 Z8 C  _
        // Constructor
' F% J$ W( W4 j4 X  p        //-----------------------------------------------------------------1 \2 o! k0 h6 X  q& }& z* i7 a# ?  }
        public ProgramCompare()% r3 K1 C9 h3 p/ l# A( |. o8 e7 O8 ~
        {
; F$ F' f' S7 T4 V        }% W4 E; R8 T& V
2 I6 _/ \6 t) O5 y0 y
        //-----------------------------------------------------------------
5 j7 V9 v- j( v6 g3 ^        // Method for testing that class has been reached. }& N! r6 h% }
        //-----------------------------------------------------------------        . M& D1 A( ~1 T7 t6 F- X

1 |: |4 T- k0 q        public boolean ProgramCompareReached()        
/ {+ A, K* M& I' B5 \        {5 H4 ~, s/ u1 L5 V* a5 ?- I# _
      try
: z/ e( l% K: [( o   {         , h% ~! X% a& t" x6 r
                        - i: ?) l. Y  c7 m1 `6 h
                //********************************************************************; @8 I3 U$ D! u  {5 o3 W
                // Try-Catch Statement is used to handle exceptions - such as file not found
% a# \$ C: |) l( q. A1 u8 y5 n8 i                // Reading the files will need to be placed inside a Try-Catch - just like this one!
" d2 S. R2 }4 L                // For more information see page 534 of the textbook" E! t  p$ r" N3 d6 G
                //********************************************************************. B4 S8 D3 I3 M3 w% k" D4 P
                    
% }- A" T0 m' N        }( z3 Z/ Q* [: l0 D, o/ E( l
             catch (Exception ex) // Exception caught here and message displayed to the screen
/ ?: L2 L7 _% {( k( m; F7 R          {
# s1 b9 M3 ]. f" x, {2 B& [; a                    ex.printStackTrace (System.err);
) k" W& W0 }" G7 ]5 H% @           System.out.println ("Error message goes here"); // Replace this error message with your own          4 v$ J0 D: F8 v: G# P! g, |
        }
- R. z4 O  X& k! ]                return true;
; G" E4 }, D$ g+ y( }2 G) y        }
6 |% Q% ?8 \+ O' c9 O$ H9 Y/ A
$ x* @  @( H+ }$ a} // end of class ProgramCompare
& L8 z8 L& \9 e3 r8 t4 w' g
4 `' a( Z" q; \7 L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( D# Y7 y) ?0 i* w2 ?
//  ProgramCompareMenu.java    Provided by: DRS0 E1 H, l' G4 G. D
//
7 o* ?( S  M$ d# H. \//  Calls AuthorisedUsers.java and ProgramCompare.java
: v( n; ^  J# {  `/ k+ R# b6 |: p//. |+ l+ b: r. T: [8 v+ C6 l
//  Driver shell for Assignment 2.0 X5 ~+ Y5 X6 A* w& ^9 v
//********************************************************************
8 `* U) d! y! w* U8 D
9 a; F$ n2 q1 ~2 s: d9 J& R6 @class ProgramCompareMenu% `  Y% O6 M, y# |3 @4 i: N
{
  g; ?/ f9 T; e7 h, o6 p    public static void main (String[] args)
' M# z& W$ u9 y- B$ q+ ~            {2 g; y- a3 C7 e
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 Z! _( X+ A9 E8 X
                ProgramCompare reached1 = new ProgramCompare(); " m4 V  I: q8 f; u
                AuthorisedUsers reached2 = new AuthorisedUsers();        # i2 X/ h9 t7 K' j" d
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
1 z+ l. M3 x! k                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
9 E- }( F+ {: Y# t+ E        }
8 E3 m& z( ~1 E/ c. L" P3 V0 X* Q# ^}// end of class ProgramCompareMenu
# t5 [+ N1 {5 H9 S1 e* ?5 b- G
$ `$ N/ l) U1 _6 H% \) @- J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************; D% ]5 q& x8 w2 ^
//          AuthorisedUsers.java          Provided by: DRS+ p% ~3 a7 `5 w4 C. w
//               
6 a0 C9 F: r. w9 d3 `//         Program shell for Assignment 2
/ A& j9 x% u1 f//2 M2 T3 T% y6 B
//         Represents facts about an AuthorisedUser
* q" R1 _+ `+ v5 L  {//********************************************************************
& Q/ O" U7 ?$ n- x- g
3 i- {  W5 i8 o+ _4 S- D* ?! i" x. {- @public class AuthorisedUsers
8 z3 k- z0 i# b3 ]    {3 F9 B+ H5 L/ o2 x; _0 x' v: c

- r! I$ l: u. K        //-----------------------------------------------------------------
6 f" m& g& q; ]: _& K3 N        // Constructor9 F1 Z% C5 I4 g2 b; Z8 v
        //-----------------------------------------------------------------( b5 B* |8 S. V) r# h8 E8 \

7 B& [- P4 a  V        public AuthorisedUsers()( Z+ j3 b6 Z7 z3 t4 T& y4 \
                {6 c' W. X% n6 ~. F" r- E  l
                }: |  X0 _* j) C; R
& j2 E* p5 ?4 e
        //-----------------------------------------------------------------
# \& l4 j: N& R. v+ `2 t. D        // Method for testing that class has been reached
3 v; n4 A' S; o9 D/ A4 R8 i" e! L        //-----------------------------------------------------------------       
/ {- {. d9 W% L+ a0 q* X+ A- Z        public boolean AuthorisedUsersReached()0 \( V1 u6 A2 e0 C7 d% x2 [4 b
                {1 A0 M/ a3 H; [: b
                        return true;                       
; e4 f/ K* S+ d& C( \; S/ w                }
7 S6 o! @3 _# T# |5 g/ O0 r" }                9 f, V% I: R1 \. \) ]2 J5 i
    } // end of class AuthorisedUsers
( U9 l3 N+ Q- u+ S6 _( Z5 T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( M. y* T; B/ C* DShanghai - 2007
7 M2 r. g! R/ ^" O5 w$ jAssignment 2
; n" F& M3 B9 YDeadline 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)0 V- r- M; K- f/ U7 }
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.# m4 O; T+ g& h, Y$ D3 u
The staff must be able to:
5 k# A& S4 O4 g" v Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
8 a. c' N5 ^/ s* K3 @2 k) v* O1. 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.
  Y8 @8 T' t5 m, o The interface should provide a menu so that the staff can:0 Y3 _* A4 j  Y4 ]# z5 q
a) Enter the names of the two Java program files to be compared& G. A; |8 f( ]5 _& y" V
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program./ b3 g8 u2 K3 Z7 A8 ], w
** 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).
) n/ @% Q+ ~. b* r% X# jBSA104 Business Programming – 2007: Assignment 2
3 y+ _0 u7 C3 CPage 2 of 5
8 r; G; J  _8 B: H& O7 s% y( P! l# ?b) Print out to the screen all the lines of code that are the same& M7 }- E: a9 H/ ]. E' B/ K( H7 m
 Include the name of the file and the line number of the code being printed for each of the two files- R* F. v1 _0 x# k
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! q) q& R" a- m0 r  ] the name, username and department of the user
2 w  o: r* n  h* x8 u8 @' Z& y the statistics of the comparison0 p$ E( _1 ^, N4 c1 r
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! \# C( i! Y0 W+ n/ O the recommendation for further checking
2 W0 d# M6 `# r- 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
- s) B% ^5 d2 x! D: i the names of the two files compared
' r6 P! {3 p7 Y( v' fd) Leave the program (exit)4 `' A% g1 u! k8 M5 X% m. \
The ProgramCompare class: (Total maximum 20 marks available)* Q) Q5 Y. ^* r& P: 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)
6 l  K0 K2 o6 F* u6 u) _a) provide an error message if the files are not found or there is a problem opening them. G  D7 t: I! ^2 b% \1 Q$ h; h  g
b) compare each line of code
  g1 r, T9 z# D; X' e, Qc) print out the lines that are the same
, t1 @1 T) j$ C% ^d) count the number of lines compared / lines the same
6 _& R/ A1 z& Y+ Z% TThe AuthorisedUsers class: (Total maximum 20 marks available), n$ g" N: l% B! r; l
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)
% O/ Z. H! m' m# D9 ]4. Provide methods to:
8 [- h6 {% v; t% O0 oa) 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+ R+ V& T: R# A- t% T
b) return the name of the authorised user
  p9 P9 @/ @) u# E5 Bc) return the name of the department of the authorised user1 k' s2 Q1 F0 [* \5 v
Individual Data (Maximum 20 marks available)
, s9 `0 `( c- U. m- ?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.+ m1 \. O5 R4 a7 c+ D: x
Documentation (Maximum 10 marks available)
: A6 i9 \( u4 ]% j& C6. 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( r& {  k2 z6 [+ ?# _, [
BSA104 Business Programming – 2007: Assignment 22 i# @1 K0 Z2 c; c: T& y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
) D% z& i: u8 m( v+ P不过你要翻JAVA的类库说明。你有下载没有?0 w) |/ U! G- m8 `
查询关于对比的函数。貌似关键字是contrast,还有compare
$ [/ R+ u8 V, r* w/ ?2 P8 D# Y' r; |  @7 m0 ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -! r, J. O3 }7 k) f
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- t) y2 {+ b2 z( E7 u可以下载到的 是 jdk-1_X_0-doc5 V" s6 r% h7 J
) s8 }, J7 Q; I& ?' i( x# `) B
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-14 07:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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