找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1360|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急. U9 K% @ j1 X0 Z + _: c# U# M- t! ?5 S
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ T/ K0 ?5 A* i2 B: m! d* X//  ProgramCompare.java         Provided by: DRS3 O, ?$ U4 w- j1 Z1 G+ p' G
//( X! J# Z7 {; y! \% E0 `0 r! V! N0 [
//  Program shell for Assignment 2! _% n/ `. P9 \# L3 B4 R% V
//
( v, d" y, h9 j$ ?//  Compares two text files line by line
$ i' n4 I6 R4 M9 B4 @. J0 d. _//*********************************************************************3 b" G2 O& l: o, S
7 m4 o' w, {/ E( u" h
import java.io.*;
4 t4 E. h+ q6 ?6 x, y8 P' a1 }& u- K& X$ O6 i
public class ProgramCompare* W- |) I5 P* J& m6 R
{5 O9 V8 J4 \1 e' u
        //-----------------------------------------------------------------3 p; N5 H" j& d# \
        // Constructor0 s; m: E. {2 g8 Y2 d9 Y
        //-----------------------------------------------------------------
) p) C  h' \- O/ h        public ProgramCompare()
7 }4 y4 B4 d4 r( g! p- y2 D3 s3 p        {
; _9 c3 d( w+ Z; L7 P6 J        }
6 \% N3 b& j, B% E4 i
1 B2 F0 S7 H( Y% }7 P        //-----------------------------------------------------------------2 V# ?6 ], `9 Q+ L+ G5 x( }
        // Method for testing that class has been reached
6 U  [) B, ?9 f  |* ?6 w- u        //-----------------------------------------------------------------        : |4 t% f0 o" E9 e  I1 Y8 |

, G  z- X  J: S5 t$ d8 w& K9 H3 Q        public boolean ProgramCompareReached()         9 Y' P) Z6 T( ?
        {' r" p; {2 v; Y3 P5 v
      try
5 `1 t1 V$ P4 Y* H   {        
) @3 `- O+ g& Z- @0 H                        0 }6 x/ K# F3 d+ Y+ A
                //********************************************************************" W- W9 m7 X+ ^! a3 q
                // Try-Catch Statement is used to handle exceptions - such as file not found ( M, x) j7 C; |7 z
                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 w! {3 Q6 Z4 A
                // For more information see page 534 of the textbook
0 P' N7 s: F5 O7 C2 _                //********************************************************************
% j' K3 N) L5 t+ J* _, Q) X& B/ D                    
( U0 M& Q" o$ R3 k        }
* f6 h2 V; [# T% z+ w1 s             catch (Exception ex) // Exception caught here and message displayed to the screen 3 F0 J- U2 I( d% x, |
          {
  p8 Q  g" |: v; E" R$ G                    ex.printStackTrace (System.err);
/ a& y/ U) W! e% D           System.out.println ("Error message goes here"); // Replace this error message with your own          ' m" o3 E* {3 |
        }0 ?5 |& G0 @, F+ w
                return true;  y! K2 G3 y$ A* O1 v
        }
5 w& m2 b9 L3 c. I) o* N7 R& l, Y" G8 w- q5 L/ z" U6 r
} // end of class ProgramCompare
7 |; C$ O( u5 ^1 u# D; H
. q8 Y4 D( r$ v# ~5 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( x; E: J$ `% E5 ]2 p3 l6 W
//  ProgramCompareMenu.java    Provided by: DRS5 i8 @. b" o$ P- x! |
//
, X. R0 {4 [; \- E//  Calls AuthorisedUsers.java and ProgramCompare.java$ K# H% y7 ]  i5 I, ^0 A( G* b
//
% p  }5 n8 ?% ?  f2 f3 X//  Driver shell for Assignment 2./ C  M" v$ |+ n! W, t( A& ]0 z
//********************************************************************4 k7 ]: k/ M& b, P6 J) D1 a) J
1 F7 I9 f8 U0 t! b  Q
class ProgramCompareMenu- {, _; w' H& U- Y
{. B1 _% D/ J6 O9 y8 d
    public static void main (String[] args)+ x* g1 Y" u4 X" m4 [
            {4 Y* B- f: E* h; Y. `1 o4 N
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
/ o# d  e& B5 T9 v6 |8 K                ProgramCompare reached1 = new ProgramCompare();
- B7 w( p$ X7 [. U8 o5 R) }. b4 ]                AuthorisedUsers reached2 = new AuthorisedUsers();        1 c8 O0 t. T- L1 H+ j1 Y9 \
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# p$ v6 y" F0 V6 S* u5 w+ t6 n
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 @7 D! W8 }  j/ N  j        }
+ F! V7 X  m, C  E2 ]}// end of class ProgramCompareMenu% _0 G  o$ c, o# d: ~

# z& Z' |9 |, t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
& q* I' f6 i% b# L! p" ~//          AuthorisedUsers.java          Provided by: DRS
6 l/ Q- V# S/ @5 l  v//                & i/ Z8 a4 Y' @6 s/ ^4 e' |
//         Program shell for Assignment 2( r5 n3 S  D7 r' p+ D* N: j" d7 b
//! ^) U9 a4 b7 o
//         Represents facts about an AuthorisedUser" ~1 Y3 {( q0 l8 O% ]
//********************************************************************
. [  c- b) L) F1 Y' ]- ^7 Y2 f9 C9 Q* w- F  w6 H
public class AuthorisedUsers9 U$ b7 D+ t) y# p) p/ t! y7 e' J
    {  }* h$ A0 i9 Z' E" _
5 p0 c8 B2 g6 ~4 ]/ ]! X6 ]
        //-----------------------------------------------------------------* [" Y( S7 n1 _( Q5 c* i- }
        // Constructor5 D- a- _- ~  P' O( X3 {8 A
        //-----------------------------------------------------------------' N* O! K" a  o' h: b: m/ @  |+ l
: T, \5 ]$ q/ I* H
        public AuthorisedUsers()) }9 R$ q- e6 q. Y
                {
1 \$ {( P% ]1 a; q8 }+ X                }
# t" Z* M' l  o% i0 m/ N/ O6 O7 q7 o4 f4 [% J
        //-----------------------------------------------------------------" ~+ B3 L% k* c1 d  k0 b' k
        // Method for testing that class has been reached
. U. n. {. K& }4 }4 ~8 U        //-----------------------------------------------------------------          Q% g6 ^' w8 ~2 w' L
        public boolean AuthorisedUsersReached()* b4 I! H/ Y4 Y* B6 C; i
                {) N/ P; d: D5 O0 W; [
                        return true;                        9 c$ s  u  K+ Z+ u4 ^/ p, E
                }
; [4 B$ D" K% D               
1 \. U% q* _7 V$ T0 R2 A4 |    } // end of class AuthorisedUsers
2 k, Z; @5 f: `/ o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! \+ |( z9 Q3 m) cShanghai - 2007
9 O* A* @6 b" \; w( M2 m/ UAssignment 2
; Y0 C6 N9 W# H/ X4 fDeadline 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)6 Y/ ]) v* I/ @9 Q  {3 A+ [
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.
6 ?! D" k* [7 t* a# V5 {The staff must be able to:  @) ~: D! ^# @
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., [0 m6 i% k7 ~6 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.7 I* E) l$ h  i4 O2 ]) R, c
 The interface should provide a menu so that the staff can:
* q9 I; W% W. S6 O6 za) Enter the names of the two Java program files to be compared! f3 u% M5 S: T6 A$ b: e. ]
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% S! e+ q  g  q$ b; m0 P  l! V6 M
** 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).& I7 B$ f+ \2 e' _" g
BSA104 Business Programming – 2007: Assignment 2
# {5 ?# z" O0 R9 {9 ?' f9 rPage 2 of 58 M4 P1 ?: N% P8 s% R& }1 P3 W
b) Print out to the screen all the lines of code that are the same( \5 Y/ ~/ o/ ?0 v8 P5 x/ a* ~
 Include the name of the file and the line number of the code being printed for each of the two files
  G' M- v" F& s' v. Wc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. M# B& ~- d) X3 G' o' p' Z; V# h the name, username and department of the user( O# j' W1 W2 h
 the statistics of the comparison
# p1 `! q* ]# b  g9 e- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* o7 q' P7 H) b1 y, G0 T% f' R# Z the recommendation for further checking. ]% ?3 M- q( I/ [2 f
- 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& D8 u+ T7 G1 A+ y' G
 the names of the two files compared
' c& \, `2 K& u2 i8 T* x  Nd) Leave the program (exit)9 l) T5 N! b4 w0 G, K: a, s, X. i
The ProgramCompare class: (Total maximum 20 marks available)+ P- k; ?! Q: e0 {9 }, u6 W- `
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)
$ G3 U7 D5 F" Ja) provide an error message if the files are not found or there is a problem opening them
3 S1 ^& E* \9 r3 _b) compare each line of code. l$ t+ Q+ F% c$ K
c) print out the lines that are the same9 h% y" y( ^" S' [3 E8 g0 c6 i0 j
d) count the number of lines compared / lines the same
9 G0 H2 _. M4 B6 FThe AuthorisedUsers class: (Total maximum 20 marks available)% I. k4 H6 m; 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): r* \$ n- e9 ]( F" O
4. Provide methods to:
' I& V% q( E) 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 match6 b% q7 g7 b+ F' G$ D  ~
b) return the name of the authorised user% D" z- E; y. _1 X" X% e! `
c) return the name of the department of the authorised user, q+ A: @+ p9 A7 l3 G1 c6 Q
Individual Data (Maximum 20 marks available)
# R2 _1 ~5 f6 _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.
8 C4 C$ f: l, O/ kDocumentation (Maximum 10 marks available)3 m- E5 i* s/ X1 t
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.
' I4 q6 f) T$ g! m( iBSA104 Business Programming – 2007: Assignment 2' n. I- [- Y9 {  i# y3 {
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ s+ ^; S( j8 o不过你要翻JAVA的类库说明。你有下载没有?% F/ h: t5 G7 H5 W9 v6 y2 Z
查询关于对比的函数。貌似关键字是contrast,还有compare4 b4 k$ A4 a! O3 a( O% Y& H

) m* D+ q. \. P( L" a5 S[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
0 a  [. [# z$ \1 H痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. j; j3 e5 E1 Y' z可以下载到的 是 jdk-1_X_0-doc; c( b! O% P, s$ m0 R3 g
0 o* u/ b4 V7 i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-7 08:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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