找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1670|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急. w* V' k" o3 V- S3 m8 N q ' N# j& t0 o' d5 M' R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************2 ^0 N/ v% R% i; l3 h/ F* N# L8 l
//  ProgramCompare.java         Provided by: DRS
# i' @, p  k1 j! z+ W7 ?//
( ^! b( D1 N# k1 F//  Program shell for Assignment 2
3 z* h: f. o# n. G3 C4 j, H//& z% N/ e( f# m& Y+ d% l0 A# I
//  Compares two text files line by line
  E: m7 N! a7 ~& ~" r) X; J//*********************************************************************' y3 \3 S2 O4 h; c" L6 w5 Q2 _
7 o3 _! y3 x( K, |' l% L
import java.io.*;
* J+ Y" L+ @$ b% R0 N% e6 i$ g
" e9 o+ s* u7 I: u4 i  _public class ProgramCompare
  q7 b  u' A) V2 U2 E- ?$ y+ I$ I{# w- v! Z0 D- @' g
        //-----------------------------------------------------------------
/ ~: B( c5 y0 k3 w& d8 }9 ~        // Constructor
" X( Z  J+ I2 I1 k! {        //-----------------------------------------------------------------
* e. `# P3 K+ s" n9 B. ~4 g/ d        public ProgramCompare()& C' g9 U0 T3 Q7 s
        {
0 ]# w* w3 ^6 n1 F: D' F* R: h        }& h% [3 k2 V( ^* ~7 L+ t
: U! ]2 d9 L3 M  q
        //-----------------------------------------------------------------
0 s7 K, Y) X3 f5 t9 [. D+ Y  r        // Method for testing that class has been reached
; J  q' d. @% H. v7 R        //-----------------------------------------------------------------       
" g" k8 P, W* B+ h% R& k6 M  X: [9 W/ Q6 Q+ E/ r
        public boolean ProgramCompareReached()        
: j8 K0 ~$ S6 X) C; V        {; F0 }4 m8 M# d0 ~  d
      try
" B" o& T+ i0 G2 q1 t1 I   {        
/ E( z( x: j' Z8 J6 q                        # c% t" R: O! n; P; i0 @
                //********************************************************************
' \5 C& D1 i! {- C! v                // Try-Catch Statement is used to handle exceptions - such as file not found
' {: {: O9 l1 _' g# n7 d                // Reading the files will need to be placed inside a Try-Catch - just like this one!. S) z' _, Z: P3 c' S4 M2 b7 ]
                // For more information see page 534 of the textbook
, \3 @, l, U) q/ f                //********************************************************************
; e( i7 s" @1 H0 N' x                     8 p( c( z$ Z. _) ]6 S! ?
        }/ I9 s& R$ N, T1 X8 S  e; v7 f
             catch (Exception ex) // Exception caught here and message displayed to the screen
, B6 R8 f; h; V7 U1 S2 y7 Z          {# V% H; G' y1 k* r  ~
                    ex.printStackTrace (System.err);
7 V. l2 U- Y( F6 O' K           System.out.println ("Error message goes here"); // Replace this error message with your own          " y& V" \& G+ D, T2 L2 w# Y
        }
  W! |7 w  ~: y' [8 ~- J                return true;' d% _1 E" H+ k, T
        }
- B4 {# R2 f2 f3 U/ C( t- u. g! r) e) r9 q5 B! g9 I3 R
} // end of class ProgramCompare$ S% ~* ?& v' |1 N1 U$ \, n9 _: O

4 @) Z" D+ }9 ^2 E7 R! B& O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& A: D* V. o; F% R& |5 I6 Y, ~
//  ProgramCompareMenu.java    Provided by: DRS+ a0 O: c$ \7 J
//5 u( A% i- p& {) f+ Q& a: N
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 I, ?# d' g) d$ B+ M  E//( p, g1 z% \: D% L# c: h# _+ f
//  Driver shell for Assignment 2.
8 C) D1 ~3 r/ [& B% K- F# [//********************************************************************/ ?1 b) q7 e  r9 r  N3 x
: W' s- G( h# P6 }
class ProgramCompareMenu* f7 K0 I" P7 x( u5 Z9 n. U9 @" D, u
{; }, |& Z* Z% P5 [. c& g+ r
    public static void main (String[] args)
+ L) F) X7 p% I            {
8 T7 Z3 `3 T# U7 c                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: [: }; {& e$ n; ~% U$ w                ProgramCompare reached1 = new ProgramCompare();
5 U% N/ O  v7 d& [! E                AuthorisedUsers reached2 = new AuthorisedUsers();        ! Q4 y* y! A; [
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" t) i9 {) t+ s! ]. T! V                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ( j) j; _! {% z" N* p+ j: ~% p
        }
2 h  |3 b) t& u) \}// end of class ProgramCompareMenu
$ I1 o. k, J8 W, t* D
; ~) S" c1 I( U/ {$ j4 ?, ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************# X7 u$ i* I) q/ A% E. E& N
//          AuthorisedUsers.java          Provided by: DRS
9 r% _, s9 s8 {0 q1 I//               
. n* l6 n0 i. Z% T//         Program shell for Assignment 2
4 s5 [0 L9 Q3 Q6 ~//
% W; q$ F& y4 w; v. U6 M7 E, P# k//         Represents facts about an AuthorisedUser
! z: V* z" B! u+ F. r3 W7 Y//********************************************************************+ j/ \- a4 y- e& o% J& t
- Q+ M' Y  n, J. n  Y
public class AuthorisedUsers% Q: S& q9 m# D2 q, l4 ?+ w5 F/ E
    {
4 E2 c' _  G9 z4 z% C% C' \
# J6 z" [+ Z& `$ s        //-----------------------------------------------------------------
8 K1 M; \5 D, \        // Constructor& ~9 ?' h! M6 Y* J, J; |
        //-----------------------------------------------------------------
5 f6 l; h. c4 |, r6 `
/ U4 U) f2 x$ ?        public AuthorisedUsers()
1 p5 u# O. k) @                {* ]7 q4 U5 s3 z4 E3 _/ A0 h: w
                }6 a% M! n. I" J7 O5 L  H

; C; y; C6 C* ]! x" m( m        //-----------------------------------------------------------------
7 ^% w3 D, M0 \# ?5 p6 O* E5 c5 u        // Method for testing that class has been reached% v- E, l/ m: C) C
        //-----------------------------------------------------------------        & B& a( u( L1 W  C# n
        public boolean AuthorisedUsersReached()
4 M: B. [. N" a& S% }# r                {
! t% k. P/ H3 p$ }) P& b                        return true;                        9 y- r9 A8 v* y8 E" q
                }
; k* u" M9 z" y. {                8 q% G5 A0 Z6 g4 k1 n+ t
    } // end of class AuthorisedUsers
; m" A2 X/ C& U$ ~0 a# j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: t9 C: {) C7 S% r( {Shanghai - 2007
7 \& @/ i0 U" M8 O% x  i6 _Assignment 2
- t3 `" }# w2 K) hDeadline 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)5 j( M7 _1 b! U. Q
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 W& i7 G4 L! E4 |: U9 K
The staff must be able to:3 s  j/ X/ ]/ ~5 I
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  l+ u' s7 e8 M+ S. S' o- s( ?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.
/ ]( }: u8 O" f: m# H* E) R2 \; x The interface should provide a menu so that the staff can:
1 M0 Y3 `  J% x- B" ta) Enter the names of the two Java program files to be compared+ L# I. R9 P) r) \1 o& i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 P3 h# J$ {3 ?
** 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).$ f; {, D7 H- P0 Y
BSA104 Business Programming – 2007: Assignment 2
2 t2 z5 e9 ^4 U& Y0 U3 N9 v6 tPage 2 of 53 \& x& d7 ]/ ^2 D
b) Print out to the screen all the lines of code that are the same: Q/ A% A5 b  u) V
 Include the name of the file and the line number of the code being printed for each of the two files
* [: F0 C; h+ V( x4 Fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 I3 k4 m2 X, G. X" }; o7 A- L& b
 the name, username and department of the user" T/ \! \4 p$ W, q0 q/ M
 the statistics of the comparison! l9 x  d$ `5 L3 M0 O, y$ |
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
2 d' o! c0 E) a( R; b; R the recommendation for further checking
  E  e# {& ], F) d( 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
5 M- j3 H0 o* r- I# V, W8 A/ H the names of the two files compared
/ C% x$ X7 [7 }6 N* Sd) Leave the program (exit)2 u2 g5 B) l  y+ Q) |4 Y
The ProgramCompare class: (Total maximum 20 marks available)
$ T" I0 ^2 W) x' B6 ^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)+ E  j8 L: b5 v& u/ ^0 i
a) provide an error message if the files are not found or there is a problem opening them
7 F- a* I, f+ @$ ?8 A  Q! d7 gb) compare each line of code4 G5 o/ k' N- d' M6 ]
c) print out the lines that are the same
5 z/ w  {5 g: V0 U" G) G+ Gd) count the number of lines compared / lines the same" D, z0 }2 X7 i" R
The AuthorisedUsers class: (Total maximum 20 marks available)
( `- C+ a. r, _. L) \; q3. 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)) v$ w2 }- \# `5 N( n- w8 \; A/ _7 N
4. Provide methods to:
7 U2 s$ ^% \1 |  i$ u1 }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, |2 g3 X- R  O* m2 E* _' `2 D9 E
b) return the name of the authorised user7 X9 Z* K! D1 B; T; i, x# m
c) return the name of the department of the authorised user  q. }5 ]( W/ l: _4 y
Individual Data (Maximum 20 marks available)( w8 B2 g+ I6 @$ k* B+ U
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 @- K: M7 Z. }6 X& L$ s& [  i
Documentation (Maximum 10 marks available)
: t8 }4 r2 ~: I6. 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.; @8 g8 i4 h, n$ r) S+ ^0 _% g& F4 _
BSA104 Business Programming – 2007: Assignment 2' }: C* }' l6 p
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& H5 {- x. b1 B' g8 }不过你要翻JAVA的类库说明。你有下载没有?
& j- i& a0 r( B( V% P  q查询关于对比的函数。貌似关键字是contrast,还有compare! m% p' K2 D2 H8 a, W

& s5 i# ^7 W+ s6 p1 x* X[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 G& S" S6 Y4 e7 N! E) h
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: c' T6 m+ T; g* M% V8 o0 P: b: X
可以下载到的 是 jdk-1_X_0-doc
; A3 s# F; Y1 q
0 y: |8 ?) c$ L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-25 10:55

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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