找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1500|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' q4 `' r! m5 i+ V 0 u) c. B" g. 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 | 显示全部楼层
//*********************************************************************( y5 F! Q" H. Z+ B7 c
//  ProgramCompare.java         Provided by: DRS4 M$ `6 ~9 n6 S: u
//
0 _/ M* y. c1 [- [( o//  Program shell for Assignment 2, Y2 |0 }% S3 j
//% P9 e  M0 R9 v! K+ j8 }
//  Compares two text files line by line
+ i3 D- u1 y: ^( e" ^* N5 O7 u1 E//*********************************************************************3 p8 Y/ S' Y- T' T
( D0 R5 f' Z( c) @
import java.io.*;* c2 x" f- G7 m1 b. `) E' c8 R
) n- K+ o0 y3 O6 y. F
public class ProgramCompare
+ Q  ?% s$ U7 y" t: |{' K% o7 q4 g) r; a3 I# C9 I
        //-----------------------------------------------------------------
& C, a# R+ {- q) R  f% g1 \' Y        // Constructor
; w$ z6 d$ H! \6 X! z3 b        //-----------------------------------------------------------------! j: ]8 p) ~7 [+ f1 f
        public ProgramCompare()
; {) E3 G- l; U6 R        {
9 g2 U& {9 u9 F- I% s) n        }' n, K, i& T# c* V7 K7 W

( f% e) Q: Z5 l  z! Z3 n        //-----------------------------------------------------------------' f8 `+ ^8 b! r* `" f
        // Method for testing that class has been reached9 r1 Q0 H2 g. c" W
        //-----------------------------------------------------------------        . h( Q; |. \. A4 ?

2 ~6 \7 z, m+ a5 X9 \( h        public boolean ProgramCompareReached()        
4 n. e# R& `$ ?' |. b& V; M; g) x/ ^        {
) {  B2 B' v7 x  B% y$ ^2 R      try 7 F: y: e1 q2 N: O
   {         ( n% m4 E1 k6 R: N; U6 Z
                        % o6 P% d9 L+ ?' W+ ], _- B  A4 u
                //********************************************************************
/ t7 A% V9 H/ d$ [                // Try-Catch Statement is used to handle exceptions - such as file not found
& @! C1 G/ {. n                // Reading the files will need to be placed inside a Try-Catch - just like this one!# `# h, f% Q* l" |! k1 D
                // For more information see page 534 of the textbook9 g1 ^% W) G1 {" K
                //********************************************************************
4 |* z2 ^4 G9 \1 z) J                     # ~- n, x, @1 @" ]
        }1 m, @* A% C7 o
             catch (Exception ex) // Exception caught here and message displayed to the screen % J6 a/ e' k( o
          {, c, V; L8 Q! D+ Y
                    ex.printStackTrace (System.err);  _1 g0 o$ Z9 @4 V" F& R0 n
           System.out.println ("Error message goes here"); // Replace this error message with your own         
. J! L! x& a0 L/ b/ u2 l2 u        }+ o3 R- y3 B4 e* c' u1 x
                return true;
* I" u* A. z. x  `* C) s$ [        }3 t% }6 `  R$ r( w& v) s# K
8 C  [4 u8 ]7 V+ u2 e0 N; x4 ^
} // end of class ProgramCompare
0 i+ g) U) B; a+ B3 r6 W9 m8 T; N# Z. D5 X
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; F2 j+ T+ b3 t7 W# K  I" h$ w
//  ProgramCompareMenu.java    Provided by: DRS
6 C0 N& n' b6 @//9 @7 [8 L" Q+ `  ?4 B* p8 y4 w6 z
//  Calls AuthorisedUsers.java and ProgramCompare.java
- t1 J( U( @& {# V# |+ X6 K2 n8 B//$ f5 C+ K; o/ \) x5 V# p- S4 y$ B
//  Driver shell for Assignment 2.
1 T% [9 @3 s$ H- C+ W0 w$ x//********************************************************************: ~/ r( [' i, w# f, q! X- @
9 Q2 u  Q2 U) n/ O# h$ U, \
class ProgramCompareMenu
' {6 ^/ C" D% C3 E{
: Q) M3 m6 A  y/ u' B    public static void main (String[] args)! l( y- ^$ o3 J
            {8 r0 `& D1 b: k. ~0 K+ J
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- @4 w0 e8 y' d
                ProgramCompare reached1 = new ProgramCompare(); ' K% K* H6 ?6 P2 X
                AuthorisedUsers reached2 = new AuthorisedUsers();       
* V. `* o5 i1 H. f                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 K$ j5 o% @8 @- \- i                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        % T1 ~( h8 h% q! `" s3 L
        }5 {" T2 a6 _! N% z8 U1 Y" u
}// end of class ProgramCompareMenu
% n3 L$ s: S2 t. Q5 l% ]' g( u' m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 I, C) y# |  d. e; P* J7 Z) ?: v3 `) V' b
//          AuthorisedUsers.java          Provided by: DRS! g8 W# @) T- E6 W1 v/ X
//               
$ h: \, V) P- F9 N//         Program shell for Assignment 2
$ Y5 D& I0 ]" V//
3 r# u3 v1 p1 v4 a//         Represents facts about an AuthorisedUser
/ R- d9 `9 G/ J  |//********************************************************************
' v5 r. g# W- I6 O( S. t, }. c- D0 x5 z) A" t2 K
public class AuthorisedUsers
. s: Q* m) y1 ]  E- w    {% c$ d2 G; w; R# Y1 V

; ?- }; D2 s; {- a5 h) u3 q! }        //-----------------------------------------------------------------! r+ ~4 f8 H6 B7 N' w
        // Constructor
9 t4 ^# c# Y# V4 W        //-----------------------------------------------------------------  Z9 O0 e& A9 B4 d2 R# I# i

& b! G2 ?: N' W, @4 f$ A2 n        public AuthorisedUsers()5 v1 j0 p5 A9 D! x
                {
) Z: t% V' _3 A# q. P                }
7 P) Z- {; O: L8 l' E& M0 \. J8 }& C, C  [2 E9 J7 Z. a
        //-----------------------------------------------------------------
1 c4 p0 j3 K. S" \+ }; l) h( b        // Method for testing that class has been reached
/ ]! T  C3 U5 h. p        //-----------------------------------------------------------------       
6 T5 B5 b: e! m  X6 A: R. n" w9 P        public boolean AuthorisedUsersReached()  d8 g3 `: g8 g0 ?! u1 t
                {
3 r! U# `4 m, D) I  b                        return true;                       
7 s, W0 ?: q( P( J" N. I" O; V                }) S4 ~" x& Z6 W
                . R6 V8 m( y& m& t9 h
    } // end of class AuthorisedUsers7 f" j& f3 @. h% q1 i$ v( S. [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 |; a4 i$ x! KShanghai - 2007
+ ]1 S* K% f& }# @" B, @- SAssignment 2
7 N' C! g  P. lDeadline 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)
: C4 H+ t, {$ {7 T1. 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.- \* c& u" z1 S  Z( s. B
The staff must be able to:
$ T% u2 X5 ^! u6 p Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" I% o9 F7 y/ H( O2 J5 y1. 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% c* t- I! e" y8 o' A; Y. f
 The interface should provide a menu so that the staff can:$ N" i6 h* u* ^2 s7 M
a) Enter the names of the two Java program files to be compared
0 \+ k: }& ]0 w4 D2 ^; r For this assignment, it will be assumed that the two Java program files are in the same folder as your program." S  U, o, T$ C! Q% I
** 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).
' @6 d- Q* M* Y/ I9 s  E( kBSA104 Business Programming – 2007: Assignment 2
# ?5 s$ X7 {- G! PPage 2 of 5. E* n; Q' V$ o: C, N% |
b) Print out to the screen all the lines of code that are the same3 Z* J' T0 F$ t+ a* M
 Include the name of the file and the line number of the code being printed for each of the two files
  f5 e' F, O; B- V' \; s5 b# ~c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
1 ]# M: Q5 C4 B/ N the name, username and department of the user( A5 T$ i/ E! g1 ]& ]! A5 d
 the statistics of the comparison
