找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1520|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急# o' q0 j, Y, n5 ~% m 0 n1 ?# U8 S" P9 ?# {2 c; C0 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 | 显示全部楼层
//*********************************************************************
# y. t# v- X8 g# r* |: W//  ProgramCompare.java         Provided by: DRS
! u$ n6 k' P4 T6 q//
. d. `' M! V5 ~" g. i  {//  Program shell for Assignment 2' [7 ]9 p& M0 z& @7 w; J* S
//% m; k! z5 a: x- P
//  Compares two text files line by line
# T$ K# Z1 g% W. N& P6 b  r//*********************************************************************& @4 K  \0 d. [5 X2 w& k
: q$ G' l3 ^) R
import java.io.*;5 ]* O# z- k+ m9 d

  b' {0 {: L' ~2 L, `public class ProgramCompare
/ y6 d: x' R: _+ b! z  j4 z{" G2 f6 s3 t4 A8 D
        //-----------------------------------------------------------------
; h8 E: M% f3 B2 d1 Z. T4 I+ r        // Constructor$ L" c8 r: _6 E8 n  h
        //-----------------------------------------------------------------& l0 \+ \- c& Y! i9 T/ V1 R
        public ProgramCompare()
# R- i* |0 z& y6 H3 x        {- }/ _& c. ~( w2 {
        }
0 y9 [  Q! V! L4 T) Q) b+ ~1 L; V" i1 z/ X8 ~4 e
        //-----------------------------------------------------------------1 q* ]0 W- ~6 _7 \  {* H! z; S
        // Method for testing that class has been reached
% B5 W$ Q. t% o8 A% A- R7 N+ |3 p        //-----------------------------------------------------------------       
9 F7 w: Y0 d* D; }9 l1 i: @1 ]
        public boolean ProgramCompareReached()        
  f6 F  C* p. o* v- o        {" |( Q3 U; T5 H7 }! ?
      try
) j6 n3 K7 m9 z+ Z! c* P. @* ]   {         6 J, ~/ D0 {5 A5 R
                       
& |/ L6 U1 l2 b1 p                //********************************************************************
! T6 ~; I9 ?; \) j1 `/ m                // Try-Catch Statement is used to handle exceptions - such as file not found
" L( |8 i: w( B! r1 @4 D                // Reading the files will need to be placed inside a Try-Catch - just like this one!  k) P& A, B4 s  \" T" N7 P  R
                // For more information see page 534 of the textbook8 X- e! f' c" L
                //********************************************************************
) M2 ]# }( G" L5 P) |; y3 [                     " v8 o9 a# S  a
        }
( g  Y3 [' @- @4 Q. F' W# U             catch (Exception ex) // Exception caught here and message displayed to the screen
, x4 j% X2 r& o+ t' [9 r, k2 i' i) ~          {
- {8 ?$ S' R# f' a                    ex.printStackTrace (System.err);
% C9 y6 P0 |. a8 d8 R  }           System.out.println ("Error message goes here"); // Replace this error message with your own         
+ F9 ~% y) w- w  s        }
: E: d# G! _; V! F                return true;
% ?/ s& D! I5 H7 @3 Z        }; e" v1 {- x& ?4 Q. q: Z

5 d$ X# F9 W' V: `$ @; v} // end of class ProgramCompare0 ], V# _( [: }; L6 Y% P* T

9 I5 v2 I, ?& t  e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" o! ^9 L$ ?: R% q& ]* ?! I//  ProgramCompareMenu.java    Provided by: DRS
$ U0 x- m2 y3 }# z" k* w//
2 t% |# l3 m- E8 K, v- P//  Calls AuthorisedUsers.java and ProgramCompare.java2 [, y! g9 Z  Y# z
//( a  W2 D7 l, \* x- j
//  Driver shell for Assignment 2./ @( H) ~9 [: v4 i. @0 H
//********************************************************************
% O  e8 @0 P9 ^. \& {7 p
; l" |1 K0 z; e  [class ProgramCompareMenu
1 I; G, o# @; U* u8 s{. t; S  U$ k+ n( d' M8 H& l
    public static void main (String[] args)
4 `2 X- P7 F7 a: p            {, o1 W2 e( |( Q- |9 }1 g! {
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- h3 k$ W3 z6 G                ProgramCompare reached1 = new ProgramCompare();
+ B0 K- a% S4 b                AuthorisedUsers reached2 = new AuthorisedUsers();        - R; ^8 ~7 s4 `( @
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
1 d7 u9 c8 U  N, {( [$ o                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        1 R% n9 Q5 ]1 P2 i0 W  J' T$ T
        }) e- ?7 U% Q# q- k0 J9 R' `9 x, ]3 N
}// end of class ProgramCompareMenu
1 Z# C- ^0 r6 `
% U( W5 {$ O6 O0 j; }$ X1 a  ~' A9 Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************/ [) l( W5 {5 X' d% `! ?. A: {
//          AuthorisedUsers.java          Provided by: DRS
5 `9 Z3 y, a0 s+ [4 ]//               
! Q/ v3 J0 @# h8 f: y2 n* K/ z//         Program shell for Assignment 2$ C2 z2 P: o( {- ?" {' H3 t
//0 ^* \& n* s& e: e8 h
//         Represents facts about an AuthorisedUser
$ I7 D3 a3 F- `. s- t//********************************************************************
2 g5 v2 k3 I6 |) Y
2 C- ~1 V/ {4 N/ E  ~public class AuthorisedUsers% ?, L' m' P. R6 \$ u
    {
% P8 W5 }& P1 P3 e/ c( l8 z; I4 j5 F7 \. J1 b/ U$ L' s6 J
        //-----------------------------------------------------------------" j/ _- e4 h6 m& \. D
        // Constructor
4 r' q& F7 M' X6 Y( N* N        //-----------------------------------------------------------------
; H. @0 \' B) v7 s$ N8 q7 t8 {: t) v1 K& V
        public AuthorisedUsers()
) R7 V6 b. B% `4 s) N! X7 r                {9 A. r7 W. C/ v
                }- v8 k( s5 I  s9 {0 y* ^7 a% w
# f) s" R1 V9 N
        //-----------------------------------------------------------------: n  j8 {7 f' ^4 }$ k2 H
        // Method for testing that class has been reached# @  A# y3 `3 p7 ^( X; W
        //-----------------------------------------------------------------       
; g4 j3 o4 E6 m, U) \$ C        public boolean AuthorisedUsersReached()
- E7 a& a6 X# C8 I0 c                {
' _4 s/ ]1 k5 f8 i5 L* H                        return true;                        1 f) L0 v  n: q- Z& m
                }" l: O- c0 A: [' }5 u
                6 v, w% P' j1 G. U+ [
    } // end of class AuthorisedUsers. U  I! x; c+ R; B% _7 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! a& k0 L) l5 V  R. i% AShanghai - 2007; u& v. s" U2 h% F" e
