找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1297|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急5 _) x8 f$ D1 `$ ]7 a) o ! H6 w* P7 n- L( U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& z  V* D( ~$ d4 s2 d
//  ProgramCompare.java         Provided by: DRS& v& v5 O) i- u3 m
//
# z+ t; _7 N( T: m8 F5 k6 T//  Program shell for Assignment 2  B4 j- i/ A. x* ?2 J( ?! b) M$ V
//
. d6 @: k" M6 u3 {//  Compares two text files line by line
) o; x1 y# H3 u7 e1 t//*********************************************************************
9 O3 [3 z4 [8 k% x5 P
& j5 q4 [" }! y1 Himport java.io.*;
% X+ Y; V3 Z' I  g2 s9 p# p/ f. B5 O+ A8 i: ]5 ^- l6 }5 P- J. Q
public class ProgramCompare
/ u" x: ^! S7 q' Z9 D; x8 [{0 s9 k5 W3 I/ H9 w' a  w0 o
        //-----------------------------------------------------------------# w/ U0 Q& W* p% E
        // Constructor
( t! v$ U& V$ I' I        //-----------------------------------------------------------------
, \8 Q& u3 I  o0 m# r        public ProgramCompare()1 v% d0 C* _' I# n0 J! y
        {3 o0 }9 O% G- f- e7 _
        }
2 c* ]4 T2 I  _/ \% R/ D
8 J) t0 X7 y$ u        //-----------------------------------------------------------------
& j4 J. z$ M) w6 O) C+ @        // Method for testing that class has been reached
% v+ c# M2 W5 H% B- n( ^9 K3 n        //-----------------------------------------------------------------        / I' @. f5 h/ O( w, T
5 @9 U# |* Z5 J
        public boolean ProgramCompareReached()        
3 h. s  I% I3 H& F+ ^, R, L4 x        {
( |$ c$ K9 p- g& t      try
3 d+ c& V' E; a9 F! z1 f   {        
6 a: I8 Q) n# U7 j& {                       
8 S4 ^, T/ j% ~" b* B' T" Z                //********************************************************************' e* h. s# V4 z3 D- ^9 l$ ]
                // Try-Catch Statement is used to handle exceptions - such as file not found
- R/ z' g7 r& r6 w% o0 F                // Reading the files will need to be placed inside a Try-Catch - just like this one!
" `1 {, s' ]2 a! k; ]) H5 r3 e                // For more information see page 534 of the textbook- c/ i. u; N) d1 T/ b: L
                //********************************************************************' U3 @" {7 {* k2 r
                    
5 Q2 S5 {) p; L5 v3 r        }6 I# A, r; }) |3 b0 T1 O
             catch (Exception ex) // Exception caught here and message displayed to the screen 5 s) k" J- t) L
          {
. |! a; B6 O: y# H# [                    ex.printStackTrace (System.err);6 h9 e" ], H# f+ Z
           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 ~( m5 M& y% s! i+ ^2 f6 ^        }* t" T, N( G( L7 n+ }- v, _6 n
                return true;
1 n/ d* I. O; y: v; N! o9 q        }" Z# b1 A4 j* s* u  }3 {

