找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1218|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 z$ g4 D4 g! h: f, U * y+ |" N/ K2 b+ {6 o2 Z) w/ Z5 S
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************; I/ l. p  J& X5 I5 ^8 g
//  ProgramCompare.java         Provided by: DRS
. }3 r7 [9 ?* j  m, d//! ^$ V' V( _" A
//  Program shell for Assignment 26 `# t; C8 M3 Y, L! O8 i
//
" X9 ]* P4 Z+ q- B; U0 g( G//  Compares two text files line by line
( f& G. e1 {! k. a" Y' s//*********************************************************************
3 U: W0 |/ v; @. \" ?( R) i2 L' p- n0 d, d) X2 o7 y) I
import java.io.*;  _: I' c1 Y$ g
: [! \! t$ [7 Y& `' @0 g
public class ProgramCompare
0 p+ G. E$ q9 z5 X) c% c9 s{
! b% N! l2 w- g4 c# P% p# a        //-----------------------------------------------------------------
. x- O# V, g2 h1 U7 p/ u3 Z+ k        // Constructor% c% K4 o: ^3 o, l7 f/ g
        //------------------------------------------------------------------ I+ I- ?* h% u  a
        public ProgramCompare()
; ^# {5 ?* u+ e* f; J  q: ^        {) g! H8 N+ y0 n
        }5 h9 ?" ]% s2 R: v0 Q( w& _/ L- m

4 H% E" m" H* w% b        //-----------------------------------------------------------------. D# ^& ^- O5 }' C' ]
        // Method for testing that class has been reached" r& y; y$ [( F* k% x+ T
        //-----------------------------------------------------------------       
0 i7 `# r" g' v! C, q0 {" [. g& ^+ F0 V! n( B1 m0 V
        public boolean ProgramCompareReached()        
1 N; t% U5 h% v: x5 t        {
5 `  W' |7 A# S) F      try
- I7 z, g# j) m: A# j9 n. U   {         2 ]- y) k. p" g( W! c6 L
                       
, V3 j. J! w+ C9 C                //********************************************************************/ E& c9 I4 D) X& Q. s" z3 r
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 _  c2 R# E( u8 x$ s0 m' c2 V                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ i8 g  E8 o1 {5 v! |2 i  w! ?
                // For more information see page 534 of the textbook
1 O" `1 @: T9 c$ h  F/ _! N                //********************************************************************- a% |. z9 B: |5 c
                    
0 R- C8 i) {; H# K1 h- m  e        }
' q0 `0 q0 m( W1 D( s             catch (Exception ex) // Exception caught here and message displayed to the screen   ]" s, Z' I" Z
          {
* y$ K; U3 d6 E7 C                    ex.printStackTrace (System.err);
: P7 p+ X6 \& F  P5 ^7 t9 k8 P           System.out.println ("Error message goes here"); // Replace this error message with your own          4 N8 P3 L+ |7 s
        }5 w, q+ U  C+ Q$ `
                return true;
/ _/ B2 J8 ?! ]+ S6 q# f" H' d6 P        }5 M& p3 K* W* ^# d. U7 }% L3 B
4 n0 o2 z6 O7 z( e. N, g' [
} // end of class ProgramCompare
) w9 H! W8 {6 d9 t: I$ n
; C/ o! K2 t$ N* J3 j/ q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. f6 H: ?  _- t3 `, L//  ProgramCompareMenu.java    Provided by: DRS
: a, Y9 x* A, [7 U' f//
* h, u& T. \: ^3 R7 Q//  Calls AuthorisedUsers.java and ProgramCompare.java* G8 D8 @1 d! X! f6 l' @# S
//
0 M, C- F! j% T- Q" @0 a//  Driver shell for Assignment 2./ d, ^- ^+ G3 q- g- E$ N# B% W- r
//********************************************************************) x8 \' w$ N# d7 z+ P3 m8 L
% i% F3 T$ D9 I' B) E. Q. f: B0 w; o
class ProgramCompareMenu) K6 L. R* B; }- C0 r7 m5 \
{  _) o/ T$ D# O) r4 O6 n$ o6 k
    public static void main (String[] args)% d: n3 g+ o1 c2 A+ j& v
            {
8 B# Y0 t( _$ O" O5 A0 @* ~( L                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 K& h) M# ?1 o
                ProgramCompare reached1 = new ProgramCompare();
7 D! i) F4 w: t& b8 ~* X- E$ O: Z: c                AuthorisedUsers reached2 = new AuthorisedUsers();        % m' @$ R5 O) M6 E% C% j. U
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 o8 @9 M7 m3 J6 z! }% F7 P                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
4 d  v! d8 g+ F& x        }
: M1 C1 P/ I. q: x}// end of class ProgramCompareMenu& y# L9 G- t& M3 \) [

+ E6 f/ r8 T1 D/ d& n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 d& ]$ U* O8 j! [% y//          AuthorisedUsers.java          Provided by: DRS4 u) B- j% k" M' W0 x) r- u
//               
  e0 N0 L7 ^& L& I) [9 b: n9 b  @//         Program shell for Assignment 2
. L6 |) ]& p4 Y/ Z3 O//
: {& Z+ P- @+ E  k$ m; G//         Represents facts about an AuthorisedUser( f: \' {. O9 z* a2 F
//********************************************************************
- d# }$ D8 r+ i  G% ]( L4 g0 |$ p8 E! Z1 u9 f+ a
public class AuthorisedUsers
( y4 j( n! r5 B5 A. J  u    {
- }6 W" C! q& _- e9 \  p
1 I+ y; q  x) L) R0 y8 y        //-----------------------------------------------------------------+ w- t% e3 B1 Y! `/ C3 q" L
        // Constructor; t' X( O% x- X  a0 v4 n
        //-----------------------------------------------------------------
% F& x& ]1 ]; c: E" I4 ?+ T: _+ y/ H! S: H. r! u* R
        public AuthorisedUsers()
