找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1787|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 g* Y4 T. f# x# b: s' z, q1 ^ 4 l0 K! y3 e9 y# y, p8 l3 x' q( i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************( ~" [! {& R) c7 e+ a
//  ProgramCompare.java         Provided by: DRS) W- `# |9 U: _) k) E
//
  T' R9 f" j) a, ]$ L0 g//  Program shell for Assignment 26 Y, F  J# i( a( H7 H
//
; S) e- E* `- y$ ^/ D& ?6 w) K6 B//  Compares two text files line by line8 Q# Y$ U& |7 l/ H: t
//*********************************************************************. ]. G2 ?8 E1 x' O. K! P. u
; \# e7 t( `, P2 ~% t9 |7 S" g
import java.io.*;
. z' ?" C" M) h7 T' C% P
# }4 {! L4 y1 `) f: gpublic class ProgramCompare% n; i, D, o* P6 V
{4 y. P7 \' J/ o  N5 t/ n
        //-----------------------------------------------------------------
6 D0 E1 _" Y! F# n. a6 W- r        // Constructor
8 b5 `) g( c$ p& k1 X        //-----------------------------------------------------------------
5 `% `6 c" U6 }# g. v' Z, N5 D        public ProgramCompare(). z- T6 k' v/ V6 {
        {4 H5 r; }8 Y$ V/ g; b) Q
        }
4 N- e) N; r, h8 y* F& a5 @
. r8 s5 U& U8 L9 \        //-----------------------------------------------------------------
) {5 s3 Z- N8 n7 ]. P        // Method for testing that class has been reached
. Z. Y6 d% c. @0 a* Q4 {# ~        //-----------------------------------------------------------------       
9 q: X, ?5 B  O: v' ^9 M
$ m; F0 x; a' B' a( H  d1 N        public boolean ProgramCompareReached()        
2 C3 }' z' M9 P. j6 N' {        {) @1 f, a) k" K9 h4 h
      try 1 U" f8 G( y/ e0 ^
   {        
$ a/ P7 F; T- T8 a4 v/ L                        ' Q" G2 C; k( N) O3 I6 ?5 q) I
                //********************************************************************
4 \& e6 y0 t8 d% h& u                // Try-Catch Statement is used to handle exceptions - such as file not found : u; p8 b9 F0 r4 s
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
0 J6 _% L3 R) {  ^                // For more information see page 534 of the textbook
; \( O: ^) S, [+ t% z                //********************************************************************, d5 J  ^8 u2 c5 d0 o4 v; d
                     7 t0 P) u* c5 X* p5 K* s
        }( n, G4 ]3 ^8 H2 k! f
             catch (Exception ex) // Exception caught here and message displayed to the screen ' _# P7 L  G; H  ~! G, A
          {
" Q' x0 m. Y* z; J8 |8 r3 O                    ex.printStackTrace (System.err);
3 E: Z' k$ L3 H: x0 P* m- L           System.out.println ("Error message goes here"); // Replace this error message with your own         
! t7 h; h/ h+ ~, t  J  Q% P        }% x& f$ d. v% J) i1 s" T1 P
                return true;
% Y- s9 _) F9 G6 S0 E- |1 V# z        }
, E( X3 k$ n# g! d5 S! p) X
% Y# R3 _+ {" g1 O( b} // end of class ProgramCompare
0 ?( r$ g- O" o; h# T( |& X+ Z! a8 i/ |5 S6 F; f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
% F2 j6 |$ {( D2 @! r//  ProgramCompareMenu.java    Provided by: DRS
. Y( e: W: ^# ~# c1 ~//
/ a5 X" l$ ]3 D) f* M* H//  Calls AuthorisedUsers.java and ProgramCompare.java
4 `) ~% s3 S2 F2 `0 t/ D. n//
: Q1 l$ W* X3 l//  Driver shell for Assignment 2.7 Z2 S; B; }* _6 n
//********************************************************************
8 @- `  Y2 k, S' |8 r- k# L7 G' [- \
class ProgramCompareMenu
5 x6 W' w6 a' N4 ?: {{
9 |/ g3 q$ z' N0 _    public static void main (String[] args)
+ O9 h8 ~' f; z2 ~9 P& j& t( C4 T            {
/ `5 j9 d/ E& I% p& K) c                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable) P. u* j: p, }& ?) R. E( A8 ?. J2 A
                ProgramCompare reached1 = new ProgramCompare();
* S9 Y% k: B4 d3 q, F                AuthorisedUsers reached2 = new AuthorisedUsers();       
( _# _; \- m% }/ P( V+ g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 r4 \# y! S0 c7 e                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * {2 A: T7 N" v
        }
. H4 @' M2 B" w- O' r- d}// end of class ProgramCompareMenu! K5 w+ ~, n3 b5 `  B
* d: _  l) N% e* i9 `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************/ A& o* M* X/ C' F) q2 f
//          AuthorisedUsers.java          Provided by: DRS- Y6 b% N2 {1 z* {7 r/ Q9 K( b
//                - d; n8 f9 n/ o7 B  X$ J' G
//         Program shell for Assignment 2, A: `# J3 r6 z% F& g  i
//
7 F4 l, {9 X2 i//         Represents facts about an AuthorisedUser4 u7 z: I$ e+ \6 O: f( W, o8 A
//********************************************************************. G  t; @% S' k: b2 Y8 {; S

0 w; z+ t' M% S5 `, h6 P( c) Kpublic class AuthorisedUsers
, W1 i! B2 A* b6 W" o$ r. O    {; Z% g' k# s6 K6 C6 b( r

3 O, V, H8 ~  `        //-----------------------------------------------------------------8 p) y! @7 F# [
        // Constructor$ m' @: K( I/ i! w
        //-----------------------------------------------------------------
$ N# ?5 J* t/ m) x' u& A" e& w
; M3 b4 L4 K% b$ D  \- x4 e        public AuthorisedUsers()
5 O! n1 O. ~- C                {; S3 x1 x4 B! b5 ?- }* D
                }$ v! v1 C0 R! Z! [- @/ ^' ?2 K' o
& e. [0 f2 b/ ]* P. z
        //-----------------------------------------------------------------( F7 I/ Y8 w/ t! W6 ?! R
        // Method for testing that class has been reached  j* B  C- z5 F
        //-----------------------------------------------------------------       
6 i8 t7 w! d- \5 j& [- Q2 K        public boolean AuthorisedUsersReached()
: j- B* `) L0 ]5 X- t, _                {
5 V- ~' H! U" I: L% D                        return true;                        ' _1 O% h! ^! ~: w8 f- Y
                }: ~" R& l! e! S% K% m7 p7 Z
                8 n3 b6 W9 i" T# |
    } // end of class AuthorisedUsers
