找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1108|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 U) c. ?: ]+ h+ V9 ~8 a 3 i) G3 m3 d& _$ _
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
5 `1 B( W9 r- b$ B& J$ d//  ProgramCompare.java         Provided by: DRS2 b1 U: O4 z0 `& K
//0 |: b: k2 T' H7 g
//  Program shell for Assignment 2! Y1 r! P) }, Y/ y( |+ H# L) g
//# C4 S! U; ?4 }4 w9 o. n( A$ }
//  Compares two text files line by line
: d. T% P+ x, q" {7 I" t/ P; F* L//*********************************************************************2 G9 \  J4 k; i4 B; s

8 J& N+ l/ N- J  w( r. q8 [import java.io.*;6 v3 B2 f" _: @; z
) Q/ h+ ]  i8 R  m5 _1 ?
public class ProgramCompare- T# a2 F" n' X& J
{5 Y- u7 G8 ~3 N, D& W# O1 i1 y! N
        //-----------------------------------------------------------------
8 T3 Y3 ^4 J4 r6 V& g        // Constructor3 Q' f; L& Q$ Y* Y3 w- ?1 K- @$ |. w
        //-----------------------------------------------------------------" t  n# i; t- r& a
        public ProgramCompare()7 S" E. c) {% W- b3 r/ m, K- K
        {
8 f* l: p3 I( Y2 d% R' e4 H: z        }7 ?/ w  T0 e: t# B, {8 p2 C5 d0 |

$ g- `! T  Z" F7 V, f) q        //-----------------------------------------------------------------
* n" g* w0 b2 p! y7 H4 I& @        // Method for testing that class has been reached
: q  A+ _- o1 w1 D5 R        //-----------------------------------------------------------------        & ]: Z' E3 J$ I' R, R6 X

2 P( N# X, S3 _8 v( C! n        public boolean ProgramCompareReached()         9 |- v' u& b2 k7 l
        {" a# B3 _2 B$ q9 r, v: A) V
      try
; ?$ T% y- ~4 q  Y* g4 Y1 t   {        
* m( j6 l; H  [8 R* L: X6 r                        - T# @& q* D) u. v: n+ ^; g
                //********************************************************************1 _- u# ]8 ^. I5 Y2 W: Q% f
                // Try-Catch Statement is used to handle exceptions - such as file not found
4 Y+ l' O* a8 W                // Reading the files will need to be placed inside a Try-Catch - just like this one!; y6 r6 f; k2 Y: I6 H
                // For more information see page 534 of the textbook* Y1 {5 d: Y5 [7 v  z
                //********************************************************************
7 i+ [' D% Z. u3 Q2 b                     ( R$ y2 s, S5 k1 @, Y2 ?- @
        }
6 I3 ~1 Q3 M. Y8 \2 b5 J             catch (Exception ex) // Exception caught here and message displayed to the screen 7 d$ C% c. b, _# w0 q  r
          {3 x0 J' q! ~6 O4 p
                    ex.printStackTrace (System.err);
! u- Z9 J$ a, R; J$ [9 `* R           System.out.println ("Error message goes here"); // Replace this error message with your own          & Z" R5 o; T5 d6 e. A
        }
1 J4 Z4 M( n: V% X! f7 G+ m9 R                return true;2 N  D* ^* m) b" m7 H1 ]
        }/ ]0 B) t0 R7 s) s1 i+ r( q/ f

% o3 R) [. n! l6 F: ]} // end of class ProgramCompare
8 b( U+ z  U/ d) }# j% y1 L% [. F% [% B. b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
& Y' p# r4 ~' K1 J' L//  ProgramCompareMenu.java    Provided by: DRS( }' |& _& c$ d2 Q3 ]
//! O# N+ b# Q" w8 P
//  Calls AuthorisedUsers.java and ProgramCompare.java6 ~6 B2 E& a, n. v, _( }) N
//% b( D+ Z/ ?( p! ^$ e$ M* c5 p
//  Driver shell for Assignment 2.0 x* u% g1 q. F" F! I
//********************************************************************
/ H; _, N1 |9 f0 o: d: k7 r, J1 L
, {; w1 ?; y( B5 Y# @class ProgramCompareMenu
4 u/ G) F# F* w, M{: K( W" f# C+ J; D+ C
    public static void main (String[] args)
0 l, U1 w. G: U# ~) J            {
$ w0 L0 b& ]2 r+ Z5 s0 l                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 ?$ k- f% `% J9 v+ D6 [* U# {
                ProgramCompare reached1 = new ProgramCompare(); / e5 ]' s: B  X& c, [% f
                AuthorisedUsers reached2 = new AuthorisedUsers();        , a6 w. P: U  g* c7 I+ |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());; R4 {& Z# ?/ p. t; ~, a5 l
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 |) R: V# {, S9 {% h! b
        }
- y+ S; k; b! J/ y" J  v' i) ~. o: f}// end of class ProgramCompareMenu. Q# n4 {  }$ j6 H5 n' D& f

) l# C' L* n$ o1 q! L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ H. T% u/ h: c' p4 ?2 T//          AuthorisedUsers.java          Provided by: DRS8 O0 u6 _! m/ W$ D8 _
//                * n4 ?6 x: w# f  S% S, o
//         Program shell for Assignment 2
/ ?9 U. t) F% A' K3 l/ u//
3 d# P: o" I  {/ Q9 v3 T& r//         Represents facts about an AuthorisedUser
3 J: e1 A4 c2 c2 d//********************************************************************0 [0 P  E" i, I. Q6 V

# D& y) o: S! spublic class AuthorisedUsers
0 ]" v: ^9 G5 Y6 a; Q( t0 K    {
/ E  N! @2 U# H: r; Q% q( S: B' t1 D% s' ]! Y
        //-----------------------------------------------------------------/ ~$ ?0 G' U, y! \; }+ ^
        // Constructor
; u( k" R. G; K: C2 ]& b* K        //-----------------------------------------------------------------
, n5 P+ j/ D/ _! g# C& M1 s8 O0 G$ E3 X! p& s! K
        public AuthorisedUsers()
# a1 E; p2 |% Y6 ^7 x& K, @4 c& O                {: n$ @" S& r/ d5 z
                }2 M9 J' }) a( o, c. A, l

. x  M) H. `& Z7 O4 o        //-----------------------------------------------------------------
+ a) h3 d' }3 `, X% J        // Method for testing that class has been reached
& N+ |6 J" E% y# l        //-----------------------------------------------------------------       
% v% h, t8 ^" p' p- j; d* b3 L9 n; e2 t        public boolean AuthorisedUsersReached()
2 c6 r+ c2 Y5 F% c6 [* d! D7 U                {2 Q+ M/ q' b2 N& R
                        return true;                       
- T" v7 p( R3 b" B1 y4 n/ c! j                }$ ?; m# R/ p0 _
               
1 `7 N6 Q, k3 z; @% N    } // end of class AuthorisedUsers6 C2 u, f6 M* B3 ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# X8 I+ g) P% K' q8 Z/ x- J
Shanghai - 20079 B0 u* t+ }( j$ i+ Y* G& ^% y) U: S+ j0 G
Assignment 2
8 f+ E- w: ^/ c4 tDeadline 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)% |2 G$ r' `+ B
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.
$ I  m" R. I0 Z, ^The staff must be able to:; t- V' Y# ]9 s/ |/ Y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
; i0 I, I0 T9 x4 q1 _# D1. 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.# P/ o8 W0 \' }: k# Q5 U
 The interface should provide a menu so that the staff can:
9 v* \3 ~3 `0 k; Ja) Enter the names of the two Java program files to be compared. [" q3 ?- K" f# b0 v
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.5 I, z& L! G# V( V
** 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).$ M5 o& R9 G- x
BSA104 Business Programming – 2007: Assignment 2, [4 I# t" w+ V
Page 2 of 5
4 Z0 U" o! u7 ]8 m. Y  `b) Print out to the screen all the lines of code that are the same. I$ c4 C) X- L8 \/ @
 Include the name of the file and the line number of the code being printed for each of the two files) b8 Z; ]/ j& i1 W: d& t/ F  n
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 T" C; }& ?* |! z. q& ~
 the name, username and department of the user& M. Z, D9 S" j. }1 f5 m
 the statistics of the comparison
