找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1726|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 A0 |$ n8 h1 f( N+ l# ]2 X( d: k; n$ J- }# 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 | 显示全部楼层
//*********************************************************************
/ g! _7 y8 J! h' T//  ProgramCompare.java         Provided by: DRS# Z- f/ ^5 K, t, S; _
//
, S% v( O" Z" x; e9 i//  Program shell for Assignment 2' _" J" c% |( E: e3 m
//) u" R1 y; g# ~
//  Compares two text files line by line' b5 |- H& w. p4 n/ I
//*********************************************************************
6 I) r+ q" ?4 f' |. J( S9 r1 g7 N. |) w
import java.io.*;
! X" Q4 P: U5 R1 U# D: N3 W3 o- s* z
public class ProgramCompare% g0 n4 }4 ^1 N0 F5 X, S/ D
{( X' d& G% c; y, V5 m
        //-----------------------------------------------------------------2 Y: W: c) d4 |1 C, y: f( [% h
        // Constructor
$ c. H$ m. t* L7 B  V0 y        //-----------------------------------------------------------------  u. f- x0 @) k, _+ {
        public ProgramCompare()/ o) q$ j2 T( ?* |
        {. m, j* j8 R, _4 I8 d
        }# i2 u2 p7 w+ k$ ~
, T; R0 s* |& k. K  m
        //-----------------------------------------------------------------7 b5 W- [" s- j  b
        // Method for testing that class has been reached$ b, J  r8 [; ^+ q: g% M* K6 w
        //-----------------------------------------------------------------       
4 n" D) m! y( O' Q4 j  _7 E
* Y! b& ]6 _7 g( f# h+ _- ?0 G' r& J        public boolean ProgramCompareReached()        
6 A/ R: }" T7 E% }5 W* g2 c1 H        {
9 U- L. P: f0 L* B9 R" e3 ?      try
3 l, V4 X* w& i# L: N8 P3 B   {         " E! q( j& c1 c8 a8 `
                       
' V) G7 r) e2 M) q$ t                //********************************************************************
& }: p/ a1 ~8 k5 B% U. N, i                // Try-Catch Statement is used to handle exceptions - such as file not found
& N+ w2 J) {- j! \% d6 P+ m                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 Z! R+ ?8 H" Y4 @
                // For more information see page 534 of the textbook$ g9 v6 o: E( o
                //********************************************************************
3 ]/ d6 a  C$ J6 `& U                    
2 ]2 G) Y3 L; N% P6 m. o, [        }
" @; W' z0 c. R' U             catch (Exception ex) // Exception caught here and message displayed to the screen 7 }8 ]; ]$ D( M7 R5 q- M
          {' d, r1 b7 S- c/ h" h: Z  v, D
                    ex.printStackTrace (System.err);
( n) i) x9 h, {2 q' S           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 }. J4 N6 e) ~, o  A        }6 J0 _$ G7 V2 y4 W1 |/ j" K
                return true;
  L' S  T1 Y" N7 m3 |        }" }. F5 t5 h6 y% l! O& J+ \$ J
& G8 {8 v& K, A. k3 U
} // end of class ProgramCompare9 E& v$ [4 R  j# i7 t2 C
2 |* p( W; H8 J7 |$ o( \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, i0 J( Q0 x( A
//  ProgramCompareMenu.java    Provided by: DRS) ?0 D- g) a' G) e& b- q4 ]- a
//% q- m9 T) _" q0 Z
//  Calls AuthorisedUsers.java and ProgramCompare.java
: c6 J9 z% o1 V; O- c//
! s: Z( g9 r$ |4 Z//  Driver shell for Assignment 2.
% y' D: L; N- l4 \& T//********************************************************************
  V4 I6 f8 ^7 y% [3 W# D8 p  S- @" S, f7 z6 n) q# E& q
class ProgramCompareMenu
# c2 T* N0 F3 H6 b& T, r{
, i1 H" x  o, S  z# j8 V4 W    public static void main (String[] args)2 K) F8 ~. D1 d& T7 w4 S4 a9 X3 I
            {
" @0 ~) N0 p( z, K/ Y2 k, l! Y                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- L& [2 H- q& o  x                ProgramCompare reached1 = new ProgramCompare(); + p! B0 I( N3 C, g' U6 ^0 i- n
                AuthorisedUsers reached2 = new AuthorisedUsers();        ' m; a, b+ ?7 r6 \" }" T6 w
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());" b& w0 F4 k$ |* R2 C% ^* E
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; O! u& O" C3 l3 E4 O+ E" p        }
) Q1 L, n0 K/ C5 x}// end of class ProgramCompareMenu
' C, ]9 G+ e( n# f. ~! ^4 _, ?  g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 @3 F4 _$ n4 q( H! ~//          AuthorisedUsers.java          Provided by: DRS
* o% J( F3 v# x3 P( H//                % }" i6 o6 ^  ~4 L
//         Program shell for Assignment 22 [& d+ @9 y9 }7 ~1 |' y
//
# j0 ?% A, P  n% ]; B7 _//         Represents facts about an AuthorisedUser$ N& g$ p( i' H4 Y1 l
//********************************************************************4 r+ i; k0 M0 A5 [" ?! [5 }4 S0 Z2 [

6 n5 |' w8 T0 `public class AuthorisedUsers
" J/ h1 j/ ?. l    {8 Q9 \. X# {7 V' w/ r! ?
' T) Y$ I- u- \  `4 H7 J
        //-----------------------------------------------------------------1 a. d  F* z" O( t- Y/ T2 x
        // Constructor1 A. G5 Y0 W" j- l) @1 H) M
        //-----------------------------------------------------------------
