找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1337|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 + d6 O; k% ~3 Q) w5 W ' n6 t2 j! T7 X2 I. A' w
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' }, Q" I5 O  S! A5 F* G' ^7 _! A
//  ProgramCompare.java         Provided by: DRS
4 b& k+ s( W, f9 b+ k& N//
3 k* q5 v: d2 V//  Program shell for Assignment 2
+ }+ v) z) D( {3 J2 j9 Y/// `% y" X% y' p1 [% s- w  x
//  Compares two text files line by line
& B' b+ p7 h% i1 ~//*********************************************************************
# S" s7 T8 B& k# @3 b, u
+ ^4 P9 |, }% Mimport java.io.*;4 d3 Y. y; g  [" k. h

" D% t0 g9 g# q# j& t. Qpublic class ProgramCompare
3 u3 N$ i% {, t( ?/ j0 ^' ]/ z" U{+ |) ~9 m. Y6 s
        //-----------------------------------------------------------------* f! T/ M! A  s4 W' t
        // Constructor! g* D4 r& d4 Q# a% V
        //-----------------------------------------------------------------% N0 ^$ r  j! A
        public ProgramCompare()
" \% a; k  t1 P/ V        {, u  Z- K# n* A8 n
        }
; C2 E) O$ X1 o1 T# V$ P. _" G2 j! l$ j0 F
        //-----------------------------------------------------------------
- Q# T5 @/ B( m1 X7 q% U9 J* V+ N        // Method for testing that class has been reached# w! [  F- R  c$ m& w6 |9 c8 e
        //-----------------------------------------------------------------        4 r' B1 \0 r7 ]9 T; N

. x5 n- k. N1 d; y        public boolean ProgramCompareReached()         2 H( V: H$ t. ?1 Z1 x& Z6 o
        {& T2 i" @& c2 T. ^. E7 c
      try : O+ Q. |( H6 Y2 G1 a9 Y0 M
   {         6 R* ~% P, N) n: @
                        5 E& \5 f; O. s3 x" K
                //********************************************************************
, H% y! E( n+ W" i, x) @4 `                // Try-Catch Statement is used to handle exceptions - such as file not found ! ~' w. W3 f8 f- G2 L
                // Reading the files will need to be placed inside a Try-Catch - just like this one!% E% m/ H7 w6 Y0 z8 L
                // For more information see page 534 of the textbook
* g; G2 ?! c) B: u2 i1 l  e                //********************************************************************& h1 i! a, i) j5 K& C
                    
3 y# P8 q8 S) C3 c        }
% s0 g0 M) E5 _6 G8 N' W7 ^- ^             catch (Exception ex) // Exception caught here and message displayed to the screen 3 Z( C$ y1 n  i2 f- Q
          {  k  Z$ ~! Q+ {9 a- M3 g& x+ C% W
                    ex.printStackTrace (System.err);/ I) \5 E6 e2 ?* s3 l5 _7 i
           System.out.println ("Error message goes here"); // Replace this error message with your own         
  }$ q- z  s" T" U# A/ V8 v3 J        }) h. c* s: j" `# ^
                return true;9 B9 p4 F9 b: }( J- }) I( c% J
        }! D( l9 y  Q0 j2 J, Z/ K) A8 {

: l  h4 r6 C+ K" {+ L2 L! b( i1 o+ ]} // end of class ProgramCompare3 z% c  `( A) F
# h) D0 x4 H5 \  M% d7 W, j* Q9 r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) d- y! Q& m. E
//  ProgramCompareMenu.java    Provided by: DRS2 p4 j1 h0 d- `. C# q6 @6 @
//
! m$ X7 c3 X# |$ S0 g9 r0 f//  Calls AuthorisedUsers.java and ProgramCompare.java
3 N6 `8 c' j# y# j" k9 I//) y- A$ m& _* W  M
//  Driver shell for Assignment 2.  W9 ~$ r8 f& C, _7 M8 s  Z
//********************************************************************
8 j$ K8 h, Q1 }) f0 |
% g- Z* a) o  B# M; jclass ProgramCompareMenu( d5 S: Z1 s; ]; h& s' U
{! ?5 t$ _. [4 V1 Y7 W/ U
    public static void main (String[] args)- C, x6 E; m2 i; _8 K& F/ O& `$ o
            {7 ^$ ]7 ?/ [- `' E2 Q. R
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
# Z: g4 e" |$ I; c$ m+ k; c                ProgramCompare reached1 = new ProgramCompare(); 6 `  v# s5 L0 u4 G# ?
                AuthorisedUsers reached2 = new AuthorisedUsers();       
1 ]1 h- k. Y$ C2 R( h                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! o4 a" B  [0 Q# m5 `$ u8 w" k+ n- y2 r                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
9 s9 t  B7 ]! A5 J! W+ p+ }7 \        }! X0 ^  _: S& J* W" D' N3 p" p' W
}// end of class ProgramCompareMenu
. E- u- J7 Z' n+ c, p# b5 g2 h6 Z/ a( k1 H2 m5 {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************9 Y: j& k; a8 A. b9 i
//          AuthorisedUsers.java          Provided by: DRS
3 z5 g8 r4 X! I//               
& h; U4 S# ]; C9 i* e' N$ t//         Program shell for Assignment 2% @* n8 a+ u' Z
//
- j7 l  q% ]$ l' s//         Represents facts about an AuthorisedUser
* y6 D) S0 l$ Q* O* p& k3 [//********************************************************************
+ G1 ]2 J5 |& A2 t
7 Z# R& G4 ?# S! ipublic class AuthorisedUsers
- v( s, Q( D: U; |9 a    {
: y) l" N$ m* A4 L. N6 H
4 V; V- F1 u% T% t0 w& F# \# x        //-----------------------------------------------------------------) j! }: ^" C/ _- r; H
        // Constructor  I! u0 G* b; f$ }% j6 Z# S
        //------------------------------------------------------------------ V# X" ?' q+ e2 K5 b
. k3 b  j1 J5 e7 N" ]& e6 x' _
        public AuthorisedUsers(); [  y6 a1 C, _( _% Z1 X& P
                {
- |) c1 F& D$ N. t; ]                }* b5 E! L; _4 J( Z! {1 B# _: Y

' E' _. q8 v! M  Z8 w        //-----------------------------------------------------------------; C; @1 I% W6 z0 F3 j5 n! n
        // Method for testing that class has been reached
' X  V) B0 U6 W$ f        //-----------------------------------------------------------------        ' T4 N  ]( D$ |& z
        public boolean AuthorisedUsersReached()+ n0 ~- z5 G5 C( |  Z
                {; G' u( N2 k! Y: D7 d+ h6 _
                        return true;                       
4 `  d0 @) L3 C5 N( u: V2 I0 ?                }) w) z1 f$ L# v" t' h' `
                ) T9 U! Y. O  h# e. {
    } // end of class AuthorisedUsers
. f- A* w# q8 d6 s+ `. J  n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# |; J" x4 Q% U4 F/ LShanghai - 2007
- _, ?) y( H" @$ H6 c$ Y; IAssignment 2
$ F: M( U# |; F6 O5 L% L4 qDeadline 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)3 S) |" `7 G1 l
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.* {' M* U( ], S  ?0 g9 |6 g
The staff must be able to:3 l( z& a  r8 o, m
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  v2 [3 f. ^5 k# x, P1. 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 w7 t" ^, n- Q& k$ T' T8 k  p The interface should provide a menu so that the staff can:% o5 F, P8 s# e, r4 o% g
a) Enter the names of the two Java program files to be compared" X3 J) @  r& T" v
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) x* V4 Y+ }# K
** 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).
- K9 H  Q/ _1 iBSA104 Business Programming – 2007: Assignment 2& C. Z. L7 m, ?+ a
Page 2 of 5! r- O; f, q0 N5 L: d$ Z
b) Print out to the screen all the lines of code that are the same, S- F+ z* T0 Q$ d! O4 J6 V6 ~8 T5 D
 Include the name of the file and the line number of the code being printed for each of the two files7 r% U8 p* I( `
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared$ X" `: E" B% E: k1 n& v
 the name, username and department of the user% d0 O) W# D' [2 v" s, ~
 the statistics of the comparison5 u8 O  [& j- a: u
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" x# k+ Y! f( o& Z/ S
 the recommendation for further checking  c/ }) P, r' C( z' t
- 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 closely9 K* u. c6 a: ^1 v3 }
 the names of the two files compared
2 p* g: z- ?; _( id) Leave the program (exit)
7 W. M3 @" e6 yThe ProgramCompare class: (Total maximum 20 marks available)
5 e5 H' J( m5 s! L2. 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)6 m1 j) ~, ]/ n" V% d
a) provide an error message if the files are not found or there is a problem opening them
8 q0 a% D' C% [1 Qb) compare each line of code
5 o- ?) h: k1 }3 F! a1 Qc) print out the lines that are the same1 ]3 _  E. B- C& n6 A/ ]$ \
d) count the number of lines compared / lines the same! F+ @4 ?$ w# O& b1 {9 P' p
The AuthorisedUsers class: (Total maximum 20 marks available)
9 V8 J2 Y% s7 R2 m. ?9 c+ 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)
1 P  l5 V7 {- A" r9 m4. Provide methods to:8 |3 S- J$ t( R. g7 R
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 match4 J; U7 F* c8 |$ L: A
b) return the name of the authorised user
* V* v% u7 L, Y5 W# ic) return the name of the department of the authorised user: p/ T9 x+ m3 _" L/ u' D( d
Individual Data (Maximum 20 marks available)
* T3 E: Z) X( N  }* q5. 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./ Y! `! `2 n2 Q/ ^5 J
Documentation (Maximum 10 marks available)1 n3 T3 s# D* ]8 }# D# b
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.; Z. M# Y7 F9 q" c9 p& W/ M
BSA104 Business Programming – 2007: Assignment 2
) V3 b+ ^  h9 T+ W  _, y9 EPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- i9 i1 `4 ?4 D% G. G7 s9 o+ T不过你要翻JAVA的类库说明。你有下载没有?% U4 o: f" n; Z+ X6 K
查询关于对比的函数。貌似关键字是contrast,还有compare
9 h" t! {8 I7 e( x( T8 u; ^) T+ l% Z* `8 Z; n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 P: O: H7 l1 _# l
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- T. q2 U$ G! y) e可以下载到的 是 jdk-1_X_0-doc  a" `% S. N1 r9 u
' _* d2 |" w7 `& b9 K1 C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-1 18:19

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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