+ {+ I9 |6 R. d9 b. \, S} // end of class ProgramCompare
( E8 u7 `5 L: P- ^
4 H6 R5 A  m5 s8 G0 Z1 U2 X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
% _: p% o8 [& h2 Y//  ProgramCompareMenu.java    Provided by: DRS0 s4 }3 q' m' M  o' o# g
//
1 L& L; j( O4 E* Q$ P  i, ]//  Calls AuthorisedUsers.java and ProgramCompare.java- J  X0 Q& ]: h5 V9 c( W
//% Y& m" u1 ]1 D& Q, S" W
//  Driver shell for Assignment 2.
) y2 M, q* `& y+ ^/ N! L6 b//********************************************************************
! \7 {& b' G. |% Z( p. [5 F/ t7 m6 t  ]% u5 ^
class ProgramCompareMenu5 ?, W1 {% T2 G& j
{
" F: ^$ Q( G/ U5 O) q1 u    public static void main (String[] args)
$ Y! w0 b9 E3 Y2 W4 ]            {8 k/ P+ @2 i, i
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, p+ L( _+ h+ c0 b8 J! S, w6 z                ProgramCompare reached1 = new ProgramCompare(); # u: b8 ]3 n; `1 N2 \  _4 P7 a) V
                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 I# }% G1 J! T$ s                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  q- n) ?+ m2 o: G% H( m                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        3 y  n  n6 G& _: x% y
        }
$ @$ O( D& Q6 V7 H4 L+ O2 P1 G# G}// end of class ProgramCompareMenu
6 Q$ p9 p, P! f$ p( p( [# c
7 v! S. j3 L5 y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
& s" G7 d/ v1 g3 ~* Y//          AuthorisedUsers.java          Provided by: DRS" E, s* E7 P. @  B/ J" a7 O
//               
0 U8 D/ l* Z! t//         Program shell for Assignment 2
/ M+ T' C, q4 U- C/ |% s//
- L, ?$ ]+ h6 W4 T; R4 M- g//         Represents facts about an AuthorisedUser
4 E2 m& P9 R$ P/ W! c//********************************************************************
) |' o) F8 K  u% g6 ^
- |  s! o( h8 m) e- x: X! epublic class AuthorisedUsers
( K3 D( @% E/ a* B    {
! I) o" B: O% I$ H2 H3 {
# Y5 F, ^4 g1 A3 E3 d) ?        //-----------------------------------------------------------------
4 D4 ?$ I  I* L+ _% D1 B        // Constructor- m# ?( w8 F* g! Z1 E2 O3 |& X9 D- ]
        //-----------------------------------------------------------------
: C% m( Z; W7 {$ L7 r! {$ T
+ T( n5 y( z; b+ s5 j' `        public AuthorisedUsers()
9 a: U8 G/ |/ f. I- A& h' H$ X9 o* g                {
& e7 U: m% C( p' N, }# r                }8 n2 x8 f4 f* s" }) x/ s3 ^: Z( P, X

8 N; |" s2 _2 _0 E3 O4 I. K        //-----------------------------------------------------------------3 v' h. w7 w! X0 D: k$ m! _4 w& ^
        // Method for testing that class has been reached9 y0 w/ R* Y) ^  {: o# A
        //-----------------------------------------------------------------        2 i& e# D8 G* l- s( x0 |+ f  ]
        public boolean AuthorisedUsersReached()
+ C/ a+ C4 z1 i                {
' S5 }# ~) _) D+ g' X& m                        return true;                       
& N' ]; g1 K0 K9 ^, q1 _; I+ h1 w% u! v6 y                }: m# u4 P; ]9 s) w
                , @  k5 Q7 y" b
    } // end of class AuthorisedUsers5 ?- Z7 T9 b8 |' G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, `7 z  V% o) ?4 T+ k$ W5 iShanghai - 2007
. ~$ C4 z& a! g3 P$ s) jAssignment 2# R2 K/ M) O( K; n1 L
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)# _2 u3 W2 X" }/ F) \
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.
1 h/ u! p3 y. C9 HThe staff must be able to:. i* |. D2 u, `8 C2 S( m  U( v
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# }9 ^2 j& V& N; i/ w1. 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./ [' t6 `$ ?- L
 The interface should provide a menu so that the staff can:
0 u) P" H/ P! o; y! Wa) Enter the names of the two Java program files to be compared. a& R) L% S% `
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ L* i* x4 m/ t" `5 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).
* c0 r& m, q: x# S7 {. oBSA104 Business Programming – 2007: Assignment 2
+ k8 ~/ j- Y! f( D' ePage 2 of 5
& p) F" l$ w8 ]& P* H! |2 Pb) Print out to the screen all the lines of code that are the same
$ E, \7 Z% `; G. P$ W Include the name of the file and the line number of the code being printed for each of the two files, r  i+ Q0 ?* q" u1 I5 s; [' S
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; P1 T! G7 K, v the name, username and department of the user& e8 I; Y: m  ?, P0 Z, i+ v2 k" P
 the statistics of the comparison6 m  O# ]! V, i4 y6 u2 J1 u
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
. K: ?5 ^; H6 i& w: B- z$ ~ the recommendation for further checking
5 T! A1 v* v  j$ d7 N* U, 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
, s4 L6 W' e% l+ Y the names of the two files compared
7 e, V" o0 R$ Dd) Leave the program (exit)& }* q2 N/ D/ f' X0 Q1 Y
The ProgramCompare class: (Total maximum 20 marks available)
# S. ^8 n( [" _$ e# K0 c. z) I2. 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), z6 O/ }3 r" s" l$ I
a) provide an error message if the files are not found or there is a problem opening them" d. l* |: ~. F* d' T7 v
b) compare each line of code
) _1 X5 d7 n+ Y) S7 m' Lc) print out the lines that are the same
6 m- m& k4 S, H3 s: o- ^d) count the number of lines compared / lines the same
( l" T( q7 @! D$ C4 h5 @The AuthorisedUsers class: (Total maximum 20 marks available), J1 |( d& e7 c8 D3 y8 g- F& b. |
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)5 I" b/ u) q+ P6 F3 l9 O
4. Provide methods to:
6 |( ?8 Z5 J' l' u' i$ w4 oa) 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; o/ X9 w; H) x) \! P9 D' N
b) return the name of the authorised user) C) [. [* t* s* R& m6 t7 A! ^! p
c) return the name of the department of the authorised user
3 u( c1 q& }$ a7 c" JIndividual Data (Maximum 20 marks available)( i* P$ o4 n3 W& t& u2 \
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.
( j- c' e& K7 |3 {1 A) {* |Documentation (Maximum 10 marks available)( V, _+ v# ]/ ]8 @0 s" `4 n2 I2 X
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.6 k' R8 Q' |4 a4 R
BSA104 Business Programming – 2007: Assignment 21 t1 S8 s0 {& `8 w& K
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& X0 @3 e, l; Q& Q8 `4 @9 c" C
不过你要翻JAVA的类库说明。你有下载没有?
3 U$ D. C( n  `! F) ]; ]查询关于对比的函数。貌似关键字是contrast,还有compare
/ e; c0 L: ]" z, \7 R4 B& X; p7 I0 d1 X+ j0 q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ H. y4 J) s6 p2 _9 L$ X2 u痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, w& ]6 \. C, {. k" f0 V9 |可以下载到的 是 jdk-1_X_0-doc5 V, w/ N  G) A6 X
& X/ w6 h( u2 l
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-19 15:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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