找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1170|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急! L! n% f; v+ h/ F1 @ 8 f p7 T5 h2 O k: Q' m
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% r4 g5 l, B0 l9 S' N, C9 S' _//  ProgramCompare.java         Provided by: DRS% L& L% V2 K/ M4 J3 T8 B  \- h4 d
//0 g: C% ?$ f9 M
//  Program shell for Assignment 25 [7 c! B3 c/ [- z0 `" k: |  C
//
( s( D& w' v7 c) x6 |( q//  Compares two text files line by line7 G7 X' K- \6 L( p- d
//*********************************************************************1 c1 q1 {( q: h3 X
$ {* ~% Q0 j* r  i7 \# J
import java.io.*;. T2 e2 G- z# S
# Z& x5 K! D3 R9 n. p
public class ProgramCompare  j+ W$ l8 y+ W4 W: T  J' m% I3 ?
{
; I: ^: [4 e" x, }        //-----------------------------------------------------------------( Q, ~! O1 ?1 A! v8 d2 F
        // Constructor( x6 a4 ^0 \+ Q7 @7 L! i/ r
        //-----------------------------------------------------------------
1 x, g( ~$ E) R5 W3 |' {        public ProgramCompare()
5 [# q8 J4 N: Q, }        {+ B2 K. l7 x: s. \# y
        }* K2 F# B2 L. J$ v6 N

1 c3 h( e: A) S+ J' ~        //-----------------------------------------------------------------# G! D" `* w8 g" }8 u) [; @* h3 U
        // Method for testing that class has been reached
7 A& L+ ^- t2 D/ U, [        //-----------------------------------------------------------------       
/ E$ k, N2 N/ b! f- ~4 x! I0 N" t2 C3 E$ C( J
        public boolean ProgramCompareReached()         : U  k, f) F; _& K+ \9 [; R) D
        {4 a* Y. ], V" b+ a( G0 |# [
      try
) w# V, Z, Q# D4 M  \8 m' [5 R! i   {        
3 X$ a+ e1 ^' r* c! w+ O  P                       
7 Y' p: g0 e  z/ r                //********************************************************************
' e" L- v( m) N                // Try-Catch Statement is used to handle exceptions - such as file not found ' x1 V2 _0 A; ^% U. C$ o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ b9 Z! n" W0 i1 j, g8 ]                // For more information see page 534 of the textbook! a, Q* g  u$ r5 r  w
                //********************************************************************
, k! ^2 M" p6 R/ C% i; K  m                     ! v% Y( @  @. e; S% x0 a# d! b
        }/ R% P) n7 e7 h+ u6 C$ g, v
             catch (Exception ex) // Exception caught here and message displayed to the screen & R) ^" g9 K$ [* C; k7 M. P5 w
          {
6 D. }4 K8 j, b$ E$ L. B                    ex.printStackTrace (System.err);) K3 |& `; W" K0 h- _
           System.out.println ("Error message goes here"); // Replace this error message with your own          2 v! z6 N9 x5 D2 r/ {
        }$ }% ^) F- M8 H2 V! Q6 d( W
                return true;$ _! k" m- I" D% j  y. X0 |
        }1 Y# M: d4 F7 I" C5 g. \# s; R, E" t

& j' N# Q( B% W) r} // end of class ProgramCompare
# ^; ^0 H1 U" o6 W: w
& T7 _3 Q# l7 J/ g8 ]. q8 q6 m! M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( \  B7 j9 |, l" u//  ProgramCompareMenu.java    Provided by: DRS# g: W- \7 f' ~
//. d" a7 V, C0 @  ]0 P) h* Y4 u! N
//  Calls AuthorisedUsers.java and ProgramCompare.java
( V5 L* Q/ ?$ c# u% @* {//* E1 Q* P9 C' a$ _& m  n
//  Driver shell for Assignment 2.
+ w7 @: ]+ l1 y& n//********************************************************************8 V. \: O- G# K
; m# W, W6 l6 S$ x
class ProgramCompareMenu
5 o$ ]' Z3 I6 r- W{8 a7 b) x$ b9 J* T
    public static void main (String[] args)# Y1 i4 u, m9 w$ t! n
            {6 D) D5 O/ F" l
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 o( ?4 B- F. d
                ProgramCompare reached1 = new ProgramCompare();
1 R3 J7 T3 g* p% ~                AuthorisedUsers reached2 = new AuthorisedUsers();       
, B& ~: [! @- L) U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# F  O  p- L. t! G$ M' q
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 Y* }8 g. [8 R7 \8 ^% }! C% N
        }
  u: }) f1 @9 `; r7 N4 l) Q4 C' s. l}// end of class ProgramCompareMenu* A+ l' R' h2 P& ~

/ ~% ?% L2 r/ R# c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  h$ s7 F: Z. y# N, }. N1 m
//          AuthorisedUsers.java          Provided by: DRS
& D4 A) B, c+ o# b1 t0 D//               
4 ]3 Q# \, q# a! L  u6 \4 j5 _//         Program shell for Assignment 2# I: s: R- w# ^9 p7 C
//
) ?3 v  X, M- }2 s2 ]7 S//         Represents facts about an AuthorisedUser0 B9 \6 v1 p  n0 d
//********************************************************************: ]5 e6 v6 F( B

