找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1081|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " Z: n* J* g0 k5 e6 F/ J A: q! [8 W* O4 W! @% u$ @/ A7 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 | 显示全部楼层
//********************************************************************** ]0 G9 j5 I7 {) U" C
//  ProgramCompare.java         Provided by: DRS
2 }. b- o4 p% z//( s  z6 ?+ [! d* W. C
//  Program shell for Assignment 2
3 [" s! z+ A  G. h8 b. _9 d# q//
' Z5 k0 P( e* e; P$ |$ `. q7 y$ F) K//  Compares two text files line by line
, }! g/ h! K, U//*********************************************************************
5 Q( ~% P# \% y/ {* f7 h
6 x5 Z$ [$ h3 y% f$ |5 j5 i6 Q0 ]import java.io.*;: ]  }% n7 X; {) z
" f5 ~. J6 }1 b; s9 E/ V+ H7 x
public class ProgramCompare7 @, ~% z) T% u1 \# v( \' v
{' @1 v& c( b& q- ?( \& _, Y) x
        //-----------------------------------------------------------------9 J$ l, R* n: L' [9 F
        // Constructor
5 R" e( V# U( B, l( W        //-----------------------------------------------------------------3 ]- y& @) b: n
        public ProgramCompare()
% X9 X# {" d/ _  s        {
4 M. H, Z2 L1 y$ A8 `- _2 k, \8 _: d. T        }6 G  r' U0 C$ N9 Q: v) n) e
! T8 e& t9 j8 q, @! J8 T
        //-----------------------------------------------------------------  p+ J6 F  s2 I) Q9 B: f% g, c: J
        // Method for testing that class has been reached- q" G: d: W; H& Z9 J8 f: R
        //-----------------------------------------------------------------        2 |# ]  B. i8 [( b' U6 `: l; C9 M6 m

2 V/ t  t) y; s        public boolean ProgramCompareReached()        
- X3 e' X9 `& X2 c- n( j( R  E! @        {0 S, B5 @) a% v4 c( Z- Y$ }+ y7 B
      try # J1 c9 G0 F0 n
   {         4 X. {5 U7 r. x1 k- b7 a/ d
                        % l5 F: i0 p* `: f
                //********************************************************************1 f. Z4 I3 M( J6 \) \2 |
                // Try-Catch Statement is used to handle exceptions - such as file not found $ e$ c% t. H. y, ~  Z; B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. w/ F( u* y5 k4 z" d                // For more information see page 534 of the textbook  i; |. @. e, j7 e/ v
                //********************************************************************
' _+ D2 k& n* p. Y5 r                    
! g* n# L( h. u        }
: k# J3 U6 e( E! y; z             catch (Exception ex) // Exception caught here and message displayed to the screen
7 n  y+ i$ }* v  Y          {
2 v6 X# M( ?7 i* m+ x+ |0 Z                    ex.printStackTrace (System.err);& z' Y! H: O2 Z4 M
           System.out.println ("Error message goes here"); // Replace this error message with your own          & p  ~# |' ?  A
        }! g( w1 M5 k* _7 x0 n7 Z
                return true;% c7 M9 Z2 i& U# v, i2 v, G9 W6 t
        }, ^; F/ F7 m3 @4 K% F3 X

9 C+ F/ F# |* w8 h6 J  h} // end of class ProgramCompare
8 W0 {1 l; Y: i# a* i6 o2 j; r, W) s' {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************: x  r# \3 p/ V$ X% O# f: |, C- t
//  ProgramCompareMenu.java    Provided by: DRS2 k- Z1 Y3 c3 U8 X' b
//
  s7 l2 |4 c3 m//  Calls AuthorisedUsers.java and ProgramCompare.java
2 }! V$ O. F1 h0 q) F' f8 Q//, D2 N7 J+ Q' `
//  Driver shell for Assignment 2.. H+ j" \' b) L7 T
//********************************************************************
) B7 g1 P+ `! T' V0 y. P
7 H" k7 \1 `+ E  }3 r( D/ \class ProgramCompareMenu
0 }4 e. u9 a) S- S7 {7 Y. E{
2 a; c7 L6 I3 ?! R7 w+ h9 K8 h    public static void main (String[] args)
/ _+ _$ A+ ]4 |+ s$ V            {/ y" r* C' T5 Y. h, q
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* ]. `+ K  ~  ?+ Z- ^, g+ X                ProgramCompare reached1 = new ProgramCompare();
; M' [- r: i# b3 b' L                AuthorisedUsers reached2 = new AuthorisedUsers();       
" f, V$ r% \3 c7 Y9 j                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
( @8 s7 l! {+ R9 A/ r; c) F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( }  O- c8 s% u$ n+ U' G. x        }
, E3 l  O8 _$ U" a1 ^! h}// end of class ProgramCompareMenu
8 T0 F* l5 q2 {$ q& Y; \0 A/ f3 d0 L  ]! |
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- F* B- U+ R$ H( h$ _//          AuthorisedUsers.java          Provided by: DRS
& Z  l9 |$ @5 n3 C9 ~  g* b//               
- C0 z/ T, s! A" z: I% d//         Program shell for Assignment 2
0 K# s- u8 D2 W9 ?: Y- q5 s8 r" S//
% j- P/ O$ v) U0 I/ `  l//         Represents facts about an AuthorisedUser
( t6 g4 X, b0 L; T, Q. F8 M# V' A//********************************************************************
. t0 o" Y! H# @# M0 z: d+ a' I0 d! c2 ]/ Y) F  e: e  v, u0 s
public class AuthorisedUsers; j9 u' l; Y! s& @# ~$ a
    {
# K- [7 F7 L: v( e; `: l# T
9 e5 \/ J) J3 Q. f0 ~        //-----------------------------------------------------------------/ h) f* R0 X. n% P+ q
        // Constructor" J$ l. R# Q& Y$ X1 x- I, T6 l
        //------------------------------------------------------------------ G/ F. A1 i( m% |6 l

6 t/ m* J. l3 l" L: G+ m% @+ X        public AuthorisedUsers()
  j8 p4 w6 {$ l                {( S. o  N  n" G6 Q1 U6 W
                }6 `! a/ _: t/ Z% `/ j

( Y/ E% R' D" H" E        //-----------------------------------------------------------------
* G% K5 V" x# A# g        // Method for testing that class has been reached
; w+ v  l, L1 o& H4 b  m        //-----------------------------------------------------------------       
/ v+ T  h6 h5 G( s) ~        public boolean AuthorisedUsersReached()( S5 R4 Q5 F: k, d! \- I
                {
1 u1 U* y2 d* }* H1 t                        return true;                        . T" e8 }  \# T; n7 ^% W/ O
                }
: Y" E+ o% E8 [1 w               
& i7 T( R3 s7 }4 M6 D+ W2 b    } // end of class AuthorisedUsers( ~$ z3 i& t) E- G- m; p
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: ?/ v* B7 N: P$ S  x. aShanghai - 2007
. E: ?7 H& ^: I9 }- r$ X8 rAssignment 2
( R, l! I) g4 A% o5 mDeadline 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)$ Z; x) U3 I+ ^! F9 u
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./ K2 b& w; c$ n& s0 C0 S
The staff must be able to:/ A6 i/ e: s* H/ G& f
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
5 J* a9 g. n0 a+ A' k1. 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.6 B, m9 _1 n! ~+ M- i
 The interface should provide a menu so that the staff can:: Z" K4 [3 a9 l+ u3 Q, L( {
a) Enter the names of the two Java program files to be compared, f0 l5 C3 c) c6 A
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 }: x  b2 p* I6 R* G6 N& v! Z
** 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).8 w% v5 L- K! n8 C
BSA104 Business Programming – 2007: Assignment 2! B1 ]- F6 o; d* S, [0 P
Page 2 of 5
7 n$ k& x7 X: [+ Z" Y* A/ O: Nb) Print out to the screen all the lines of code that are the same
8 `# S" y! I5 [4 k Include the name of the file and the line number of the code being printed for each of the two files
, C3 E% J  |! x; M- G1 Rc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) s: h3 L  W, |- Z! K0 X9 z1 ]. x; S
 the name, username and department of the user2 i8 m5 @9 V! M8 T- l! k$ W
 the statistics of the comparison
6 G6 h6 g" t2 q6 R  K2 K- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 L" S% A# c- Q6 g- j+ e; C7 z! g9 C
 the recommendation for further checking
6 o% c& P: v1 |+ ~8 n- ]- 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 closely3 u% K+ k/ C3 n6 {/ Y$ K' j& B
 the names of the two files compared
+ Y' ^# \) V: _% _2 Z3 J, t- n' Kd) Leave the program (exit)
8 W8 Q/ C3 \: A" t; c: X$ X7 m' W2 r+ SThe ProgramCompare class: (Total maximum 20 marks available)
- z6 q$ _  G4 `9 |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)+ }; c( `* u: @' @5 J" D
a) provide an error message if the files are not found or there is a problem opening them
1 ?1 J+ I" {; d* F7 gb) compare each line of code7 S  Q5 c* A5 j/ b/ I4 V6 @# F! Q- {
c) print out the lines that are the same5 x! z3 e% U" \1 N$ S
d) count the number of lines compared / lines the same
  l$ C; A7 ]: I4 d8 G9 HThe AuthorisedUsers class: (Total maximum 20 marks available)
3 j/ C2 `  ~9 w6 J/ x0 z& q% V" L  O3. 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)
! K& m! ]5 G6 |/ @4 D/ T1 Q7 a3 r4. Provide methods to:; B: w) I2 O4 K) g% j# J
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
0 H9 p) x2 b: X  j. c0 ob) return the name of the authorised user, I7 h: F# c4 H  I6 l1 Q- q
c) return the name of the department of the authorised user
# p2 N' c* W/ F5 b' cIndividual Data (Maximum 20 marks available)" l6 z* Q2 G0 k
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.+ ?/ N2 L4 G; x' |3 F$ q
Documentation (Maximum 10 marks available)
* h+ o7 o9 r' c# j+ l0 g6. 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.% q7 I. }6 F/ r& n! F
BSA104 Business Programming – 2007: Assignment 2
! C3 v: U9 I, \( h: S; e; KPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 N- L* A- b' E6 Q+ P. k不过你要翻JAVA的类库说明。你有下载没有?  @/ M* D8 g( \" B
查询关于对比的函数。貌似关键字是contrast,还有compare
/ `' }5 ~7 i3 {  X
9 a% a/ o/ E) w4 R1 d7 |% \- J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ v% Y( G9 t1 P/ J
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
! L' h, A3 ^. g0 p6 I) R9 O可以下载到的 是 jdk-1_X_0-doc
2 v+ ~8 H3 A2 k! `! \* c/ ?
7 ~- l6 e5 k. |  C2 {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-1 04:52

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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