3 `' u1 H0 g: [; N0 V2 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: q5 k9 ]; ]. d" _! cShanghai - 2007  m# H5 N' |: q+ F6 Y5 L
Assignment 2
* o7 K2 j' u5 A) q/ V8 K$ nDeadline 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 b, Y& p! o1 `  j1. 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.! @( w6 ^- r0 h
The staff must be able to:
0 \5 g4 n9 ~' m$ e Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& }* J) _. d1 r- G, E: M1. 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 |4 _7 `2 W# u8 n The interface should provide a menu so that the staff can:! W* q2 i9 f$ W2 _5 }
a) Enter the names of the two Java program files to be compared
4 o# n4 H2 |0 h5 B  r5 S0 C# D8 g. ? For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: g9 H/ W7 F& e** 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# B+ k0 w3 M2 P" M4 n; `1 ?% g1 GBSA104 Business Programming – 2007: Assignment 2
, x  i) w0 Z5 |% ^8 ~Page 2 of 5
6 s# u3 A6 F- e# d( F; g0 k6 ib) Print out to the screen all the lines of code that are the same6 d9 G% ?% y9 V) P8 R4 g  {1 K# J
 Include the name of the file and the line number of the code being printed for each of the two files% v+ u' }, T3 ]6 e9 k3 I
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- y5 A' J( x$ R0 z2 s4 F/ U the name, username and department of the user
* ]( I+ N2 B, M0 C! x! d the statistics of the comparison2 p# J1 k( `$ a" J  Z$ u
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
$ Q* K! h. y) B1 Q5 t the recommendation for further checking
$ f& }# Y, ?1 W$ \- q( h. p# P- 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
& `$ d8 |  Z' E5 u: Z0 D the names of the two files compared3 W: v5 D4 q3 {2 u/ s8 T, B9 c
d) Leave the program (exit)
! t7 Z. x' m6 k; a% {4 vThe ProgramCompare class: (Total maximum 20 marks available)
# M) r' @" N2 A: h9 y2. 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)
/ [1 K2 f  x3 J% o5 B4 r+ y0 u) ga) provide an error message if the files are not found or there is a problem opening them
7 c  i5 V3 ?1 f$ k" q' |b) compare each line of code
9 t2 `8 c: s3 u. `! ~0 x3 T5 Jc) print out the lines that are the same. o8 s& }' @: m9 o: v( V
d) count the number of lines compared / lines the same
& M  H& L$ \  Y( l. b5 W4 {The AuthorisedUsers class: (Total maximum 20 marks available)0 {. ]+ d5 N; f. d' e
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 J, j) G; s$ D
4. Provide methods to:& n9 o+ g$ e6 u
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 match2 R/ E0 r6 I) [; ?, K
b) return the name of the authorised user5 X3 H' a/ _7 u$ S4 q8 L; E
c) return the name of the department of the authorised user) n8 }' U% \% }; ~# S
Individual Data (Maximum 20 marks available)$ P0 i0 N3 Y# F8 J9 A3 S; [
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.3 _$ w0 w# B( {- C- ~
Documentation (Maximum 10 marks available)
( @; }, ?/ Y/ n8 {, m# U. U6. 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.4 F* l0 g2 Z% H) }/ N3 a& r
BSA104 Business Programming – 2007: Assignment 2; F4 }4 C) U1 ?% T1 W& Y+ h
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
3 k% Z& Q4 i$ m  J" V& `不过你要翻JAVA的类库说明。你有下载没有?
+ u& O- Y, E6 ^) r+ l查询关于对比的函数。貌似关键字是contrast,还有compare4 E5 G# j5 R( L! i) ~8 I4 w

% I: s1 D( ]4 K9 W[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -* |1 `9 t. Z) l8 ~' s, Q$ z
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 j9 k7 A1 R, J, x可以下载到的 是 jdk-1_X_0-doc# Q) U9 h9 c) T" T4 S9 i/ X

5 b, L  I2 `7 i; ?1 T$ x  }9 v5 [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-31 07:18

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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