5 E( H2 U; B+ a6 D- f3 xpublic class AuthorisedUsers/ \) ~, Z; o* R: |% k" D4 `9 u
    {/ z/ T( Y& b  x8 ~
. ^0 r! [0 t9 `% U7 Y! n
        //-----------------------------------------------------------------, e/ g: O1 n, a9 }
        // Constructor6 V8 X- Z; R2 l  T7 ]6 p" h
        //-----------------------------------------------------------------
6 z: _3 ]" r# t. {8 r% |) A# ^/ q% s4 l7 S! ?
        public AuthorisedUsers()
/ i5 F- b: }0 ?1 S2 _                {
% E. Q3 B9 D! f4 }- u                }# }' O$ n7 U; x  N; b) P1 ~9 [. G

6 Y( j$ l' u8 @% n$ y* N6 q        //-----------------------------------------------------------------
7 ~* N  _. S  \( W% p; ?: M        // Method for testing that class has been reached
, b. j. [5 M; P$ m( s; b        //-----------------------------------------------------------------        ' {" a: v2 K) Y0 m3 x5 N
        public boolean AuthorisedUsersReached()
3 @1 _, O! Z; \" @( {; o8 w                {$ i/ p8 k' [" y$ f
                        return true;                        ! [! j/ X( s( V5 g) q
                }% U+ Z4 N+ O' K2 D
               
- u2 s6 L1 y9 n+ |6 P! P    } // end of class AuthorisedUsers
6 V& j: J9 v7 N9 T6 f' z* i4 J. }8 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 |: b$ d. {# u* z8 O' ^) s$ A* xShanghai - 20078 ]1 o" z1 y0 H2 N+ W, i, z$ [4 v2 H( r
Assignment 2* F1 J3 `! R3 n3 k9 N3 j: @5 o5 @  b
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)' W3 i+ |  ~, `! s
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.
6 @& H3 @! b# X% l2 U0 g- _The staff must be able to:
8 J8 P# k2 N& \+ n8 v Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
5 {: Z: A3 a7 h, ?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.
1 [: H2 X* I4 h- W The interface should provide a menu so that the staff can:
& t3 Q" C( W( c; Sa) Enter the names of the two Java program files to be compared
5 M5 N9 h* p( {2 V/ _ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( O' D; w( d+ \. q" c( o: D** 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).
' s! D" c/ u  m0 t+ O8 VBSA104 Business Programming – 2007: Assignment 2# I, \0 p! O0 G* j+ Z) w3 s
Page 2 of 56 b) T) N9 @! a7 W5 K
b) Print out to the screen all the lines of code that are the same
* I* Q% q( n! n0 A# ^9 b Include the name of the file and the line number of the code being printed for each of the two files) ?. \- T( H! |, L* h( ^
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared: _. A- z7 y6 ]  n5 ]% Z
 the name, username and department of the user" \$ ]/ z0 @$ m
 the statistics of the comparison
& T& T" B5 k( T- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
# t$ }1 Q7 r9 e the recommendation for further checking# \: W$ f0 ^/ U* [9 a2 Z% c* |
- 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
8 p  k1 `# w4 |2 W$ Z; G* `; t the names of the two files compared+ Q% T1 a7 O/ k
d) Leave the program (exit)
; i7 w" Y3 S7 N7 [The ProgramCompare class: (Total maximum 20 marks available)+ y# W! _$ N6 b3 Y- F
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)8 x( i8 I( g5 I. A
a) provide an error message if the files are not found or there is a problem opening them  z" Y8 R9 b! r7 h* t8 e
b) compare each line of code
: |9 c* L! A5 A& N( F# L( xc) print out the lines that are the same
: |: a6 T- A! T/ t9 X1 Q0 id) count the number of lines compared / lines the same
& i- l! _6 `. _/ |, \1 |" BThe AuthorisedUsers class: (Total maximum 20 marks available)
4 |6 A, o% C$ s( Q% K1 c; l7 J3. 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)- C" b; @; U/ j6 N" n" a7 t) h- Q
4. Provide methods to:
, s  E# ]+ i/ I4 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
  C2 M* o( S# ~% {; C$ J. X- Cb) return the name of the authorised user6 ^# P, o. e  Q" J3 n6 Y
c) return the name of the department of the authorised user; q- W$ Q! \% ?. t  h9 V3 O
Individual Data (Maximum 20 marks available)
) P6 p( [/ D4 ?+ \/ I0 A' r+ Q* D5. 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.
; G. K" ^; |0 BDocumentation (Maximum 10 marks available)9 v: B- p7 E. Q! w) `
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.$ v% J, X9 _  h) c- h4 q
BSA104 Business Programming – 2007: Assignment 2
1 Z' L3 i* O- o: x2 i; E7 y5 FPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 h6 M6 i' ^* ~% E不过你要翻JAVA的类库说明。你有下载没有?
: [- j6 b* H) ]) c查询关于对比的函数。貌似关键字是contrast,还有compare
" p5 W  u6 X2 E, w6 F; n1 s  h7 w  Y0 F7 L/ |5 q+ p" }( q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 A6 I( \: G# ?; q/ Z6 C5 [痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
9 i4 l2 a, c3 z. F6 Q# ?可以下载到的 是 jdk-1_X_0-doc3 A8 J7 |* B  L

: ?' a+ s2 Q2 }2 \5 P; A) }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-8 21:08

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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