找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1686|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 % W7 I" N8 k& P/ N# G% m# F8 u9 ^5 ?( v3 C+ f6 P' `; H
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
: H  Q2 _0 V9 C0 B; H- ?3 ~' a! z//  ProgramCompare.java         Provided by: DRS
7 Y3 a2 R0 d; v! Z, _* k//
0 q; j4 p. c  j, N; S: N//  Program shell for Assignment 2
2 U4 _2 N" d( n- ~# c; J//" N# c% B& s: Z+ ?$ c9 Y
//  Compares two text files line by line3 j" p+ X6 \. i  q3 @! t3 p
//*********************************************************************3 Q. X4 `: o# b* n

7 [- N* z% J; t) m# Bimport java.io.*;
2 w& L$ n& O- Y9 K
+ Z8 d! I: z" }) i( k7 U8 bpublic class ProgramCompare
: _3 _( u3 B1 W7 C9 g3 D3 Z$ g4 N$ _1 L{
: c1 ~! r; W' D1 Q8 d        //-----------------------------------------------------------------5 i* S" G0 p5 c$ X: r
        // Constructor
" i  [- _: j( k        //-----------------------------------------------------------------8 L2 z  Y/ R. {8 H
        public ProgramCompare()
. l  Q( c2 F. [7 J# z7 L8 }/ u        {
' C* q% Q; S. n6 W% U! m        }
: D, F% r% h: h2 C1 |* R. b9 q! Z9 _) a8 U
        //-----------------------------------------------------------------; b2 w( D' d& _9 z
        // Method for testing that class has been reached
! Z/ y' x4 x- ?* o! g5 j        //-----------------------------------------------------------------        3 a" o" X% a% V: U; o9 q
6 U* l* I& m' ]8 }6 F
        public boolean ProgramCompareReached()        
8 m1 j0 Z7 m2 b  ~' ?  ?        {% J5 U* c) c- O) z0 \# I5 h
      try ! D' M+ V" n5 g5 ?2 G
   {        
7 s* F( ~  T9 Y/ ]                       
) O7 k! W$ a' H2 B& J5 w                //********************************************************************
/ G6 ]9 Q2 P6 G) P# Q* F6 V                // Try-Catch Statement is used to handle exceptions - such as file not found
3 B! o/ s+ a( K# u" [                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- B6 F: N! C& E                // For more information see page 534 of the textbook
, X5 B! g/ O" B4 ?3 a; Z                //********************************************************************7 r+ ~, u2 b, q: Y. M) R* l
                    
( k  G1 \1 f" t, M1 b; p. J        }) }, M/ F: G  V' N* d
             catch (Exception ex) // Exception caught here and message displayed to the screen
% J4 h! n, q1 V/ R          {' G3 |; @2 _  x' D
                    ex.printStackTrace (System.err);8 G) [* Q! Y9 Y9 e/ U
           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 t3 _& D7 ^( {! v" V        }
4 J; S8 h- j' E  ]/ d% f- `                return true;
* @/ ~" k$ U1 s        }
- [) Z) q7 O& ?5 J/ Y( l1 n- d: b. {; B7 |+ q2 G8 A
} // end of class ProgramCompare
& r4 e! C2 X2 a5 c, u" n* F8 }1 X. M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 l. D7 s. Z4 A, e
//  ProgramCompareMenu.java    Provided by: DRS) H# l! q( l2 [* \7 m0 U& }
//
( J4 [* p9 B4 b//  Calls AuthorisedUsers.java and ProgramCompare.java
) w+ v! a5 \  {, I. G/ i//
3 N+ n% r$ m0 Z$ v+ b//  Driver shell for Assignment 2.) `! B$ r% ?8 ~
//********************************************************************3 u8 f9 A- m3 D& E$ N, |
+ }9 S: Y+ i. }
class ProgramCompareMenu
8 E5 [7 b& A! i0 G0 l$ K3 M{
" Z) A4 {! A% O( U& |7 q    public static void main (String[] args)
0 j/ k4 a& E( s- f  o& l. Z4 d            {! P5 w+ `, t  i/ V
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 l# F- Q8 b' I  M
                ProgramCompare reached1 = new ProgramCompare();
. }' V4 B  ?) Z                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 G& `6 S- P* J& C5 [& g+ l                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());/ T! ?( j  f' R9 ]! c
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ! F/ W  n9 v+ o/ `3 T$ {7 V( f# r
        }
" A8 r6 }! B# t& N6 R  U}// end of class ProgramCompareMenu
6 M* K% U7 q; i, ~8 m4 y& s4 w9 I, }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
& Z5 g" I3 G; r//          AuthorisedUsers.java          Provided by: DRS" e7 j8 S4 Z# E8 F+ G" M/ K
//               
' K8 b- _, d6 s2 z" i//         Program shell for Assignment 2
6 V9 V! l2 p2 n0 i- [0 z//+ c: C1 x- z% O! t5 d
//         Represents facts about an AuthorisedUser
% Z. a" Z* N& N7 H' K( c//********************************************************************
2 k& D1 E( B4 g
! K; I/ Q/ m6 {1 s! K! a* r1 W; spublic class AuthorisedUsers
: E7 |6 [* }3 A+ \  y; @    {
' d2 x8 @  C2 y2 {; v4 n0 K0 A: n# v' \. X  ]  Y' C$ {$ J; R6 {
        //-----------------------------------------------------------------
' R7 k  i5 f; C  @: P+ Y# v5 t& r% A5 p        // Constructor. Y) V' Y7 p, O7 n; V! W( P# S
        //-----------------------------------------------------------------" H9 `5 a; G0 a% A/ s4 [. v
7 D2 u/ j0 C6 V' a5 N' ~
        public AuthorisedUsers()
, o* c# X& A/ H! ?5 F! J; ]- s                {" q/ [/ |% U1 \5 n
                }
$ ^2 B' K$ g3 n+ Q2 L6 o6 V* j1 d* O0 R7 a7 G1 z: l4 q
        //-----------------------------------------------------------------1 h# s6 |% [, |, Y8 Z
        // Method for testing that class has been reached
! _: R3 [; q0 Z8 E        //-----------------------------------------------------------------       
" S1 y: c; c) x1 T        public boolean AuthorisedUsersReached()
9 d3 L' [, \4 s- |4 [" H: T                {
9 p8 V  J5 K( M% M3 C, T0 F0 G+ |                        return true;                       
) a& u% x* U8 L& P% T) `/ o( s                }
4 N. u* A. x& d" q               
2 I* R8 ~. o4 j7 y  r- ], x; |    } // end of class AuthorisedUsers
. c. G2 E  y0 K. v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: p7 G: z8 o8 j  |Shanghai - 2007; L- [1 H- |6 U# [
Assignment 2, e3 S7 l! Z3 C
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)( K: J) y0 ~' z) M& e3 D
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.- ^$ U: A9 i! W) I. ~
The staff must be able to:
; i( B: Y: h' {: J( O1 J Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 W; U  ]/ o5 I5 b
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.
/ x- N4 J% w9 T4 X  E( J The interface should provide a menu so that the staff can:
2 T# F" _3 w/ x( r( w% Ma) Enter the names of the two Java program files to be compared) K& c4 h* V: k6 H
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 p6 I6 _) W1 G** 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).
# Q  i) o- f, F6 sBSA104 Business Programming – 2007: Assignment 2$ s% j  l3 ~, I
Page 2 of 5
! b3 v  c. i. Gb) Print out to the screen all the lines of code that are the same
7 W7 c1 m1 r8 @2 w7 ^" k- @. p Include the name of the file and the line number of the code being printed for each of the two files- j9 ~5 v- t- n
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) p' C) }, J0 j* \# _
 the name, username and department of the user8 d  E  p# J1 Z" ^
 the statistics of the comparison
5 @2 E, y3 N6 X& @' l5 Y- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different$ l7 s7 h1 N7 i* _8 Y/ J" `
 the recommendation for further checking
& s' k! r. e/ l( y6 |6 e: O% B# j. O- 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
" s9 A  D. ]3 C0 Y the names of the two files compared9 J0 q4 Q, O4 a
d) Leave the program (exit)
9 P5 L! _) Z1 I+ z6 _* Z( TThe ProgramCompare class: (Total maximum 20 marks available)
5 e/ P! |) h9 ~8 |, G# {# G) R9 e2. 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)6 Y- R; n1 Y  y7 r
a) provide an error message if the files are not found or there is a problem opening them8 w" h$ `3 i6 C. `$ t, F# u
b) compare each line of code
% N. |/ o% M$ o0 U9 ic) print out the lines that are the same. @! l7 K# Q8 C/ W( r
d) count the number of lines compared / lines the same
' W1 [8 m' S; L; vThe AuthorisedUsers class: (Total maximum 20 marks available)
, [3 f& h$ P. q3. 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), P5 K6 f& Y- D9 G# h
4. Provide methods to:7 x( c; W0 `, y  h% Q
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
8 V8 v5 S1 L4 U0 p4 B, F. Pb) return the name of the authorised user
4 e' e* ?8 z$ c" ^  h1 qc) return the name of the department of the authorised user. a, Z$ P9 V- Y1 G8 i7 t( o+ ]
Individual Data (Maximum 20 marks available)( k0 P8 x; b9 \  b# j) X* |) H
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.
; ~( ?- M( q  H+ a4 N: N# @: t( vDocumentation (Maximum 10 marks available)
' e. Y! F$ g5 E% v6. 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.
) E7 p$ F7 t9 R3 @" l* @8 ]BSA104 Business Programming – 2007: Assignment 2- D& O0 o. f/ t$ t- l
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
7 K& x* o( K: \$ U不过你要翻JAVA的类库说明。你有下载没有?- l* _% ^0 D3 ]! |
查询关于对比的函数。貌似关键字是contrast,还有compare
  c$ G6 M) A& X$ \  t
! n& f# T3 e4 Q2 J* n+ w# U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" [% W/ a# y% R  w2 h5 o, b
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 F- e& _# S# H' t$ O可以下载到的 是 jdk-1_X_0-doc
% N$ H: ]! q, s% n+ O% N& t
$ e/ `4 C7 L: G' r/ Z" t6 S8 }( |) r+ i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-30 19:13

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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