, p9 v2 f% P/ D! H$ L9 H0 X" c# E                {4 p4 Z$ M+ e/ K* ~8 j/ R% d
                }
' c0 D" ^& R+ F, c! [; T- N% H& M+ F  S9 n) u4 m; Y, d
        //-----------------------------------------------------------------6 u* Z  t* I  H+ Y& r8 u
        // Method for testing that class has been reached
& ]* P- l/ @2 s" g8 \        //-----------------------------------------------------------------        3 e& k6 m" E0 v# {7 T5 m
        public boolean AuthorisedUsersReached()7 j6 Z# S: s* |& N+ d
                {
) m- s! h) B' s                        return true;                        + g8 z! B, B/ V: Y) f
                }
( B. p9 L7 ^- C                ; B5 f- M; R- ^% c: o% N. }% P
    } // end of class AuthorisedUsers; a* u1 V! V" b+ Y. A8 G3 R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
7 q  U/ N8 ~  n" n; qShanghai - 2007
" y. S# i& L( V4 e0 s4 S* ]Assignment 2
* d7 \: j! c" ~/ E: d# tDeadline 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)
/ d: L& D/ \! m- ]" s1. 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 G' H. O% f( ?5 R# i0 y0 u) UThe staff must be able to:0 Q* {. x) W" N
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  _# S3 p+ z' H9 \
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.4 t# ?; m  M5 a4 Z# B6 i& z/ g
 The interface should provide a menu so that the staff can:
, w4 Z1 L: j& p! V8 Ma) Enter the names of the two Java program files to be compared% |6 O6 R. n# n
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' i" S2 b3 N9 G1 {. ?
** 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).
, v1 Z  ]0 n" t# P, p- i7 f# C1 [" lBSA104 Business Programming – 2007: Assignment 2, ~% @% w/ t. Z8 ]+ r% o" C$ [
Page 2 of 5
( e8 {: d4 i1 y& c% J% s% ^, ?b) Print out to the screen all the lines of code that are the same
2 q9 X1 k# K4 \1 ` Include the name of the file and the line number of the code being printed for each of the two files
8 F; u8 |: R9 m$ D8 r% w  x! fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; t) M7 ^3 W  z9 k3 ?8 o the name, username and department of the user, n( p$ d* e+ B
 the statistics of the comparison+ M0 h1 M* |/ P2 T
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" i$ Y# z' ~. p* d the recommendation for further checking
2 v/ M8 _+ s. G! w- B5 G* M( N' ?, v- 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: d6 n: W  {3 _; o0 O
 the names of the two files compared
) D% f# R9 D  ]d) Leave the program (exit). k* b6 ^& i9 ?2 b. W/ U+ b
The ProgramCompare class: (Total maximum 20 marks available)
/ {! \; \0 |+ y5 ]/ j& X2. 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& a2 K' Z3 F3 q% F
a) provide an error message if the files are not found or there is a problem opening them8 b3 e# S7 e  t' ^( i$ `$ F
b) compare each line of code2 j: i8 |, x% O
c) print out the lines that are the same
& m0 Z+ k  |9 E9 L/ q) J. f: pd) count the number of lines compared / lines the same5 i/ D# \' c3 a$ |, r
The AuthorisedUsers class: (Total maximum 20 marks available)
& _1 _+ @% g1 E  Q( _" \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)) b6 e9 V, I6 R
4. Provide methods to:# C+ j9 c" R" a* f2 y
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% H1 K4 B- h4 `9 A8 e9 |; G
b) return the name of the authorised user
0 y8 G. T* i6 h6 _) W" K. d2 |c) return the name of the department of the authorised user" [8 u" L- B5 P. _7 S& l5 R& P
Individual Data (Maximum 20 marks available)
: Q+ x2 ~: c0 r2 W- |4 a4 [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.9 r/ u3 n7 [3 i, e% X1 J; E* a5 q
Documentation (Maximum 10 marks available)
% Y+ O+ q. ~7 _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.
# n& E3 t$ ]8 e, p7 `, SBSA104 Business Programming – 2007: Assignment 2, M( Q9 X# y* W* K* @# q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了1 \7 |% j/ U1 H
不过你要翻JAVA的类库说明。你有下载没有?
5 h# {# T$ X/ x& t: }5 f查询关于对比的函数。貌似关键字是contrast,还有compare, v5 B* I0 f9 e( _+ f
/ i" ?# p# Z  g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( X5 v5 T! z+ B/ L8 \) w+ U6 g; F4 ]痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 l8 M' x: o6 P) a: Z* \  M' C可以下载到的 是 jdk-1_X_0-doc2 ~  s! e( x. O2 [, w9 S
2 \6 A% a2 a* j
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-20 13:02

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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