& d0 M8 w8 Z# A/ d% t- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 i3 |; H. C1 ]/ r the recommendation for further checking4 E( x8 q# w& ~/ L/ U6 Z* g7 e" W! {6 W
- 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
. T4 U* h0 K/ J0 U the names of the two files compared+ @7 R3 b+ S  P0 r  y7 v  c
d) Leave the program (exit): K0 @5 ]  ~- P  t9 w2 w) D
The ProgramCompare class: (Total maximum 20 marks available)9 B4 g- `7 L, u/ g
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): q6 G1 W+ ^0 x5 Y
a) provide an error message if the files are not found or there is a problem opening them1 F; ]8 [3 C; D9 D% }2 H4 W! h, [
b) compare each line of code0 {. ?3 |3 X9 b. G. A" V
c) print out the lines that are the same9 k; W  c* P9 ?7 y4 b
d) count the number of lines compared / lines the same1 D) w6 s: b; q2 D# u
The AuthorisedUsers class: (Total maximum 20 marks available), a6 {' H2 o4 }; _. P$ D+ M
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)
8 q& U( o+ D9 O' N& v6 Y1 X% R4 T2 r4. Provide methods to:
. q- [2 _( J% }5 y# C2 V5 G1 E, |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
- K6 h6 |0 u. s7 _; b9 db) return the name of the authorised user
: v+ {2 n9 ^( U% s3 I1 k1 z% dc) return the name of the department of the authorised user
9 ]4 k( x4 ^1 Z- iIndividual Data (Maximum 20 marks available)
5 ^# n8 v! c5 ]/ m- J3 w5. 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.- v/ I* a3 w8 q. F/ C
Documentation (Maximum 10 marks available)
- ?7 l( k& T; [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.
. S8 T, I4 m+ l) B+ V& h' qBSA104 Business Programming – 2007: Assignment 2
3 a+ O/ A1 V/ yPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
: q4 U! Y- U% V1 W/ a6 I/ u# J不过你要翻JAVA的类库说明。你有下载没有?- R4 X+ u3 I' l: A; C: H
查询关于对比的函数。貌似关键字是contrast,还有compare/ W" [; O+ r! ?

7 e4 z( t' @( l# \7 v[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, T: T4 T7 W0 ]6 l痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' t6 E# z9 W1 e( c% Q
可以下载到的 是 jdk-1_X_0-doc& M4 R: \, m  r  w8 e( [! S* R4 p

* n9 r/ F+ v7 j2 b0 j- x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-13 10:54

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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