找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1823|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 B. ~9 _( h) e! M5 u/ Z; e4 g4 I& M! L$ n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  g' J: l+ g3 ]9 V) m; Q5 x6 B
//  ProgramCompare.java         Provided by: DRS6 i- Z  m! u, D. Z
//( _$ W8 g- T' r5 s+ s7 o
//  Program shell for Assignment 2" n9 r$ C7 \/ }- j0 g
//
' a4 y! P5 c9 C& n2 h3 c- q8 E  `. \, R//  Compares two text files line by line. v3 H9 q; U2 X/ }& t" s
//*********************************************************************6 W. z4 ]7 N) E! G; D
1 N1 p7 @1 l+ B: Z( j6 k7 c
import java.io.*;
, Z0 V7 d4 W6 W( r* \% C( z/ M7 e7 K6 [8 z( \: P* T1 Q
public class ProgramCompare5 ~% i2 t" |$ l( V9 T" g
{% W2 a9 s4 F* B
        //-----------------------------------------------------------------+ T2 d4 [3 C0 n2 k& m
        // Constructor/ z4 }) l8 x0 m( D4 q; K: F; l) F
        //-----------------------------------------------------------------: `8 R. n$ T4 g# r
        public ProgramCompare()& D' n0 D" u% i
        {
8 r2 W4 \1 F" k, p        }
. a* L8 r# a" e" x; H, e, W6 \$ X2 E+ H& x- n
        //-----------------------------------------------------------------
/ L+ h# ~' T3 E5 E        // Method for testing that class has been reached
) }$ y/ ^; W6 N; A5 g" d& G5 |  E        //-----------------------------------------------------------------       
* F# I  w! ]4 ^9 R8 N# s6 x  H; f- x& \  X
        public boolean ProgramCompareReached()         9 X: P4 O1 ?: |) F
        {! w1 v4 y' o% h4 s8 B) y- D
      try & ]$ c3 C; u2 l8 ~1 |
   {         $ l7 [& W2 o' {6 B6 @* i9 b  f
                        , D, W- l1 S6 V; ]2 F6 e
                //********************************************************************
9 `/ ^+ n6 e; @; m+ j* `                // Try-Catch Statement is used to handle exceptions - such as file not found " M6 ~+ E2 R9 L6 q* ^# a; R
                // Reading the files will need to be placed inside a Try-Catch - just like this one!* P# m8 H& A7 H4 A% h
                // For more information see page 534 of the textbook9 P! W- p( d8 @+ B
                //********************************************************************8 m; C: c- A! M5 A
                    
4 e' A1 q% M( q1 N+ J) d; q" n! F        }( f6 @8 p# k- i: E6 g. A" p  O
             catch (Exception ex) // Exception caught here and message displayed to the screen 9 `& \/ y/ c( Z- Q# ~* _
          {7 m* G; U: g* b: ~" f
                    ex.printStackTrace (System.err);
- x/ _" ^9 ^8 }9 ?9 F% ]" {- w           System.out.println ("Error message goes here"); // Replace this error message with your own          $ Q+ i& X* w3 E5 E4 r2 P2 K
        }
# M, d* U- |5 {3 Z4 n                return true;: s2 |: G1 T; Q4 m
        }
, `. H0 {3 `$ U1 n" Q( ]/ U
$ c: W" P0 k! m} // end of class ProgramCompare
9 h1 ]) b' b. T
! n, U& l3 O, S- S5 \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 r9 v( p/ E$ b( }- y# k1 D$ E
//  ProgramCompareMenu.java    Provided by: DRS
/ t% U3 L% v) N/ v. R/ u' k//
$ z" |8 b, W* y' [+ e& z2 `5 o//  Calls AuthorisedUsers.java and ProgramCompare.java
% I; S- o$ i  j8 r//+ u; [) R2 p: P  E; p0 N; P
//  Driver shell for Assignment 2.% [# J8 E& H1 x! Z
//********************************************************************
+ v# A4 H0 x" V0 Y3 B
& `  z# n, M' Lclass ProgramCompareMenu2 t9 q, a/ o: ~# }5 k1 `" G5 f
{
8 p5 T9 x/ T% v# o1 Z0 d    public static void main (String[] args), z5 u' L8 @' V, o$ T; J$ \. U
            {
# e1 a% ?7 j, l. X1 A& a                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable, Q' k: V6 m) v* M" j) o% J5 Z
                ProgramCompare reached1 = new ProgramCompare();
7 m6 b9 }" N9 U( X0 T                AuthorisedUsers reached2 = new AuthorisedUsers();        - Q* k% K: u/ y1 n
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
$ I0 R& z6 H6 L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / P% c, |! y! m1 x) x# H
        }
- n4 f) }+ H. t; k# @' R}// end of class ProgramCompareMenu
# Z' m8 n3 D) l: o  B8 d! ~8 m4 c; {% D8 e+ g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************% x# ~8 |  P: y6 U* D
//          AuthorisedUsers.java          Provided by: DRS# {1 S9 E3 r' D0 d! u, ~
//                " p2 h  K& H* Y0 I& l. k
//         Program shell for Assignment 22 d* [) L) x+ Z
//
+ {! @6 h) V" v. q& G4 W  d4 W//         Represents facts about an AuthorisedUser( d) d4 \7 Q3 c: N1 X
//********************************************************************
) J. w" q2 c$ I: `* `. B7 h) k9 v* O) P9 {" \
public class AuthorisedUsers, S% `! h6 d' q: j" \$ W
    {* S3 s7 _# u+ H( h' P$ U

8 m/ C  z. r# W- B        //-----------------------------------------------------------------1 P6 y4 `2 f4 f. J+ H5 z5 c$ y
        // Constructor
