找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1405|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 p& B9 o. M0 Y4 D6 |* S! S9 W/ T" @% A- V2 e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
5 O. E- b8 u- J" a( t- d//  ProgramCompare.java         Provided by: DRS
3 ^8 f7 p6 }" _) }//; {, z+ `8 a! F8 R" e: k9 f
//  Program shell for Assignment 2' ?( d. Y. ?! E, V
//
& Q" U0 j1 h2 M4 J. b//  Compares two text files line by line0 M/ l, a8 K0 m) q% [5 k1 c
//*********************************************************************, q  V' r  V+ N" p2 t1 e5 m8 V

, ?2 u2 D5 D3 Eimport java.io.*;
4 u. g' Y% Z* `: u% s$ d$ c9 V
; E* S" O) b9 v0 R4 s9 M% epublic class ProgramCompare1 e8 {* [& b! n7 ~9 ?4 }7 q
{
" k3 O4 B" B( e, U) ~- V( I: I* ?        //-----------------------------------------------------------------0 T$ B3 g- q- n3 i5 v! a
        // Constructor& p% Z% S1 c2 e8 w8 u$ \
        //-----------------------------------------------------------------9 d( s7 t8 j* K, H* Q
        public ProgramCompare()4 |! ~' d. U& Q  l) L- h6 f
        {$ q9 E' [3 M' q! s+ @7 D# L8 z
        }
; r# _* _* f2 ~1 m  T# n: ^! j4 b; D6 N  d# q) Q2 o* D
        //-----------------------------------------------------------------( \1 d1 b; o5 J1 o* ]  F
        // Method for testing that class has been reached
0 s9 t! l: r/ I5 ?4 x        //-----------------------------------------------------------------       
7 J$ V7 k1 ?% Y8 z: t/ X  }5 {# F% \% L
        public boolean ProgramCompareReached()        
/ M' c5 z! |) O; d6 s        {
+ P8 |" @, E5 I; Q      try
9 o9 j, c$ ?( f5 b   {        
! r7 ~4 E5 s% \4 g: P3 ^" N  ^+ W                        # [( v9 W2 o& U. ?( f& K7 S: T" U! H
                //********************************************************************
  [# G5 ]' @+ f  k/ `6 d9 R8 C                // Try-Catch Statement is used to handle exceptions - such as file not found
  B: K$ _* P- m/ Z                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, q0 H/ C2 e8 E2 A9 x& J5 T* d                // For more information see page 534 of the textbook
  L3 I! X  b3 I                //********************************************************************
& D/ E% N6 ^( B( V7 P9 v. c                     5 P& I! b( z+ T4 E4 Z+ K
        }" E% p& b% e( E* p: H2 j; V8 j
             catch (Exception ex) // Exception caught here and message displayed to the screen
" J' @7 y$ X& R9 n8 r          {4 b4 S, }4 S; G: Z6 I$ x  N" |, @0 J' B
                    ex.printStackTrace (System.err);
# H+ C$ g+ @. C. m! V  R8 ~           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 l) a7 q6 N* P1 K9 k) Y& R! ?0 z        }
, T" }6 @4 B' E0 ]- z2 k% b$ w                return true;
9 F6 S6 p8 w# a: Y5 b. U        }8 X9 o+ J9 X2 d2 h
# v; j8 U) p) p3 a7 A
} // end of class ProgramCompare
% k8 R% d# Y9 g- a& `# B6 b( v+ m1 W; B4 S, F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************: q) `  I/ N3 v0 r8 S
//  ProgramCompareMenu.java    Provided by: DRS
4 K) @( w/ o4 U. p8 Y//7 Y! t, p9 U8 b) l3 J0 Q
//  Calls AuthorisedUsers.java and ProgramCompare.java* \4 H+ T' s7 i- u
//4 r: _$ J1 d2 R9 }6 D- V
//  Driver shell for Assignment 2.% n  O, k# ^) |2 h5 J
//********************************************************************& C* p4 E6 z, @4 `9 v

) ~: J( y/ G/ k$ q; G/ Oclass ProgramCompareMenu
( ?. ~* ]+ k+ m8 P) F. @" K{+ U% G# g" ?* c; v3 e# {
    public static void main (String[] args)
+ ^: h) F9 p( ~, q, X            {9 X# Q4 C+ W1 D  }* |6 h
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
+ F& Z: q$ Q( K! n                ProgramCompare reached1 = new ProgramCompare();
/ C1 M# w* f% Z                AuthorisedUsers reached2 = new AuthorisedUsers();        / \6 i, F* Q* y* @8 B
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 r7 _4 ]2 p: `7 a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 j+ A; v+ Q* O" B" G* w        }
6 X, ~& g  v1 T# r8 t}// end of class ProgramCompareMenu8 w" a8 n- _2 j% e

/ K8 c* z+ u, J" ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************/ W  v& h9 ^- ?1 b# r2 C8 z; R
//          AuthorisedUsers.java          Provided by: DRS1 ^( C! ]  f2 q9 ?! }$ q) v
//                ( M6 Y( K: c$ f' L1 o
//         Program shell for Assignment 2
; i" N& e# x; L) M$ P) t//
- w* R; s) T5 K//         Represents facts about an AuthorisedUser+ n9 m7 D8 f& w, {! U3 |0 S" M( O
//********************************************************************6 v4 N) \0 Z3 w& _, Q" n, r9 H5 q
+ U4 x/ v8 Q" h% ], \9 R. w% z5 Y. x
public class AuthorisedUsers
- E' m  q! B5 G6 h: R% x) X& o    {
8 J5 d& y( Z7 e2 ^* V* }% v5 }5 R
6 z9 h5 h7 A5 [% \        //-----------------------------------------------------------------
5 L  \  y! b1 j! O        // Constructor
& v3 r3 k" u% M) p/ A, v( o        //-----------------------------------------------------------------
9 S4 O0 H- m; w% h8 _/ y3 T% b& E! f) T: ]. n, u
        public AuthorisedUsers()' _; y" I( R0 x* @& v: Z% }: p
                {
# `$ O) b( M" a. H7 I. q% [                }
9 [5 ~' s: U& v/ d' v# l/ t$ T) L9 N6 L- \1 A# [0 J) ^2 V
        //-----------------------------------------------------------------. |' y3 w5 m! K8 U% W4 a+ B. L" c: V
        // Method for testing that class has been reached! k7 @3 q; ~( E. h- |  q
        //-----------------------------------------------------------------       
+ b: W2 B4 W$ ~. C5 A. u        public boolean AuthorisedUsersReached()* X) b! ]' j9 \
                {
! ~0 m$ p1 Y3 L) X& J% ^                        return true;                        6 e  e5 ?, V* W/ s% w
                }
" b: H, T* t& Z9 P               
* i% Q7 G/ h3 v" J    } // end of class AuthorisedUsers6 `, ?# \' W7 @* }3 O6 v
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming0 ]5 ]5 v6 h5 p! X5 U; _
Shanghai - 2007
& E( w$ z  R3 \! K% T4 zAssignment 2
; p1 W/ l" P9 _$ R* _) O" |5 ?; `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)
' c$ @$ I8 B$ h8 A7 C1. 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 f6 p" i  A, o* ]' x$ ]) JThe staff must be able to:* ^6 i! O8 ~4 k! }. }* J  L2 e  T. E' h
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# O7 n+ q( p9 z1. 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.
, s. r& t* R8 K* {  j The interface should provide a menu so that the staff can:) I3 o" o7 W) o$ y
a) Enter the names of the two Java program files to be compared0 V, O" f6 p% B. @) g; ~5 E
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 A0 E$ r) f" |; 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).
" ?2 _7 s7 z+ i/ X0 QBSA104 Business Programming – 2007: Assignment 2& z; a5 B+ q$ ?( |, B3 V6 m
Page 2 of 51 Q2 u8 K' y  ?7 y, V
b) Print out to the screen all the lines of code that are the same
" D5 U$ O. i! ?' u. t Include the name of the file and the line number of the code being printed for each of the two files$ F& [# t  L5 G. `; b4 j
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& E" ]/ s) B! a9 D+ [
 the name, username and department of the user9 P0 h: ~1 b* y" z! U. v# F* p
 the statistics of the comparison8 W. e8 l8 ?! W3 O( ?4 e/ w
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 R  V# j; ~3 j the recommendation for further checking
. T& A, E+ u* N. r7 V4 {" X- 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+ X8 x% E! i7 o" I3 M
 the names of the two files compared6 g# r, D: R' q0 Z& ]
d) Leave the program (exit)
/ ^; t8 b$ t7 rThe ProgramCompare class: (Total maximum 20 marks available)" y% a/ K4 z6 }
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), `& B! I4 _8 ]
a) provide an error message if the files are not found or there is a problem opening them, J, i, \2 D$ P- {
b) compare each line of code2 Y0 p/ I7 o; e  Z% w0 i2 i1 q- k! E6 v! P
c) print out the lines that are the same
7 v9 {' U: H% bd) count the number of lines compared / lines the same+ w* E$ h3 _8 P. N. w  R
The AuthorisedUsers class: (Total maximum 20 marks available). B; D+ v( l) M) @
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): }: x! q/ ^( X! A% ]
4. Provide methods to:, l6 q1 k1 u/ [
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
0 D( ~8 N" v* C& @+ ab) return the name of the authorised user1 G/ M( A6 l! B" a0 B  ?" A, r2 @$ B
c) return the name of the department of the authorised user
! d! n$ H% ^! AIndividual Data (Maximum 20 marks available)' z" k  N. I, B2 O$ f- }
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., C, Y, f1 }% w0 ]8 G
Documentation (Maximum 10 marks available)
- s! |6 c- c+ y0 H1 J( P6. 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.! N* _3 D. K% w4 H( ~
BSA104 Business Programming – 2007: Assignment 2) F3 L1 I- N* j3 L5 k1 L
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 \  ^  T' m8 M5 |) a# o; C3 @: w不过你要翻JAVA的类库说明。你有下载没有?, `4 v1 d- \: j; F8 k
查询关于对比的函数。貌似关键字是contrast,还有compare. ^- c: ]# A6 w  A; a7 y/ [
& r! [' @6 h$ Z* E9 p; Q1 a0 v5 f" e' d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -) G6 B% I) n! H! y
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* Y3 a8 E9 Y9 ^) m可以下载到的 是 jdk-1_X_0-doc
7 o2 X( @3 m* n2 Q/ J5 |4 l: z5 ~0 q4 O9 q$ H% R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-23 09:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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