找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1071|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 Q4 B6 j! i# o6 p . z& p% K* _ Z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 _, B4 W4 ], \( Q+ Z//  ProgramCompare.java         Provided by: DRS7 f3 W' y) a' z$ z# t
//
3 o( y5 D) L. q' O) }+ U//  Program shell for Assignment 2
! `5 A+ a$ R0 _1 V* S//
5 ^: t  A5 u! t: j; Z" j//  Compares two text files line by line
8 B: y7 @/ {; f. l+ B+ d/ `: U//*********************************************************************: X1 m# i( P5 v. n
: x9 j' X' G' h8 n1 r3 x$ `6 p4 w, z
import java.io.*;
3 h; |1 ]4 |4 e# L3 P- O6 e; D" ~4 P7 f7 V, a. c  ^# K
public class ProgramCompare. ~, k8 ?$ E2 L
{& g" R- g0 p- X: j5 p8 E) z1 [
        //-----------------------------------------------------------------. }7 f- w  _2 m2 m- k  V# u; o; ]
        // Constructor
8 J3 |6 y* @3 E9 d6 {5 C2 ]3 T) \/ H        //-----------------------------------------------------------------
9 [* t6 z  M7 F+ @$ s0 P        public ProgramCompare()1 Z: [* ?; C- q: ]0 M' R, z
        {( ^3 e: P; c; j9 v
        }  Z2 m' P4 V- V2 @) ]
5 ^7 `# I: W1 p
        //-----------------------------------------------------------------% A! Q. u1 U, v
        // Method for testing that class has been reached
! a: ?8 A, z4 q, U( w  r4 w7 Z        //-----------------------------------------------------------------        ! l) x- o' H0 P. g$ k

1 K0 A6 A! G2 m" T! P        public boolean ProgramCompareReached()        
9 K' n: S- Q- n5 i) q        {
2 S2 O9 g5 g% \: Q3 t9 J: k      try 6 |) T2 F( Z1 p7 A
   {        
, X7 ~6 n4 L& y  a                       
* p4 P/ U+ k# H5 d. ~                //********************************************************************- A: c( P  H" b! e
                // Try-Catch Statement is used to handle exceptions - such as file not found 8 x! n$ v* Q% U' Q$ T2 m+ g7 }
                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 q0 V6 b/ B! Q# n
                // For more information see page 534 of the textbook- X3 ]8 R3 p8 g$ l% k6 H. o
                //********************************************************************
1 J9 m& R9 ^" H& L9 Y7 b1 {3 W                     3 p' K) I5 j( S3 o/ y
        }) {, S: Q# |' E( c$ A) O/ Z' J, g. `
             catch (Exception ex) // Exception caught here and message displayed to the screen
8 o; x  m. x6 X8 I          {2 ]& w5 n4 J5 ?9 H/ q
                    ex.printStackTrace (System.err);( T( V; ~2 @7 x4 e* r1 q+ S- f/ t
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- |& D8 {8 C3 u) @9 _        }; C) ?  M5 ]9 b; x
                return true;
$ @+ f' ~2 F- w" m- u4 t( P& }        }- l3 k% [/ Z& z! t/ N

: g+ y# j( L9 w6 S( ~7 C9 [' U1 S} // end of class ProgramCompare
+ A2 t% }  p; |. e
! D: L" m" U+ n* E3 l- \* y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  y& V5 l' E9 ?) e4 V- J
//  ProgramCompareMenu.java    Provided by: DRS
+ p& m; q# z6 L$ ^, I& t( I& v/ k//" ]+ ]$ v. @) i2 K" a; \
//  Calls AuthorisedUsers.java and ProgramCompare.java/ P$ \4 y  l( x; {
//
% t$ ~9 b0 x! g* p( |; E7 K) Z//  Driver shell for Assignment 2.; d& F  K7 l  `6 R3 ~; v" R
//********************************************************************, x9 K: k5 n+ t5 f

$ N  r) c3 N! Z0 n+ q, I" r2 yclass ProgramCompareMenu
; @& [5 L: L4 X{
* B" j, Q% M9 v+ D% J. e    public static void main (String[] args)7 c7 ^& g' K' J
            {
  b2 K$ H9 @9 c! ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable) ^" E* I& A0 b  m& z, L
                ProgramCompare reached1 = new ProgramCompare(); ) e! g, V; o3 s
                AuthorisedUsers reached2 = new AuthorisedUsers();       
  z! ?1 [# N4 {0 [" N                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
; z( N; D, J; f, W. }* L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ; U' E& r  T( D' [' m* D, k
        }+ t1 y8 ~) i: @6 g
}// end of class ProgramCompareMenu& G: [/ b$ M6 m5 K/ r$ e$ z
! C6 u) Z  J6 C( V. ^7 w+ D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 I2 f8 z3 [) i
//          AuthorisedUsers.java          Provided by: DRS  `$ e& o$ W2 W7 A; ?# x
//               
1 E" N& m4 Q/ @. u//         Program shell for Assignment 2+ Y: w! E5 p% A! h
//* w) x- S" E( y3 e0 `
//         Represents facts about an AuthorisedUser
5 g: E: C8 ?" I  n, M* R/ L//********************************************************************' O6 B) M% o  a  S; |1 V7 r

7 n# e# g7 P8 i: k6 O9 P  epublic class AuthorisedUsers
3 r- }; h; @- p1 ]    {
# S- H: Y% O& W! Q
  q8 q) ^8 d" _* z4 A. G        //-----------------------------------------------------------------