Assignment 2
8 b# g& U, M- C$ G% B8 ?+ z+ I. H0 `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)
0 _1 H1 l: g. K8 f1 F- ?0 _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.
. Y" \; c( r3 x& ^" [* C8 O% iThe staff must be able to:
. ?: T, Q$ E; [( ]/ X Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! r/ S8 r5 j' p: t0 t! @2 \5 S4 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.: l& b+ m, p! F$ M
 The interface should provide a menu so that the staff can:
1 d+ H$ @5 v$ F% m) sa) Enter the names of the two Java program files to be compared
5 e$ D2 k5 e6 T9 H( H, Z) S For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: e7 g5 d% Y1 [9 X
** 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).
/ o/ Q, j9 e2 A5 B7 E7 [BSA104 Business Programming – 2007: Assignment 2* K! ?+ v* }8 {3 S1 F  L4 D! B
Page 2 of 5" o( p' V9 O7 O3 t- m
b) Print out to the screen all the lines of code that are the same7 o) a8 c/ {# z' [
 Include the name of the file and the line number of the code being printed for each of the two files
% e- ]) \- a1 W9 B! u- nc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
' |7 Y$ p! S" ^8 U the name, username and department of the user
3 U  q: n$ y$ l+ i  M: v: M3 N( Y the statistics of the comparison
3 X+ \1 S5 ]. [3 j$ I- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% q$ s! a2 S+ c- O, k! z8 w! _
 the recommendation for further checking
3 l4 A5 F2 p# L+ E- 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$ Q# u' x- d. i& X% W, R0 c
 the names of the two files compared8 f4 Q+ |% a0 q
d) Leave the program (exit)
# F# h3 s0 a. \1 E9 tThe ProgramCompare class: (Total maximum 20 marks available)) D9 \2 j3 w( d
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)+ A6 g' t* H% F" ^) r% {8 s
a) provide an error message if the files are not found or there is a problem opening them# O1 B) j5 Q. g. c
b) compare each line of code. k( D' t# |* C( _- q4 P
c) print out the lines that are the same  l7 ~8 W0 X( @/ x
d) count the number of lines compared / lines the same
1 g9 z1 W) s( V4 b0 x% iThe AuthorisedUsers class: (Total maximum 20 marks available)
' Z0 o+ e% H, G6 _: n+ N3. 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)
' {6 D4 h6 H$ [; x* F4. Provide methods to:
" c4 b4 v0 d' }9 f4 R/ T. W* ?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, m7 T; T2 D' N" R
b) return the name of the authorised user- M& N6 P. E9 r& u# {' W
c) return the name of the department of the authorised user0 e* q- H2 n2 q+ `  n
Individual Data (Maximum 20 marks available)
, ?3 R8 c1 K! W' ?9 N) n! I- U7 o5. 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.
1 O5 `9 G; D7 [* v  Q' N- SDocumentation (Maximum 10 marks available)9 V; D* e8 K* `1 i
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 p5 g: Z( g: fBSA104 Business Programming – 2007: Assignment 2' B+ {6 _) T0 B% A
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ f7 F5 o0 S, N5 k. V, o不过你要翻JAVA的类库说明。你有下载没有?. p" _3 i4 A7 j; W; z, I
查询关于对比的函数。貌似关键字是contrast,还有compare
) M, F- z9 r! ]9 Y9 t, q9 \8 O3 x. q! Q- |+ y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  Z- S. h) T5 M0 i6 B, d. a# F
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! P2 o6 N0 I) D: R9 t- t
可以下载到的 是 jdk-1_X_0-doc0 |9 ^& }+ Z4 v, \; r! \

8 m* c/ N8 \3 z9 f[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-5 00:48

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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