找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1307|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" Y; Y* g. u$ I P, X ! Z, O5 ]- {$ W' M4 F
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************/ ~3 g- Y$ s+ T
//  ProgramCompare.java         Provided by: DRS5 K1 u' {- R* V- r3 A, i  K
//
* M4 s: ~6 L" Z% f//  Program shell for Assignment 2
8 M  Y" \" w8 n. ^2 ^8 ]//
4 n5 c' B% I1 j$ H& E6 F3 l& @& E//  Compares two text files line by line
8 ~- n; j& D7 D1 o8 @//*********************************************************************
8 d' X- L1 q. b# `, V
4 Q3 G" N" _: ?8 c" @import java.io.*;6 i  [  ~4 L+ C# }! H
' z1 q; G) w5 I
public class ProgramCompare
2 P' W; ~8 w5 e( Q: f( P, n' X{
& G- S: D, B- {/ ~' ^        //-----------------------------------------------------------------
" K! T& m, [/ P9 K2 l& }( }1 l        // Constructor
$ A2 t; t" B8 o+ W# z+ G; ~        //-----------------------------------------------------------------6 {' X1 w) ?; Q( S8 k# U2 H
        public ProgramCompare()
4 T. s& G$ T% v9 C, l/ j1 e        {/ ^+ z7 {/ c- L$ m# ]6 p
        }' _. w- E" f2 n# a

; @! J. ^  ?$ o        //-----------------------------------------------------------------
5 w. \5 O4 V5 |/ C! c        // Method for testing that class has been reached
: w" h( {/ S( A$ ?7 p        //-----------------------------------------------------------------        ; a( f; _# {) U1 W2 m
! h% `3 i0 v1 \6 R
        public boolean ProgramCompareReached()        
4 V6 b1 f6 \: _; S        {( C' s7 B( V) P/ U3 }. c2 b- D) Z
      try
# \2 p$ j6 }/ b- i2 h+ T   {        
: o& N9 F0 o9 }+ @  c, t/ W; f# Z                       
5 x0 C- l  Y6 }: G                //********************************************************************
" A3 t0 R; z! H/ l; e& A$ _                // Try-Catch Statement is used to handle exceptions - such as file not found
/ K; l0 x( p/ ]) E1 N                // Reading the files will need to be placed inside a Try-Catch - just like this one!7 f- y! l9 [  `( y# |8 K- Q: Y2 E
                // For more information see page 534 of the textbook: \/ U. Y  ^7 n) B2 }
                //********************************************************************
3 B1 G9 Q7 _4 ?" p                    
' R( J2 Z5 ~8 g9 S        }
: x: ^, d) ^) s4 t" n0 ]! k/ Q             catch (Exception ex) // Exception caught here and message displayed to the screen
! {! Y2 n! r0 @( v! @: v          {
' n- o4 E1 _4 F: r                    ex.printStackTrace (System.err);$ ]1 }' E% G1 t2 h% ~6 H
           System.out.println ("Error message goes here"); // Replace this error message with your own          ; N7 G, G2 J4 ?
        }
( v! D9 m+ E5 v+ y& K* n, ?                return true;
" P" P2 P; i6 E0 e1 _( T- [        }
: d5 Q% }/ a; P& y0 ~$ V: X- P0 V
} // end of class ProgramCompare
$ f2 @$ `; [) \; P0 G' m7 F' U) N% c' T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, K# {, u0 u! Y
//  ProgramCompareMenu.java    Provided by: DRS
% H, [6 T  W% b& h8 S//
4 k4 _' W& V) w" A( [  c- O; @//  Calls AuthorisedUsers.java and ProgramCompare.java
( X3 M) x3 y1 ~7 g//
) s; c5 `0 X( `3 U5 w7 A//  Driver shell for Assignment 2.0 H% K8 }" E- K5 C  k. g
//********************************************************************! q6 \+ R0 m+ S. o9 u' y4 t
6 O5 C8 e5 {; k/ o* p+ T6 _4 t* E
class ProgramCompareMenu) X1 N* L% m; L- z- R
{2 {* N# Y8 _& D9 V- r9 w' I
    public static void main (String[] args)3 b. E& O$ w- u* z# V9 y& V3 P7 Q3 s
            {/ c/ s: L* D  T- r
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 z6 U# N3 K. r/ I& Z4 e, H/ f1 y                ProgramCompare reached1 = new ProgramCompare();
" }- W2 g9 p( s8 B: _& A' z                AuthorisedUsers reached2 = new AuthorisedUsers();       
1 Q2 d; Y( X. Q7 B3 E                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());* O& u7 l  X$ F2 Q
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / K" h9 d2 ?6 \6 g% d' X
        }8 v! S: z2 Q# p. ]7 T
}// end of class ProgramCompareMenu$ S: O: d, E) M4 `: t) e+ B: l

. W0 p' W& P' U9 R  s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************; j( A* s  w0 E1 S7 b# Y# {/ \
//          AuthorisedUsers.java          Provided by: DRS& F( H: P: r; U
//                0 K1 G( U9 b" O' N5 s
//         Program shell for Assignment 20 F1 |# i% G$ I: ~4 _3 G. g
//  h3 ]+ B% }, A$ y
//         Represents facts about an AuthorisedUser
$ L+ G1 T( z" j1 k& m4 |4 p3 p2 z//********************************************************************
) K# c% Q4 m" U0 f5 ^
& t6 Z0 [# x8 n; q1 E# Kpublic class AuthorisedUsers+ u2 @% f! m& f
    {9 E/ z3 F* H. P* ^
8 e4 V! T! X+ G9 L) Q( ?" i) b& r( Z" O
        //-----------------------------------------------------------------
$ Q: P* S* J- g2 B. P: P        // Constructor. `8 h  M- ~  ^: V- a  O
        //-----------------------------------------------------------------! e+ p& q4 o4 o3 c! t8 U7 G* k
7 T& {% s& n: n+ L' |; A: Q* Y
        public AuthorisedUsers()- |" A  @& p  A
                {
3 L1 V  b0 j; D; x) S1 [                }
; }) I, p4 Z, P/ Z; [  i# p3 Z* z
8 ~1 z) w2 F; M3 {) h% ]        //-----------------------------------------------------------------$ f% C! ^9 {8 r
        // Method for testing that class has been reached
) {$ W6 ~; j/ l: s: W6 |& P3 X: r4 ^        //-----------------------------------------------------------------        : A# C  T* L. W5 D: y% t
        public boolean AuthorisedUsersReached()
* q6 [4 D- Y# v+ H/ D                {
& G) r7 O" b7 B                        return true;                        1 W" E( u: [, Y) b: w" Z/ |
                }
. y+ `5 i( Z8 c7 j. U4 s                ) o0 V: h0 ~. v' w! @" J0 S  P
    } // end of class AuthorisedUsers
/ T0 g# V/ ~; h6 L' H+ Y: z1 B1 t8 j8 y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. V; I/ ~1 d( {& i% Y
Shanghai - 2007: U. p6 _9 f; J) x0 f7 W( N) R7 `+ h
Assignment 2
( U7 y" e) J/ {7 B/ h1 UDeadline 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)
# w2 }- G2 p- D5 `8 |# k) }8 X1. 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., a  U# R# |' `7 I6 Q; l# z
The staff must be able to:
! v( W/ M3 P9 G1 ^. m$ i Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 Y& P6 N7 `! d' s1. 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.
( h+ ~7 Z9 R2 c. Z0 A& s The interface should provide a menu so that the staff can:- n# [/ G' b$ ?, ~
a) Enter the names of the two Java program files to be compared
6 U. y+ M: s2 j# [. b9 m% e For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# s' e' F6 b8 p- B0 q  S** 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)./ Y! ?, d3 d( Y9 L5 y
BSA104 Business Programming – 2007: Assignment 2
4 j: |1 ~/ d/ o) Q8 s5 e" tPage 2 of 5
1 Q/ r9 b1 }  G" l2 b' t. u3 bb) Print out to the screen all the lines of code that are the same# y7 g4 i' \  T0 u/ R8 X
 Include the name of the file and the line number of the code being printed for each of the two files& {4 T$ g& |! t$ c9 M/ z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. R& B. o  k  C, [
 the name, username and department of the user
+ V2 j$ _3 n7 W, b) e9 }8 }; t: Q the statistics of the comparison
- M! S  d# y0 B6 a3 p0 w& D5 M- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# P4 n+ N: d' b" i4 j5 M* {
 the recommendation for further checking* {5 Z& L( N+ R, l8 H3 y" t  B
- 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 closely3 y" y/ e1 s9 @1 ~
 the names of the two files compared' @3 Q' l( q$ {: g2 k' W
d) Leave the program (exit)
5 \  E& R+ h) ?  z8 E. m+ [The ProgramCompare class: (Total maximum 20 marks available): A: F( G3 H1 B
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)6 n4 b3 J4 P, f/ M- n( C7 p) s. T
a) provide an error message if the files are not found or there is a problem opening them
+ K* h2 S( p: D1 f/ X5 tb) compare each line of code
4 \+ E6 z* ~9 w  kc) print out the lines that are the same  q4 `7 _1 d. Z% o6 X% t
d) count the number of lines compared / lines the same
, a" Q! B. b  X; z+ H3 o/ A7 v5 MThe AuthorisedUsers class: (Total maximum 20 marks available); i/ x9 J6 T. u4 A& a/ D
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)
9 F# |: t2 v3 q- q$ _' B$ o! b4. Provide methods to:% w- O0 |% `* y% O& U; M7 j2 `& T
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+ a4 I9 c0 f( P/ o% J, |
b) return the name of the authorised user
! f* k+ `" X% ?# U: Kc) return the name of the department of the authorised user4 \8 r6 b: ^1 l; D
Individual Data (Maximum 20 marks available)3 f' ~3 v0 u+ m7 v+ ~9 g, }( `$ {+ 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.4 J& w1 N8 D7 j* c* W9 L
Documentation (Maximum 10 marks available)* z: K: o) k0 x- Q& D
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.
  C4 h7 Y9 X$ HBSA104 Business Programming – 2007: Assignment 2% X  ]' s  n# V& Z3 c
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* i% H1 ^: S( ?5 I2 E! K, @4 l# p不过你要翻JAVA的类库说明。你有下载没有?
% S- V4 b& G1 P/ _8 g0 W$ p2 m查询关于对比的函数。貌似关键字是contrast,还有compare+ V3 b* u) D% w9 X7 H: \
, V' M" u1 \8 u
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -$ m( ]$ ~# F1 x' ^/ m/ u
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。" }! X" z; ^+ G% h
可以下载到的 是 jdk-1_X_0-doc
1 m  j1 W4 H* n6 X1 I2 [. [9 E; C( S/ d) T9 G, T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-23 08:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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