找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1618|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 _# S0 A) Z6 t # G) z. t+ ~! O0 _. ?
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
6 K! ?8 X# D7 P1 K6 K( d( d//  ProgramCompare.java         Provided by: DRS, b5 n" n! F/ Z# e
//
9 c: r) Q# x: m//  Program shell for Assignment 2
* ~& v6 c% W  {9 G7 ]1 Y//
, g" m4 S7 B0 Y9 @  E' [//  Compares two text files line by line. a$ l5 |1 O) g5 e) u' P
//*********************************************************************
/ ]$ f: y# P0 s) d- l( t: z$ y2 g8 A' s1 a" x' G; w6 I
import java.io.*;
# h; _/ T3 ^0 P3 B- z/ y
1 n8 r9 B6 g/ l0 T: G' I, u( Opublic class ProgramCompare
' [. R2 h& L' U7 q{
  {: W+ w' r1 K        //-----------------------------------------------------------------
) I$ F( {; a+ O; [# E. C* h        // Constructor8 J1 D. R, p! d9 E6 c
        //-----------------------------------------------------------------) u% F% {. E7 Z2 c7 {
        public ProgramCompare()
) r1 c9 u- J: Z, N* @5 A        {
  H5 ~( Z+ _8 X# Z, K: T        }8 y1 P" z( b3 I0 q# o7 N9 r3 m

" f, T2 N% b3 B$ d' i        //-----------------------------------------------------------------9 P* B/ W& y$ w5 g& ?
        // Method for testing that class has been reached
" G+ b* b7 D$ Y# t" ~/ ^        //-----------------------------------------------------------------        4 U' e0 ?( m" n

8 r4 k, X1 ?7 q  w8 W$ Z  A        public boolean ProgramCompareReached()        
7 k0 I* N- a) f- u# G  f# }        {! X, O; A1 `3 k+ C  c# k9 p. g
      try
% T: |  k( T! T0 X% M) k' z8 l; s" c   {        
6 K' b2 U7 T! w( G" o                       
; e# g9 P8 q: L$ D3 G                //********************************************************************
6 P, t* j0 |7 t% P9 Q" q                // Try-Catch Statement is used to handle exceptions - such as file not found
1 ?$ n: j; r) {                // Reading the files will need to be placed inside a Try-Catch - just like this one!* |" g, }- |% A( w% n9 N6 @1 \$ k) q0 ~
                // For more information see page 534 of the textbook
. a0 F6 ^1 `& |! U7 |: W                //********************************************************************
6 F$ C2 e/ }6 I7 c9 Q5 H% f                     . L% B: N1 U: Q. I6 x" a8 Z$ Q
        }
% h+ j% a; ], G5 H! K( ~" M             catch (Exception ex) // Exception caught here and message displayed to the screen ' U& B2 k+ t# P" H# v. `& @
          {  r' o: ?7 F: ]' o
                    ex.printStackTrace (System.err);8 Z& \6 O2 K9 H
           System.out.println ("Error message goes here"); // Replace this error message with your own         
* A6 \4 g. ^# L8 {8 s        }
  m: b. J" l7 P& V* D2 [& D( Q                return true;& j0 @7 {3 U3 B# Q
        }
2 y3 l& ?; s5 i+ U) h. Y1 a5 h
" G7 J7 p0 z- ^! Z7 b} // end of class ProgramCompare
, O: L' Q6 z& D9 `! R" X) K$ z4 r5 b9 k$ w0 W4 C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( S: }1 G( W& B$ ?//  ProgramCompareMenu.java    Provided by: DRS5 j# X! a- l3 y3 @! N0 V9 [
//) B7 g+ r0 t$ _
//  Calls AuthorisedUsers.java and ProgramCompare.java
  S1 B% [7 W! h6 G0 w" Q6 f4 [9 A- Q. }0 K//
# h4 f# V" [: [- Z- v' n//  Driver shell for Assignment 2.
- ^  {; ]0 J; X" @1 I//********************************************************************
5 d, L2 w/ s& B2 N* i5 A7 N6 ^- o2 k& R8 K
class ProgramCompareMenu* Q0 o$ T6 Y+ k* Y! [
{
4 R6 Y; Q! y0 U    public static void main (String[] args)
  a' A5 e2 s" z            {
# A( E0 r5 f' `4 j: j                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% O1 `6 `/ M" Y0 }/ B! }                ProgramCompare reached1 = new ProgramCompare(); # [) L: E/ v+ E4 H! T0 k( O
                AuthorisedUsers reached2 = new AuthorisedUsers();        : q$ _6 r# U! y0 ^5 c
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
/ L4 K0 h" f6 I* L# {/ O) ]+ k                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , i* V. R. |9 A5 Q) b/ y- b  |0 @
        }+ i4 Y+ O( I, z4 E2 C' ], m
}// end of class ProgramCompareMenu1 R) r2 C$ l: E$ U" ^
7 `9 I/ V- y- T7 K1 l' g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# D) W) d$ W  I/ W//          AuthorisedUsers.java          Provided by: DRS
1 L* Y& M$ u& o  h//               
7 J$ f* B9 A% Y//         Program shell for Assignment 2
; A" c+ L$ F* h0 Z* Q0 G  b7 I" A//! d2 M) p: T) g% P+ |$ _# a
//         Represents facts about an AuthorisedUser- k( v2 V# r! G  o
//********************************************************************1 I  J0 ?# y) z; t8 `
. G, W* |* c+ F8 F; N" }6 ~7 a
public class AuthorisedUsers0 a: \9 X# J& J! j
    {
- @5 g! j; u3 c4 T1 p. e2 j
2 s7 g1 f: Z* O9 K        //-----------------------------------------------------------------) {% P4 Y8 R* N8 _0 O
        // Constructor3 M, R9 M: e. L
        //-----------------------------------------------------------------$ R7 z6 d4 n4 [: Z

: ]& H$ }' t8 {1 P        public AuthorisedUsers()+ E5 x. |" ]1 u) g- V% a/ _- d
                {  M" i/ ^2 |  B& r3 e0 i# f9 [
                }+ |5 _8 [. Z( [  e
/ f+ o6 q1 c) S9 q- l# K
        //-----------------------------------------------------------------8 l5 w5 H0 D/ I; K
        // Method for testing that class has been reached$ E) ^; v* V# R4 c8 h2 ~5 o
        //-----------------------------------------------------------------        ( g; w3 J: f; Y/ j4 Y/ z4 F# `
        public boolean AuthorisedUsersReached()
3 }  K& x, F4 d4 P! g" h: j                {8 _: J' Z7 W8 [/ q+ Q
                        return true;                       
4 l( M1 x6 Z6 w2 Z. u! I                }; R/ J! F1 f: n& s, c5 [: c
                + ~6 U( D  i! \
    } // end of class AuthorisedUsers
6 F$ T! q- _5 T: U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  z1 Q' \0 S0 t
Shanghai - 2007
- B- k# X. A$ I& M! n2 wAssignment 2  y$ z/ R( Q, v
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)
1 e7 u+ }  h7 c' ~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.+ @0 Z4 E, j" `* _2 \. u
The staff must be able to:* j* R6 w: q+ M$ d0 Q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.) w7 y7 [. E( ]% C
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.% v# |' Q7 v" @7 H4 Q' {& \' e
 The interface should provide a menu so that the staff can:7 u3 Y; B" a7 l  J. I( {
a) Enter the names of the two Java program files to be compared1 E- h8 R  _! i$ k
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' Z* Z9 k( g0 }! ^
** 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).
! |0 d0 i* i" C" |( }6 ], lBSA104 Business Programming – 2007: Assignment 2
0 e7 A2 `$ r3 QPage 2 of 58 D1 U" ?0 g( W( Y& p4 q+ M+ |, R
b) Print out to the screen all the lines of code that are the same9 U* [$ i$ O! c2 Y) i: I
 Include the name of the file and the line number of the code being printed for each of the two files3 n0 J$ U; c/ L$ \" [
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 o/ Z9 |# G! R4 z
 the name, username and department of the user! H. L1 u) M9 [
 the statistics of the comparison
; y) t6 O. _+ e8 ?; }4 g  X0 L- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different& \9 M0 i1 ?/ ~) [& H, _; A
 the recommendation for further checking
8 L: s  ^) P5 E$ U$ z7 [- 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: b% W% G4 ?+ s. Q
 the names of the two files compared4 B' k$ y) s/ E
d) Leave the program (exit)5 s$ ~! A' s1 X: d: H( N: H
The ProgramCompare class: (Total maximum 20 marks available)% Y; ^& ~; X! n. D$ e
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 N8 i: A, U% Y! ~" q! G
a) provide an error message if the files are not found or there is a problem opening them, s  a5 m' ^! l( g) P
b) compare each line of code
1 q  X# ?8 M# B: P7 U8 H9 n. _c) print out the lines that are the same) v8 I3 m- i* r8 b4 n; T
d) count the number of lines compared / lines the same9 Y% E6 U4 F4 `0 ~5 @! b6 m
The AuthorisedUsers class: (Total maximum 20 marks available)7 w/ O+ t- C$ t+ C* Z, L
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)! F2 G5 w' Y% I% H# l
4. Provide methods to:
+ }: M3 a9 E# n$ a) C- da) 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: T+ W+ T- ~! {. M( N2 L0 z
b) return the name of the authorised user
) l; p, P: k. R2 _c) return the name of the department of the authorised user9 d7 q' B! Q9 D. s1 m. \
Individual Data (Maximum 20 marks available)
) x! y$ Q8 N6 ~9 Y, i5. 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.6 Y1 ?( u. T3 W/ L1 l- |4 s) T
Documentation (Maximum 10 marks available)
/ P: Z2 c! l! g( N+ ]/ X6. 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.( u; s; W9 u) K' T4 K$ Y5 f
BSA104 Business Programming – 2007: Assignment 23 j! z. n& b- t1 }0 n' A" a+ s
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 \2 l. ~/ x2 |2 l4 N
不过你要翻JAVA的类库说明。你有下载没有?# _; B/ a& J, A3 x+ F' |
查询关于对比的函数。貌似关键字是contrast,还有compare. {& V% ~3 A5 N% {% ]/ {

$ v0 k, h2 Z9 p! P[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
! p, {( t, O- d$ H, p, z痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  ]+ B& J$ _1 h& C: B可以下载到的 是 jdk-1_X_0-doc7 l$ N. f* R3 e; o5 [
4 t/ K' g' |4 g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-10 09:11

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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