# K% v) B: j4 G& Z# U0 L# ]1 W2 {- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 Y: t) u7 J- l the recommendation for further checking
! P8 S' G+ \" d- W+ h- 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" W) C; Z" }3 c+ |1 L5 X3 ~2 ?
 the names of the two files compared
: ?) j8 y; Z" Y/ R, ^! x% ld) Leave the program (exit). {9 K! U, p; h' h+ t5 V* M
The ProgramCompare class: (Total maximum 20 marks available)2 L* U. S. f% y, q
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)
. v- W& L# v9 H' p; ?5 |  d3 B& x( Ea) provide an error message if the files are not found or there is a problem opening them5 p1 t# P  P* m3 _* j' ~
b) compare each line of code9 ~: b) }3 E0 f3 t$ Q
c) print out the lines that are the same+ c3 b, k& c, `
d) count the number of lines compared / lines the same$ t$ W2 g# c5 X3 q
The AuthorisedUsers class: (Total maximum 20 marks available)
5 M( ?; z$ z  w7 \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)
+ N$ C1 D- D) B) y2 b. B- j* F4. Provide methods to:
) s& l6 V4 \/ c7 F* o  ~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
; d7 V4 \) ^& E1 u, n! D4 w% l" Fb) return the name of the authorised user
  H: ~/ d% @) nc) return the name of the department of the authorised user+ N" ?6 g% O( d  [
Individual Data (Maximum 20 marks available)
5 i7 t+ K* F6 m5 n( {8 t5. 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.: V3 W9 K( G$ B- r5 i
Documentation (Maximum 10 marks available)
% A3 N1 n) `. t9 B& {; 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.
" ^( S, U- T2 F* |! |1 R0 L5 Q7 n  r1 KBSA104 Business Programming – 2007: Assignment 2
6 }" {* \9 ~- L% n: f! aPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& T$ c; M, \9 ]  H+ P
不过你要翻JAVA的类库说明。你有下载没有?8 M3 }* a6 D9 Y1 n8 S& P
查询关于对比的函数。貌似关键字是contrast,还有compare' D. {2 ?. }- b1 e" f2 o
$ Y- d6 G1 @, J4 y8 b. n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( E) b) I* w! R6 C3 `痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; |0 w2 p) W) a$ \. `' `/ k可以下载到的 是 jdk-1_X_0-doc
  c8 y( k+ O( e6 `) X* g
) a5 d% u) j4 \% U6 _0 Y' D8 Y: M[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-28 05:39

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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