# C) j- [6 ~1 ~; d3 Q        //------------------------------------------------------------------ W9 B* z4 H8 ]1 b

& g8 I1 G! Z2 ]9 J2 k3 G        public AuthorisedUsers()
/ f- \" J3 {/ T! L/ I; n# ?                {# U" ^% N0 a! G7 D7 v. ^
                }
' t2 _% O4 E% Q
! `' `6 l( W( B: A. ]1 g& F        //-----------------------------------------------------------------, L6 T/ E; l7 A. {! n8 w: b/ Q
        // Method for testing that class has been reached
. [- Q) \  ^! Q0 l$ ~5 X        //-----------------------------------------------------------------       
' H1 s4 m" U& x        public boolean AuthorisedUsersReached()/ {7 y* j8 A- |. i8 y: M( o! {
                {
) D. T$ g3 S; R+ }8 O/ a                        return true;                       
- u- a! }0 R0 @5 i. ^5 p% y                }! x% q3 c! ?# {. @+ ^
               
: {# R* X3 k' s/ z    } // end of class AuthorisedUsers
9 ?- E! N# I3 L& z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 ?# v  B1 j2 h" s& z- v
Shanghai - 20072 F; E8 J3 N; S' Y
Assignment 2" y8 g& A, U5 ^. b; t5 k- Y
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)
  l! `* c4 l$ L  M# `7 |* I1. 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 }# X$ U& h0 r" X
The staff must be able to:
0 K9 k, P( E5 t# m* x Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# }- R" n, d( L9 Q. b" U7 W5 S
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.
2 N$ G: ]( ]- | The interface should provide a menu so that the staff can:3 I8 t. `) G/ ]# K. s+ B$ k6 C- V
a) Enter the names of the two Java program files to be compared
0 m5 ~6 @3 [% h! M For this assignment, it will be assumed that the two Java program files are in the same folder as your program.4 d" X/ {4 L2 ^4 Z1 Y) e5 W
** 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)." A: g- w/ A* k! S% z1 J
BSA104 Business Programming – 2007: Assignment 2$ f/ g6 P; \" k" i- A3 Q; ?+ H) J+ `
Page 2 of 5$ _. K& Y) \% b) t6 Z) T
b) Print out to the screen all the lines of code that are the same6 k5 ?* u. w7 c7 r4 N- M* F# M
 Include the name of the file and the line number of the code being printed for each of the two files
: L$ Z' K. @, ^. q, ^3 g3 c7 z+ gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
8 x8 U0 U1 r% E% h. x the name, username and department of the user/ f9 Q- d3 U9 z5 {; j
 the statistics of the comparison
& J9 {9 D. ?- F0 E. A$ V- `1 U, K4 W4 L: M- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) b1 \8 n, A. \( G6 \- F
 the recommendation for further checking# h: y+ j6 v( u" U
- 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
% U# ~1 U0 P+ k) G4 o8 R) G$ ^ the names of the two files compared
" e: O( T9 @7 zd) Leave the program (exit)% L: [0 F; m8 q% s3 w4 X- {
The ProgramCompare class: (Total maximum 20 marks available)
& e' A2 |+ w  Z# C, K: q8 ]; c1 e& t2. 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)
, F* _4 F) u8 `4 |9 Z# O/ Xa) provide an error message if the files are not found or there is a problem opening them
' a5 [# W& P- hb) compare each line of code
# H' n4 \: ]+ p# Dc) print out the lines that are the same! b  W7 c) w0 S6 p" r) d
d) count the number of lines compared / lines the same2 v1 x( P" o5 H% n# D" i5 W0 X
The AuthorisedUsers class: (Total maximum 20 marks available), O+ P. \4 Y1 T9 {
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)# B/ |7 x' w) u4 R+ e! M" o% i4 i
4. Provide methods to:
  N5 Y0 }  c0 s& t6 c* c- Ea) 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
/ D% Z3 i* I' ?b) return the name of the authorised user. p4 x  N  m& t1 r* \9 D  ]0 g) e, V
c) return the name of the department of the authorised user
, }( O( ~- X+ Z) EIndividual Data (Maximum 20 marks available)
3 A% b; z/ w- j# d/ I# e9 F+ n5. 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.
" c1 _) [  Y9 F, `: ^. QDocumentation (Maximum 10 marks available)4 X0 n& Z6 ?# w9 C6 G4 V
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.! \( F: X0 O0 U# \$ X! m$ N
BSA104 Business Programming – 2007: Assignment 2
/ E- _, r/ k- `Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ n# R) f: d' K1 e: |不过你要翻JAVA的类库说明。你有下载没有?
  R0 B% }7 T0 U查询关于对比的函数。貌似关键字是contrast,还有compare
: m( V7 t) n' L* E! \" A, C& X( S
* [# g1 B- v- }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 o$ y+ N% ^) ]. a( Y8 h
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。; n' {* ?) f, u  j3 x0 B) @
可以下载到的 是 jdk-1_X_0-doc. Q9 f9 y$ K6 [. l, B' }( o- ?

& ~- X" K, x& l7 A! K6 V8 {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-14 04:03

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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