找回密码
 注册

QQ登录

只需一步,快速开始

查看: 938|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ h+ p8 }# U: y % j0 X0 m7 d/ I2 P. y
回复

使用道具 举报

 楼主| 发表于 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 A- c, H% S/ c; R: T' G, U//  ProgramCompare.java         Provided by: DRS
+ E6 u; ?. ?% i//
; G8 |. u2 r  ^8 n3 d1 M//  Program shell for Assignment 2
8 v8 X* S+ W6 _4 \- Z7 T//
, u% \: ^" p) l) `. P//  Compares two text files line by line8 k- \6 W" L& y% n9 S
//*********************************************************************
- Q' ?8 }8 X" t% f: c* a5 ^! M: O- y1 ^/ o. T
import java.io.*;
# g" i8 O7 j& u' y6 _3 x
  o0 R, g$ p) h. f! `6 t  Mpublic class ProgramCompare$ u8 a! y+ L$ f6 s
{8 o" Q6 T( q% H: V+ V$ Q% L$ ]$ |
        //-----------------------------------------------------------------
8 I/ P# a- F' e; H, n) ?/ l- J        // Constructor
8 M, Q, n* O# G* f( H/ Q0 u8 B        //-----------------------------------------------------------------
! t+ m0 k  N2 ^" t1 P. \        public ProgramCompare()
- y/ G1 I; n) e6 \3 d0 H5 h7 d        {; P5 n) W2 k+ S; b) X
        }
! f% J8 g1 p7 ~$ k$ o) u
- X% Y0 Z( V8 n. n! h7 O        //-----------------------------------------------------------------
$ S  f2 c# o7 E9 {& H" b3 q: j3 H% k% V        // Method for testing that class has been reached
5 ~$ E1 a$ z& B* r1 x2 I0 a        //-----------------------------------------------------------------        ' u+ h) {" x. v4 _
) T9 c. q, v: Y# G: \) i1 r
        public boolean ProgramCompareReached()        
7 B# F  P. ~; s1 G" M) D        {
7 o7 F$ o. \8 K. w# z      try $ Q9 F! q3 `1 y+ J+ y/ A" \. I
   {         / |" `7 T4 ?3 C# Y+ C& v6 B: h
                       
, h- S4 r7 H1 R: i- ~                //********************************************************************  K9 N  l6 b1 J3 Y& Z6 H5 g
                // Try-Catch Statement is used to handle exceptions - such as file not found 3 U# J9 D/ Q! _( k
                // Reading the files will need to be placed inside a Try-Catch - just like this one!: e0 q7 a# w+ ]* S; D* Z$ J
                // For more information see page 534 of the textbook
  f  q/ X& g$ K/ x0 i, ]$ }                //********************************************************************4 a7 z; a. P; V( J9 R1 K, r
                    
+ i; n$ J  N* B) U        }
% y9 p" B) o3 J% k             catch (Exception ex) // Exception caught here and message displayed to the screen
4 W3 A1 H; W4 r* }) S1 U: D          {
$ {( e  v. }6 Q                    ex.printStackTrace (System.err);: G9 z! e2 q3 _8 o9 T
           System.out.println ("Error message goes here"); // Replace this error message with your own          8 s: j6 ]+ P" C
        }
; I/ i; w) v( {                return true;8 e8 O4 Z, T+ E2 A
        }9 H5 j3 y4 K. [- L$ T! h

4 w  [* N* q" H5 M4 K} // end of class ProgramCompare
* J( L/ Z1 c3 G# ^% ?2 N
1 L! ]1 o. y4 t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# t0 U2 U+ q, A/ S  \/ H( `9 w5 I//  ProgramCompareMenu.java    Provided by: DRS8 r7 Q! B4 R2 b5 ^; J0 B6 j7 G
//
4 s- j( c) w. H( L9 I% J3 T//  Calls AuthorisedUsers.java and ProgramCompare.java8 o2 d1 Z! d9 d, I$ V( \
/// E, @  n" S7 ~8 `$ ?$ @: g
//  Driver shell for Assignment 2., ~! U8 P3 A8 r$ _
//********************************************************************: B& r- z1 \4 x, b$ X4 D% T$ V

( G- p% T1 i. U: q& w5 [' [class ProgramCompareMenu
4 p, B) Z! w# P4 ]) Y: k{
6 V. b! ~5 r9 Q& \& `* g    public static void main (String[] args)
: d& e& |( \1 e0 q3 z3 i            {
! Y3 t) B* m6 l2 B" X& i" r5 N                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 r& P6 l& l* `2 m$ h0 k
                ProgramCompare reached1 = new ProgramCompare(); + {1 f- e% @$ u0 \1 T; r' f
                AuthorisedUsers reached2 = new AuthorisedUsers();        & h* I) x+ E) y4 ]' F
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 M* O$ T. S) M" ]: T3 g                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 S4 T7 B. L9 z        }! N9 x+ F8 ]: {' s
}// end of class ProgramCompareMenu6 x! f- s& `, k4 D
0 y% w1 C4 u/ D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
4 i+ R1 g7 H; @4 _% i& b- ~' a' b) l//          AuthorisedUsers.java          Provided by: DRS6 H  D) i; U/ b+ R
//               
' O! r3 `+ x$ P* R//         Program shell for Assignment 2
! m1 ~: k0 V) o2 Y# V" ^' w//0 v/ l+ P, @0 g2 m4 T8 R* _9 W
//         Represents facts about an AuthorisedUser& U; F1 D7 W: R+ H& c& \
//********************************************************************
# P$ [! A( [! F# }/ z2 z
$ \5 f7 y- ]/ J' P8 |public class AuthorisedUsers+ M- _+ F" {  i
    {* n1 t% _& s' {0 [; Y

. Z! t6 R* ~! U1 \' p        //-----------------------------------------------------------------" S& g7 S- V6 U2 W
        // Constructor
' d/ l4 \4 q; j. M        //-----------------------------------------------------------------
7 q, K; `! m! I; G* d4 e4 B
2 a" N4 F5 A- p, k/ Q. _% }        public AuthorisedUsers()
  P/ t8 H) d# A5 y7 \8 {& v% A                {
5 `+ \0 R5 r+ v                }
6 D( G  p) d4 o% L- j* c  G
+ v. n2 F* d2 {1 c* ^        //-----------------------------------------------------------------9 {/ g: j" c. G# b  y  E
        // Method for testing that class has been reached* n  |/ }  E6 B' _% b) X6 w
        //-----------------------------------------------------------------        ! L& r1 v1 H7 [7 T, P2 I8 [
        public boolean AuthorisedUsersReached()# H7 u2 H+ g2 O0 |- q% M9 u1 |( Z$ R
                {# A9 G7 \9 L9 X) k' o& v0 ^% E
                        return true;                        5 C% n9 _* x, U+ R5 m! e) N/ e4 ^. ^
                }