0 C  y- V: |6 O% X" O/ K3 m        // Constructor  U7 @1 S9 a4 W8 m, z% h
        //-----------------------------------------------------------------
$ v: V2 }+ C3 `+ v; Z1 P% A9 A- [5 g! u6 V
        public AuthorisedUsers()
3 m/ i- [1 N* C" v                {
: T. f/ N4 M$ i1 ?4 U/ A0 @                }
' x! A0 u2 j4 P" P. k. S$ O: p. q; {3 H6 L# m% p' G
        //-----------------------------------------------------------------
+ x7 W: w# x" @4 o( Y6 Z. v% N        // Method for testing that class has been reached; d3 \% z6 a( _' S) l
        //-----------------------------------------------------------------       
: V8 h+ `& A) g2 f: q1 ~6 S' H        public boolean AuthorisedUsersReached()
& ?2 V% F  g( i0 T. g                {
# N  e4 o' F, D: \8 C. w6 ~; y                        return true;                       
5 C7 V7 t+ X! O! N                }
8 Q6 |0 k' W- q               
+ e0 ^9 ]+ \% I& [# a4 p    } // end of class AuthorisedUsers
# C' m& }. R" [& V9 T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 j6 A! C6 B" X. \, YShanghai - 2007
0 e3 {$ u3 ^. u8 x! `/ JAssignment 24 X3 H1 A" E$ l
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)- \  ^$ K) D; U# e' `9 r8 ]) G- _, K
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.( R% a6 A/ y) u
The staff must be able to:2 I% J' H9 U* d) _/ H% ?8 a
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' [7 N: _1 i, i3 T2 f* _: i1. 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.1 E0 M" C% q3 R) ^
 The interface should provide a menu so that the staff can:( P0 F/ S# W- j
a) Enter the names of the two Java program files to be compared' X3 X  V+ `! ]; J& Y& |1 D' {, r5 d
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- E$ k# U. d' T# G8 ^
** 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).
. w* t- W* h2 D; O  lBSA104 Business Programming – 2007: Assignment 2
: q! o+ y1 O/ j4 \Page 2 of 5; C0 k8 y9 H6 _2 Y1 }+ t7 l
b) Print out to the screen all the lines of code that are the same
$ E; S) @2 [- y3 H3 l" j Include the name of the file and the line number of the code being printed for each of the two files/ N2 K4 m  H7 Z& l% T
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 b2 Y. e& w3 a3 X- C/ s5 f! u
 the name, username and department of the user
6 U0 j$ o0 x7 w( Z the statistics of the comparison
) K, U8 v' f! i- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# _. C( h" @. ], p
 the recommendation for further checking7 h2 W! f; X' `" F7 ^7 K
- 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
2 s& H( g0 p1 x* M the names of the two files compared. }+ P  l4 L  R! o1 [8 O
d) Leave the program (exit)/ _/ f. _- [# S+ ]% K
The ProgramCompare class: (Total maximum 20 marks available)- }' ?! a4 B+ l: U8 A
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)1 n  H$ t% U! x
a) provide an error message if the files are not found or there is a problem opening them
2 S# z) |) b% W$ [- cb) compare each line of code* r0 V: ?( E/ r) H/ W
c) print out the lines that are the same
/ c/ v, A8 \6 z! }9 P0 V+ Yd) count the number of lines compared / lines the same
- d' P' a6 z. V6 \+ e/ ]! h$ h" tThe AuthorisedUsers class: (Total maximum 20 marks available)
4 d5 P& t" g* Q6 z5 a( [1 ^& j3. 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)
% Y) ^4 h7 `  \4 j3 n4. Provide methods to:+ j8 G7 P0 [- Z6 [5 ?* P! q4 F
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
) j* @$ S! \* {  A( R3 Y& V2 gb) return the name of the authorised user
* w7 t* u& J8 ]c) return the name of the department of the authorised user
1 C" C& G2 N* y0 z$ H# c8 M7 {: Z. FIndividual Data (Maximum 20 marks available)
  f" ~; i% _2 h! q' K) v5. 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.
& U+ s+ d) I+ K' C' T/ Q/ eDocumentation (Maximum 10 marks available)
) D! k0 c3 _' W2 g- n. K0 K6. 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.
1 u" ^6 s, z, b% ~BSA104 Business Programming – 2007: Assignment 2
' ]2 D5 v+ Q7 c7 p! rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. o1 u% n; D3 |/ [0 }
不过你要翻JAVA的类库说明。你有下载没有?
/ \, `! b" K* l( o查询关于对比的函数。貌似关键字是contrast,还有compare5 s5 c- ?2 F* n8 q6 {

  @( [3 [  X+ a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -2 A+ o4 x6 u( A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) ~. }, b/ @% B
可以下载到的 是 jdk-1_X_0-doc. o- {: x! y8 e( z
# B/ R3 R$ O. H7 I7 E) i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-24 09:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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