1 P. V# o9 O: f, b8 O$ S3 q# [% _" ]% Z4 q. A, Z$ y
        public AuthorisedUsers()2 {. q* t; f$ c, P6 r
                {
& U: [* V7 q- z  E4 m  e                }
% U( r6 [+ [* W6 i3 j( C1 ?/ H; T+ ]- Z- C1 G! I5 k/ v1 s
        //-----------------------------------------------------------------$ A+ O% ?' D7 p6 `' \( i
        // Method for testing that class has been reached5 A' E0 }* `, S" o
        //-----------------------------------------------------------------       
) i8 a0 O8 p& t        public boolean AuthorisedUsersReached()9 U: F/ v6 @8 ]4 a3 t$ j
                {. x' S- m# e0 k0 ~$ u" d
                        return true;                       
$ i- Q( h. b. v" r2 I                }  g% e" i& S  v+ _+ i2 ^
               
; |' z! _% Y3 s6 P    } // end of class AuthorisedUsers3 u) Z  v% u  i( H; R9 y+ e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. p* I" y+ @  A/ g
Shanghai - 2007
3 R: Y/ Q& H+ c+ t* X* h* nAssignment 2) D* f0 G, }3 _& x
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)
4 G: ?2 C( A" L" C9 e1. 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 g1 G2 l. U& c1 Q" A+ OThe staff must be able to:
) C4 G  G# s8 c' h0 l Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 t# v- J" h+ v/ w9 w; d& u5 G6 `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.+ @( ~: C& I% o4 i
 The interface should provide a menu so that the staff can:2 r: j$ Y, q! K1 Y
a) Enter the names of the two Java program files to be compared
" N7 ~! T+ `+ d5 o! C For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 s7 m- x6 t  o2 r" b7 b' q
** 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).
% U5 L1 q; K4 {/ t. |BSA104 Business Programming – 2007: Assignment 2
( {5 p+ X/ S4 b+ z0 i. [Page 2 of 5
; ~- ]& l. Z, o; [- x' nb) Print out to the screen all the lines of code that are the same
! k# T4 H3 s9 P: O6 G0 d& Z Include the name of the file and the line number of the code being printed for each of the two files; s4 Q! F( Z4 J) f0 I9 a8 C
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 p4 V+ S5 |& m0 s) v! {( k the name, username and department of the user
, h* @3 Z5 U$ ]# t9 ~ the statistics of the comparison
0 H: I/ b9 _1 q) p7 R  N/ k5 P3 M- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 S! g; {' b1 ]; M: C the recommendation for further checking. [/ |+ U" B$ K" v
- 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; o" I  h. o9 m/ `$ w. l
 the names of the two files compared& n' T4 H' t7 D4 O8 ?( [
d) Leave the program (exit)( a& S; @% G. I. W+ u3 q
The ProgramCompare class: (Total maximum 20 marks available)" Z- Y' l, n( G( [2 F
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)
0 q; f4 {! F# v0 _a) provide an error message if the files are not found or there is a problem opening them
6 ^  i5 C. S. x2 a6 c+ xb) compare each line of code
9 |0 y, J* F$ \7 Vc) print out the lines that are the same
: l" k, O" C. @- Qd) count the number of lines compared / lines the same! s0 E/ R( @; @; _
The AuthorisedUsers class: (Total maximum 20 marks available)) @  v$ y. [' r, j
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)+ P/ t( X" ~6 y: U, w6 H/ @
4. Provide methods to:- c  w3 j6 b: ]: q$ @0 a5 D
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 match0 Z4 i& {0 r+ d& M* _3 q
b) return the name of the authorised user3 D! S7 q/ c, b+ g- f! u
c) return the name of the department of the authorised user
9 Z) I! |/ R7 r2 {5 QIndividual Data (Maximum 20 marks available)
8 \" m3 \2 q+ A' c5. 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.
7 y0 d. o& W2 E& ^& z* j( FDocumentation (Maximum 10 marks available)$ ~+ w( i. v' U
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 @; }1 Y! q0 w+ Q4 w% R
BSA104 Business Programming – 2007: Assignment 2# o9 U% c5 c5 ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- n' p- M. t" g% H/ |- G/ G; a不过你要翻JAVA的类库说明。你有下载没有?* b! V( j$ A, i, o0 t
查询关于对比的函数。貌似关键字是contrast,还有compare& B' E7 T2 A5 N& Y2 H4 H7 s

2 c) t0 H, i! z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -- W$ e7 x2 W4 r) X, {; w# d/ U
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- Y& r0 x' J! i) |: h可以下载到的 是 jdk-1_X_0-doc
" E) Q  x5 Y( b7 V5 u' w: R% T+ U9 K6 U" S  }
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-15 05:28

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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