找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1872|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 w' G# T- g S/ i2 U5 J& O+ P1 M- U; D5 l
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
) F5 \+ Q  o7 g# x' [//  ProgramCompare.java         Provided by: DRS/ z. `6 u" X$ {& o  E2 R0 ^
//
- Q; M. ^1 [& N# p7 o//  Program shell for Assignment 2/ @1 T+ K9 Z8 B
//( m& E1 v: l) {/ t4 H
//  Compares two text files line by line+ I0 L5 W* S  a# @
//*********************************************************************7 k* B4 ^, }. J" u6 e! o" n' `

: d( k2 a; e* ~3 p+ b, @import java.io.*;
6 [  i6 H# T( H) _7 |8 D
. W. q& j  K( ~, opublic class ProgramCompare
1 D7 g+ k  T, A9 |{
" U: W/ n! S2 ~* y5 Y1 W        //-----------------------------------------------------------------$ ~1 d% e: h$ {7 D7 Y* t
        // Constructor
' [& g  ^7 f; }        //-----------------------------------------------------------------
; J# X0 }1 r& \" w& P( l        public ProgramCompare()
' b' |2 K: A& Z  M7 B        {
  D3 K, h7 F- a$ A2 d        }, a* L7 A/ {; L) ~$ n
9 O' P$ N- ~5 x- G8 `$ O: X
        //-----------------------------------------------------------------7 J& Y) v7 v% g$ V2 g6 w( `4 _
        // Method for testing that class has been reached3 K7 e3 i! p% Z
        //-----------------------------------------------------------------        . s  E* Q  B8 i& f* F- |+ D

& K. X6 \/ M  e* c4 \+ |- S        public boolean ProgramCompareReached()        
/ [- l( f- J; a9 Y8 Z# ^* y        {
: l+ X; D$ R7 F+ q/ S2 B      try
2 [  z) x8 g" z8 X   {         $ _4 L" C% j/ a! s% H
                        5 m7 u  [# B; I! N" \
                //********************************************************************/ \# @2 M0 _- H9 r; q
                // Try-Catch Statement is used to handle exceptions - such as file not found
+ [" _9 Y7 y: U0 C4 r  u) P# g& D3 O                // Reading the files will need to be placed inside a Try-Catch - just like this one!8 k' M1 X) `, Q, `
                // For more information see page 534 of the textbook
3 w6 j( {% C( V8 A: `! D                //********************************************************************; M5 S) f# {& L  [% h
                     " m. S2 y6 k: Z3 _
        }
( e: j% O0 C) l: I             catch (Exception ex) // Exception caught here and message displayed to the screen ' _& a) s" t; g! {8 b- X4 f# f. [
          {7 Q; t. L# \) U, ?+ q! E
                    ex.printStackTrace (System.err);( a$ A$ v. h0 B: T! ]' W4 G* k# c
           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 M" a( a; i) b. ~6 F; I3 U1 C* J% l        }- Q6 H9 v/ r% p% Z8 N3 Z  W' l
                return true;
/ a0 B2 }- Z) j! V1 I+ I* {5 d- r        }0 Y0 J9 o" u2 u" V
' T+ N! i) f% }3 T* G- p1 t
} // end of class ProgramCompare1 r5 u8 R2 P- S8 f5 H5 p* E8 t& o
% o$ k; g( [6 q+ D' ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, r7 D& Q! e+ T1 I3 I3 Z2 u' r//  ProgramCompareMenu.java    Provided by: DRS  g2 S3 {0 k* n; O6 e+ Q* U4 i% d
//- B' E# w& k7 F
//  Calls AuthorisedUsers.java and ProgramCompare.java! \) L6 f% h' a7 ?% j
//
& S8 n" y$ e9 `$ o//  Driver shell for Assignment 2.
* F! b* ~- P3 k, E8 j! ]//********************************************************************
% ^7 n" X6 Z+ ^- Y6 x9 U$ E7 q. K7 d
class ProgramCompareMenu6 ]- j% Y7 A) Q4 P) K. i( \
{
- c' p1 k8 f& H" @- C& d& |' V: Q$ t    public static void main (String[] args)4 g1 [- V) J- F9 ]; }
            {1 d$ r0 B9 h5 Z' m; A) }' o
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable' G  o; e+ G) O8 P
                ProgramCompare reached1 = new ProgramCompare(); ) I! z$ A- |. W1 J9 H  h
                AuthorisedUsers reached2 = new AuthorisedUsers();        . a+ P  I. t) O% `
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
$ Q& U- F8 j2 u' y, l0 A+ E                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" q. c! d, L; S% R        }
* e0 c& Z  j! w' f7 i, K}// end of class ProgramCompareMenu5 M! f3 h/ Y: @

5 w7 u& K  f% d//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 _2 ~" h& U0 a//          AuthorisedUsers.java          Provided by: DRS( o: H+ S( h2 J  s
//               
2 l+ p* P: N" |% v//         Program shell for Assignment 2
2 o% M9 l. F0 Z4 I  z* Y//
' ~8 k0 ?5 p" N  C, u) @//         Represents facts about an AuthorisedUser
) f7 j) N! n3 J, C- R/ z//********************************************************************1 |# r7 \4 f8 j3 S0 o1 z5 C

2 q4 p5 h5 a9 F5 A- q' dpublic class AuthorisedUsers
6 _0 ^/ Q! v; j* [" Q    {
0 z3 J# w. U% |" x* E
# N7 v) i; I" U0 M! C) i3 X! u        //-----------------------------------------------------------------
* X/ C7 K5 t" _/ m  @( `        // Constructor
# F. o  S# J: @3 C; T0 f6 p        //-----------------------------------------------------------------0 |% Z& C9 V0 L0 f  J1 g, h4 }0 H
/ P: {  d/ ?8 U( L9 A# v
        public AuthorisedUsers()# ~' X4 q( Q+ y
                {
! y+ G( `  k- A. s                }( v* v& w0 V  V  X  K# @8 n; F
! v; m5 t6 H- c. t
        //-----------------------------------------------------------------) j7 `* n' s4 _  V& e. ~# a2 N
        // Method for testing that class has been reached/ D1 Y7 V5 D) N% P6 \5 A
        //-----------------------------------------------------------------       
' l5 z' ?4 A% ^- b' s        public boolean AuthorisedUsersReached()
1 M3 w) x; o' Y4 |                {
3 i. g+ D5 O: G# t4 ^) j$ Z! R                        return true;                       
- x& f8 Q$ Z+ T. P7 {. w                }
* F$ u- V2 w6 s/ Q               
+ ~2 P3 D5 {4 e  M/ c- u    } // end of class AuthorisedUsers
5 x( z: R0 t' b+ f/ g- k& y9 ~& f; A; G//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. }. H( C# d  \0 ?5 i
Shanghai - 2007, Z" Z, L* ]" E+ J, x' u
Assignment 2) C" t0 ?- c4 v; Q* Y
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)
. s5 M8 G1 A6 g" O1. 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.
" V  G- r2 u: n' E; T/ _  T+ q: r0 wThe staff must be able to:
) _& d7 [; P/ p+ f$ K1 N+ R Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  x; G7 H9 W: r
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.
- j* O4 w% P5 N3 C$ g! u  c The interface should provide a menu so that the staff can:
/ b5 E! C6 o7 Z/ m( V% M$ h6 U) `a) Enter the names of the two Java program files to be compared9 {+ V' m1 n- l! u3 ]' N  i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 n! h. K7 A" w  |5 b5 F3 R** 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).; j1 s6 o5 A  s/ f
BSA104 Business Programming – 2007: Assignment 2
! Q1 h) E+ q6 tPage 2 of 5
) a0 i4 G  w7 S% w) Jb) Print out to the screen all the lines of code that are the same
/ d0 w  E$ J, w; g, T! F Include the name of the file and the line number of the code being printed for each of the two files/ _9 X' p# ^; b5 R: x4 m7 g( ?
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 W1 e0 n7 T' L4 ]; e
 the name, username and department of the user) m: \8 m9 w4 N, J8 D1 Z
 the statistics of the comparison
! L( f4 y( Z$ {9 m3 F9 W7 }: l3 z- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% b8 G6 f' I3 W" p3 s1 ~- g& D8 s
 the recommendation for further checking- @8 P1 r" g, W; k* d% r
- 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 closely1 ^6 P1 {8 x1 V/ {) p- b
 the names of the two files compared- E  z1 _% ]3 P" N; W
d) Leave the program (exit)
, n# X5 W7 i) e# z0 @0 sThe ProgramCompare class: (Total maximum 20 marks available)$ h; l* W2 o7 l4 i# Q, D
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)
0 e2 S$ Q5 c& s/ X3 f; Ha) provide an error message if the files are not found or there is a problem opening them% I! t5 ?; l  o# L! y3 u* W3 U
b) compare each line of code6 b1 M( t# C5 `0 {: ]( X9 M
c) print out the lines that are the same4 ]0 ~* F0 t# _; p% J( E
d) count the number of lines compared / lines the same1 E+ w1 i3 j3 k, K6 i+ {
The AuthorisedUsers class: (Total maximum 20 marks available)
4 y4 O# Y* }- v# y# s4 n$ p3. 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)
* G  P% |/ l$ `8 v4. Provide methods to:  z+ z& o- U4 T5 s
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 match6 l: }; G# G% E
b) return the name of the authorised user
( d5 k& j# y. R4 K; }9 ec) return the name of the department of the authorised user( P- L* o: ~3 ~( k. ]* g
Individual Data (Maximum 20 marks available)9 y( |1 e; t, S% c: U. |* _6 j4 A
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.2 M0 l' o) \* W: L2 K& z
Documentation (Maximum 10 marks available)( I) @# B+ [7 X7 D
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.
% I( t9 F7 Q. D* H/ _BSA104 Business Programming – 2007: Assignment 2
# h" V+ G+ ^: h; W$ A& V5 {, l% ^Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ R6 A% w/ {+ C$ S不过你要翻JAVA的类库说明。你有下载没有?
# X  q- ~8 O8 F6 a8 d: m5 \9 ]查询关于对比的函数。貌似关键字是contrast,还有compare
& w& U) j9 c7 M4 w% s/ ^
7 r' C5 Y" f5 j2 V6 K[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; o/ `1 M) J& R痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
2 u2 k8 T& j: G9 L. T3 Y可以下载到的 是 jdk-1_X_0-doc
6 H( t( B) A3 x$ }# M
* m# z" I: }2 f- {& J' Z1 R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-12-3 21:35

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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