找回密码
 注册

QQ登录

只需一步,快速开始

查看: 939|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 i2 y/ i; p$ M8 i1 C5 U) p . N( B5 l. q: Y1 B5 i! T+ k
回复

使用道具 举报

 楼主| 发表于 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 Z  F) T  U) {//  ProgramCompare.java         Provided by: DRS
$ A; t& Z5 e$ g4 V0 D; S6 {  p8 u  l//; R6 q2 [. S: Z( }9 l" V
//  Program shell for Assignment 2
4 G; X( R6 O/ n6 y  @//
! ~, b7 T: C: g7 Y. W+ m//  Compares two text files line by line. R2 P6 {/ J0 q* E% r
//*********************************************************************6 ~. Z/ K  x. g& Q
  H" }$ C2 |5 z
import java.io.*;- z3 C( r; o& U0 R- @+ {/ x4 f

$ u$ t" }8 a; Hpublic class ProgramCompare
$ q8 D- {" @' x2 L8 ~0 Y! N{
3 e5 Y( l4 N- P6 R+ C6 @        //-----------------------------------------------------------------
# L5 J% N; I+ J- i7 |" ]1 O        // Constructor2 a3 V) w, Q  j! U, M. Y8 \$ B: F! s* l
        //-----------------------------------------------------------------: f; t& D# Q* m0 T
        public ProgramCompare(): `+ L7 }, u  q$ ~) T, j0 b
        {$ V6 ]) N1 |4 K+ x
        }
4 h* ]) z0 j) K
+ G0 F1 S. j% l3 Z. U8 @4 X) S- O        //-----------------------------------------------------------------
- l: W2 x2 j2 D6 n        // Method for testing that class has been reached
1 e- g4 B$ [0 h6 `, V5 [) U        //-----------------------------------------------------------------        . S8 W8 F, W; g" f) \* ^

  V+ v9 A- u9 N        public boolean ProgramCompareReached()         ' K' s" b- ^6 J& N  ?
        {
  t+ D! r9 j0 c2 b5 O      try
% O3 c# Z2 e1 Z- v& B& x   {        
1 e: ]$ q. t! G$ R& x                        2 r; r6 B* _1 l
                //********************************************************************& z* C' Y; T/ w$ O* W1 i% k. ~$ w
                // Try-Catch Statement is used to handle exceptions - such as file not found
. j/ J; V' }5 ^0 B4 j                // Reading the files will need to be placed inside a Try-Catch - just like this one!
1 M& D( C0 [& p: _) [7 l8 v                // For more information see page 534 of the textbook1 r% j1 |+ y" W2 }- L. ]0 d
                //********************************************************************: E' q) C+ b4 _" i. C' l
                     . H5 N& x+ \# l
        }" e2 J! B) \0 O" f& f9 N1 a$ v
             catch (Exception ex) // Exception caught here and message displayed to the screen 9 b/ {4 p. X9 x, }, W
          {6 N' N+ N0 ?$ |' S+ ?5 A  B
                    ex.printStackTrace (System.err);8 C0 D5 H1 d2 Z! i6 Q5 Y, y7 \
           System.out.println ("Error message goes here"); // Replace this error message with your own          ! I1 F( S0 H" A8 F
        }
% I3 O; W; F9 k' W( w                return true;" F, K. Q' u1 M; F
        }. S2 n0 A! z( h# F' d% m

8 }' H9 N3 Y7 @; c! _3 V8 N} // end of class ProgramCompare+ `. T4 O2 i% C  y& L; L% _
( o9 t& B* u, n* u( c/ h( m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
0 {9 x' ~, H7 _' A- e0 e//  ProgramCompareMenu.java    Provided by: DRS
. N  E$ j8 o! X8 G: b: \/ {+ n, W//
5 x# n) S1 R" R, z9 I//  Calls AuthorisedUsers.java and ProgramCompare.java
$ T$ W! V( Y$ F* ^# a0 I//
5 C! a' e1 l7 w2 G//  Driver shell for Assignment 2.
  Y- z: e& R9 Z4 [: E//********************************************************************) Q0 o$ \3 {- F' |3 q

. W7 U% ]/ b/ v' U: Aclass ProgramCompareMenu
. z* @9 `. r& _! H: h& r{
1 U# o/ R: o. r1 C. K# O0 ?/ \    public static void main (String[] args)
$ s% v& B/ b" d5 ]! x5 e0 ]            {
, a+ |: I: ]  k* U                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable% m& q2 H( V) O4 _5 q
                ProgramCompare reached1 = new ProgramCompare();   v% C8 U3 V& [( h6 t
                AuthorisedUsers reached2 = new AuthorisedUsers();        # P$ [- n$ @! ]0 A" L
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 G( i0 L: u, C6 W( _$ R5 w
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ t& Q) K" z0 {7 @7 {* @7 f+ V        }, h0 Z  ]5 K+ K, U9 o
}// end of class ProgramCompareMenu
$ b# v9 F1 i4 m' \' b: w- v$ g7 X* y+ w2 |4 q! J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 v/ e% r) k2 \) s7 b1 Z8 k9 p7 A//          AuthorisedUsers.java          Provided by: DRS+ b) E2 j5 y9 p
//               
) B1 q- y5 y" ~) Y; q1 s//         Program shell for Assignment 2
2 `- t$ o# T5 B5 f/ u* n//$ n) i6 `8 I# O) t
//         Represents facts about an AuthorisedUser
' Q: U1 i, i4 j4 G( R" o% A//********************************************************************
6 G5 F- {; H/ j9 D
, u- a# p/ H# G0 S: u" cpublic class AuthorisedUsers
5 i) h' a& n+ D    {1 ~9 Q# w* N8 {# Y" t& p
7 W) w9 H1 Z0 L" U3 d
        //-----------------------------------------------------------------: `. X6 M. q6 c1 v
        // Constructor! f1 u8 r( ]. Z( r, ]1 }
        //-----------------------------------------------------------------& v% f$ S# X# E- Y' [5 Y

( z% s4 B- x2 R6 [; j        public AuthorisedUsers()
' \. u  Q3 C3 g3 W+ h                {
( U+ w) X" W! Q                }: s$ o% I5 I' S9 i! u! g

4 v: m9 ^: w! w        //-----------------------------------------------------------------
/ r: ~9 R, T! e" J; U        // Method for testing that class has been reached  I8 w) I% q4 S) b% Z
        //-----------------------------------------------------------------       
0 h5 S3 g5 [: t# G9 O8 q        public boolean AuthorisedUsersReached()5 @0 q6 K  ~& R/ Q
                {7 U+ s5 H6 k1 C
                        return true;                        + H/ G4 e: @  ]" o  i1 `( \0 M! z' f
                }# X: O$ h0 {8 P: R5 A2 {9 \/ \
                ' I- P: h/ _/ r' }0 t
    } // end of class AuthorisedUsers
- j9 ~7 {. w8 c" V6 K& M4 H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
% P3 E  R" b: Q% a9 h6 f1 hShanghai - 2007! C- |3 x: w  l/ {0 `+ g
Assignment 26 J- u9 _' s; h5 x' B- Z; }
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)7 N9 O- [6 Z8 o7 @
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.
' p( ~" W" ~9 \" aThe staff must be able to:
2 m) }6 v, y2 A0 D8 T/ Z) m! E, p Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: b- l" W) \: F- d% ?" B2 h0 g1. 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 Y% j$ y5 M  L, p% |
 The interface should provide a menu so that the staff can:
8 E$ o- ]! d+ w! e) `7 n8 n( Ha) Enter the names of the two Java program files to be compared" T  Q7 W! E' g+ m; o- f/ ^
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ F5 A" [* {- ]8 p2 O/ W3 O
** 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).  D: V: |' v# S4 R# V' ]
BSA104 Business Programming – 2007: Assignment 2
2 x6 o+ M, y6 S/ dPage 2 of 5
8 ^0 K2 g8 A% X; t& G/ Zb) Print out to the screen all the lines of code that are the same
7 v9 |& f/ f% z) _7 l Include the name of the file and the line number of the code being printed for each of the two files4 \/ n+ h$ P" d0 G) W+ G% d, r) p
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
$ v; q6 z4 c/ w* Y! K# [ the name, username and department of the user4 @& O5 _2 ]' {" B$ j) Y  n
 the statistics of the comparison
& r0 H" z, X5 C' f) m4 k- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( W0 l8 Q: A9 o5 Q) z. c the recommendation for further checking
9 X! i" _" ]7 b+ p1 @- 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' s9 S5 M2 M! N7 u* S% _
 the names of the two files compared5 N6 F: f) i/ v4 A! ?* A
d) Leave the program (exit)
0 Q7 {6 d  F+ PThe ProgramCompare class: (Total maximum 20 marks available)
, I8 b, @" R7 D: U2 m2. 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)
( s* T5 J# |5 E' q. j: aa) provide an error message if the files are not found or there is a problem opening them7 r( y/ W% r! K) N5 B( N7 {# S+ {
b) compare each line of code
* X  B* ~5 U: H9 G) zc) print out the lines that are the same
& Q1 D1 `% v7 ?) C' F" `( G* R9 D3 Gd) count the number of lines compared / lines the same
9 h0 h. U' \+ Z+ J3 w: |" fThe AuthorisedUsers class: (Total maximum 20 marks available)
. U- r1 b: g9 b; b3. 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)
7 W7 S$ g% I3 X0 S2 y- b& W4. Provide methods to:" E2 Z" c( G, c6 t# M& }* G
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$ k& u7 U; r* u! V, b8 d% P
b) return the name of the authorised user3 U* Z! B, Q; V/ Y, E+ k$ C4 `& W
c) return the name of the department of the authorised user3 p- e# d& t- ~! f  K
Individual Data (Maximum 20 marks available)" g1 G. m/ H- E
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.! ^, S7 U( D& I% n' [& M7 N
Documentation (Maximum 10 marks available)
9 q) l1 @# z( X- i% O6. 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.# w5 v7 L3 m( `  R" f8 M+ d
BSA104 Business Programming – 2007: Assignment 2" G+ ^" v$ V$ J, \
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
# |: N4 m* A5 B  W; n1 X6 s不过你要翻JAVA的类库说明。你有下载没有?: v4 m+ G) V0 w  O- O
查询关于对比的函数。貌似关键字是contrast,还有compare
+ J$ ~4 W7 L) {5 D' h
# B2 _- d* T7 ]+ }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -8 T5 R) j9 y  z& Q$ O! }% S8 m
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
# U" K5 f% Y0 Y+ f9 S可以下载到的 是 jdk-1_X_0-doc
% Y/ m! X- B$ R6 X
5 g; P% h% q3 K: b* p) I4 L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 03:05

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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