找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1172|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 ^8 w8 a$ \8 u3 t9 _4 Q 9 e3 n" g4 W. T 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 | 显示全部楼层
//*********************************************************************
5 Z8 y% ~5 H, l. w$ t8 w  x$ y//  ProgramCompare.java         Provided by: DRS  p/ f8 k* @$ z1 P% q2 ~; b' [' u, [7 s
//& a& V7 Z; z$ s- A& L
//  Program shell for Assignment 2! L6 W2 k* R. u  n+ w1 s
//5 V# ?4 x+ A* _: y+ q0 Z' t) x
//  Compares two text files line by line
# ^! s) x4 Y$ O1 _//*********************************************************************
* ]  R# i6 P3 p' r
4 a5 Z1 w* ~/ ^# C% c. |import java.io.*;
2 y5 j: q) o1 P3 j# w, t! F6 Q% D! ^! L, j% Q
public class ProgramCompare
1 X; F% S; }$ v7 P" H3 b( K8 h{+ X1 X0 }0 y. _  P  x
        //-----------------------------------------------------------------6 |/ W' B2 B% w3 _. }: H9 m
        // Constructor
" y) p/ x: p8 h( b* y3 {0 v7 f        //-----------------------------------------------------------------
) m; q- h. v+ x; Y- }; W$ R3 E2 l        public ProgramCompare()
' a2 e- V6 Q& ]  O. O        {( }8 p% A; q+ ]+ I" `8 x
        }9 t* P( B: I; y( l7 W) E+ W6 T

4 j2 ^4 @. _# A9 U4 A- H3 N        //-----------------------------------------------------------------! A( s8 g5 T8 ~7 I( r& ~8 ^
        // Method for testing that class has been reached
, k/ x/ ]% v" B. ]        //-----------------------------------------------------------------        : T# D$ Y1 @$ R& Y( [, v

; J, g; J0 ~8 l* r0 J* l        public boolean ProgramCompareReached()         % T/ L, k3 n& C9 z% [# z
        {9 {+ O  Y6 J  P% f, d; i6 b
      try * P+ C% G1 Y1 ?: p  R
   {         / S+ x- d0 N  [  p6 L! @
                        0 D/ k. k8 g$ X
                //********************************************************************
/ s: e% j/ _) P3 U3 k                // Try-Catch Statement is used to handle exceptions - such as file not found
& r' T# I: W. h: {3 ^                // Reading the files will need to be placed inside a Try-Catch - just like this one!$ B2 E4 l2 N: W' ~3 h
                // For more information see page 534 of the textbook
8 s7 |# I5 a6 ~5 c& _0 w                //********************************************************************
3 p+ `1 p# B$ H5 r/ @( H: y+ E                     2 y* Z. S( S/ @6 Q' t& p. e
        }6 I! O5 A, }2 L: a
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 G" v* I6 ?7 j
          {: a6 I2 K7 R: D6 ^3 I
                    ex.printStackTrace (System.err);
- V( R9 V9 ~9 N  ~6 n           System.out.println ("Error message goes here"); // Replace this error message with your own          - G6 h  Q* W- y1 V& a
        }) o; ^# V& y0 C& z4 N7 Z! k: W+ i8 M
                return true;2 {$ K% `* M. Q2 M
        }
# C/ i% C( D) F8 `% c* Z2 [
5 ]8 l3 |) S4 q& V  y} // end of class ProgramCompare
. W5 S3 W! A7 v
8 t7 `. V0 p% x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
5 F! {/ W9 O. W) N+ M2 N+ o2 D, V8 g//  ProgramCompareMenu.java    Provided by: DRS
- x2 h3 t1 T7 q& i6 G  ?//
' z' {8 M2 y8 M- J5 `//  Calls AuthorisedUsers.java and ProgramCompare.java) h# R/ R4 z1 M' E4 J# K9 r
//
; _) P9 n5 k1 V: [( Z6 i//  Driver shell for Assignment 2.( D7 ~, O" I2 p$ |) q
//********************************************************************- D5 B! P4 N! @4 c

. i- C; L9 U6 h$ X( V) Kclass ProgramCompareMenu
: z( Q% J! E" u{
3 j  l# T: B) ]9 X$ S1 ~8 i9 C( I    public static void main (String[] args)
( x8 S/ L" g' v; i7 H# G8 y            {# [8 ^+ z9 ?& a: O2 L
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* K4 |: `3 U+ |8 [$ `+ e
                ProgramCompare reached1 = new ProgramCompare(); ' k- C4 p( i  A; p; w
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- G' A! Y  P5 @. R- p* `                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& V' P4 x7 _6 F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' @! |  K" ?$ |        }* d% N$ U5 T* D0 H1 |6 L: B3 B
}// end of class ProgramCompareMenu9 G9 g) Z+ Q; u3 C0 T

1 ]( a4 C8 [9 `$ X+ h! ?+ V9 a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 F) @1 V& _, I: J6 e//          AuthorisedUsers.java          Provided by: DRS* |2 ~* ?- h) E# |& U, P; E& J2 q
//               
9 O7 N; F( `4 U& L//         Program shell for Assignment 2
, f0 d( x6 C5 i//
  A( m4 J+ r7 w! i//         Represents facts about an AuthorisedUser
8 l; e: z8 q+ T3 I& q//********************************************************************7 B! X- {5 k8 m+ C0 X# g
! L1 j8 g, G# p  E; x
public class AuthorisedUsers
+ c! O. S2 v1 j' A! N3 x( x    {6 o/ W4 O3 S. h" ?

- ?& J, H3 c. d7 X        //-----------------------------------------------------------------
9 R1 Q! g- p/ T( R1 C( U1 r        // Constructor
5 ^: J3 m, I4 P3 D        //-----------------------------------------------------------------8 ~$ o; v* N8 Y$ V* r, g/ L

) P6 V/ l, X" a        public AuthorisedUsers()
! H; ~9 H& z+ `/ ]! r: Z                {
% d: D  t# ]" X; t                }
) N* @& U$ u$ E9 ~  B
% p" ^/ g3 `/ v! j) J7 B        //-----------------------------------------------------------------3 D* [; Z. i# F' k- [
        // Method for testing that class has been reached* ~8 ?* ], l4 x: o9 t9 [/ {9 c
        //-----------------------------------------------------------------        , V2 m9 ]  l6 c7 ]6 r! T
        public boolean AuthorisedUsersReached()
, v2 l; @) u' W; S7 _( g3 }  i( p                {# }1 v; F5 R% F3 g4 S, s4 C
                        return true;                       
% W: H9 `6 S4 S! q3 a2 B- S                }( K7 X. O& f* \8 X' E
               
/ w( L; Y1 P  K1 |, g4 u  B    } // end of class AuthorisedUsers
5 }+ X* @" A4 p& ^8 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: G+ e" ^6 v: p# `% S1 n& P
Shanghai - 2007" p5 g, n' e& ]: W6 @: ~( S- f
Assignment 2+ e- L# L* O/ Z1 o7 ?
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)/ H" ?  }8 F( _' T7 m0 J2 H; S
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.
1 w1 D- D$ l# gThe staff must be able to:) `9 u& Z( v  g2 r
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.) p) S4 D/ z- z) R! L) d
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.: y" i3 q! ]+ j! u4 @8 C
 The interface should provide a menu so that the staff can:2 D5 v6 T$ C) ~! i' z