6 R) o6 \+ L8 [! V( H4 |# C  x               
- w- h2 x. B+ o* E/ z* J8 K    } // end of class AuthorisedUsers
) b( Y4 ~3 s% s% M' O9 C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
) L! ]' H9 c2 Z/ {2 rShanghai - 20079 ~* l  W6 \! Z1 T4 c/ {. g1 p9 {
Assignment 2  C3 p- M+ I5 M1 K
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)
0 q2 R* v  P+ 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.
3 ^& Z/ @" ?" L) J/ r; uThe staff must be able to:- u! |5 n6 s( b' e/ L. C, I% U0 k
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
) H( D, D7 ~9 J8 u& e1. 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.
3 S  t- G; ]" A The interface should provide a menu so that the staff can:
, W6 @. H  |' f* P  na) Enter the names of the two Java program files to be compared$ C' W3 ?1 }" v3 T8 W
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. H5 |, z, ^2 Z% @8 V** 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).
$ K( i/ f1 x% `! t8 U& E$ _/ jBSA104 Business Programming – 2007: Assignment 2: W; i# F3 A1 }5 @
Page 2 of 5
. _" l" k6 ?' T/ m/ o! \b) Print out to the screen all the lines of code that are the same  |* R6 g( x" u0 H' o
 Include the name of the file and the line number of the code being printed for each of the two files
7 O, [1 y( W( i# T% Mc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! `& ]/ {0 K! T8 S, a the name, username and department of the user& S/ @- p* |% m2 ~
 the statistics of the comparison
; C8 r5 j: t/ V/ i" d1 S) u4 z2 t- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 e1 i9 h* E3 c* O
 the recommendation for further checking
( _5 {# W+ b, L" H# I- 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
- `. v  l$ ]0 L5 w the names of the two files compared
8 L9 ~: y$ i& L1 l* j/ p7 Ld) Leave the program (exit)1 j: k1 P. d% t1 {
The ProgramCompare class: (Total maximum 20 marks available)6 S1 S4 P1 e  x
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, C) d$ f- @: B) [6 y: ]
a) provide an error message if the files are not found or there is a problem opening them0 {+ L" Q2 R# Z3 b( q; D9 |+ A5 g
b) compare each line of code' H  M$ c1 z% Z
c) print out the lines that are the same
, Y" K  ?9 V5 |# u/ xd) count the number of lines compared / lines the same6 A5 b1 ^1 m+ X8 ^, ^
The AuthorisedUsers class: (Total maximum 20 marks available)
$ ~# [5 i8 X8 W0 U+ W9 V3. 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)- @! r% D- c4 X& G! l" p
4. Provide methods to:
7 Y* C' I; U, P7 d. m6 t  d6 r/ W2 C: Va) 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/ }8 {4 z  q: E. G( u
b) return the name of the authorised user( F4 K  V2 _  O
c) return the name of the department of the authorised user5 g; u* C- J( S0 X2 L/ G
Individual Data (Maximum 20 marks available)/ G3 q0 V7 P& Y7 m& p
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.
/ K. y6 C" o; X1 X$ y9 dDocumentation (Maximum 10 marks available)/ o8 I3 f2 h5 C5 D, z! @+ j
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.2 z* a7 E- Y+ C: n/ R2 K
BSA104 Business Programming – 2007: Assignment 2
9 I' ~$ O; s% S2 O; f& kPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
; y5 T% {5 q3 V+ p3 y9 ]不过你要翻JAVA的类库说明。你有下载没有?3 Y# J+ V/ s* |2 r
查询关于对比的函数。貌似关键字是contrast,还有compare
! }7 t  A+ ^: Z: S3 x4 A* D, ^
" {# p% ]9 c  x% E! H& b0 p, a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# W( S$ U9 Z( i2 e0 q8 H, T痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! l, |; g" |/ n7 F* R) V3 C6 B
可以下载到的 是 jdk-1_X_0-doc
/ R" u/ D' y9 z$ B' Z
  z( {& E% L5 _! Z2 g/ B  E[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-13 14:34

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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