a) Enter the names of the two Java program files to be compared2 l0 O( W# ^' @( {, P0 u
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 c1 [6 r# L3 T5 g  t4 O4 D2 Y** 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: ~5 ?( r  R9 }8 y3 I8 UBSA104 Business Programming – 2007: Assignment 2
8 p2 ^9 ~2 P) L9 s0 fPage 2 of 5! t3 j! O4 P4 Q; l% ]% {
b) Print out to the screen all the lines of code that are the same
7 R1 \/ g' r  d Include the name of the file and the line number of the code being printed for each of the two files7 p0 j3 r* R) Z( T2 n3 r; J
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 x3 r$ u9 }& t$ C. K. |( ^ the name, username and department of the user
( e6 B2 L3 D  B6 L the statistics of the comparison
8 A' k4 |4 x& G- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 ]' q: v/ e7 b
 the recommendation for further checking
7 E* p1 M6 b. N- v, |) l/ 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 closely
+ z1 k2 e4 W* `2 {2 W1 | the names of the two files compared
& v4 ^5 _& ]; N. Y: s- H3 S2 I: w0 pd) Leave the program (exit)
5 s& A* x5 p* sThe ProgramCompare class: (Total maximum 20 marks available)4 T6 k1 ^1 T" s: |+ O) P0 N6 E3 g
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)
# j; L' h4 G4 p0 s7 r% i" Y* qa) provide an error message if the files are not found or there is a problem opening them! h; S3 W1 [5 f# c
b) compare each line of code
' g( |0 F: `- U5 b8 b- \; sc) print out the lines that are the same/ {2 l4 H1 L- V+ `8 b% s, N
d) count the number of lines compared / lines the same
$ i2 `( d0 c0 E- \' XThe AuthorisedUsers class: (Total maximum 20 marks available)3 }2 e) t# `" s+ s
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)0 b/ S0 O9 l. a* }! h9 i
4. Provide methods to:% M- E+ F# b. z5 p8 T+ i' v0 E" }  D
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
/ q/ w& d* y% R$ O: Q0 Jb) return the name of the authorised user3 e3 G# u# k) `+ c  O
c) return the name of the department of the authorised user( Q) e9 S* |/ E# @4 J2 m9 Y& z+ M$ |
Individual Data (Maximum 20 marks available)) f6 G. t5 X7 O- Q8 y; E7 z# n
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.$ M" W7 b$ n: f9 w. X) B" m1 m# r
Documentation (Maximum 10 marks available)8 B/ G# L5 V2 F9 v4 n& z
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.$ }$ }# {1 T+ T1 O4 {
BSA104 Business Programming – 2007: Assignment 2
1 H. ?( t' l  C, y7 j8 G- V4 [Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了' }5 J* j: |3 ~+ U0 g. O
不过你要翻JAVA的类库说明。你有下载没有?
# s0 k& t+ f6 v0 \( }0 e$ G查询关于对比的函数。貌似关键字是contrast,还有compare1 K- z1 m) \$ h4 r. u

5 k4 G0 o6 X" I6 |) U$ f[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
& `5 ]% z5 z8 J& V" p痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 s8 w- H+ Z8 W+ \$ n, M0 t/ w
可以下载到的 是 jdk-1_X_0-doc
& c/ F( E' `+ g
# o) Z4 X/ @' y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-10 00:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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