找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1302|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 w2 \/ J( J9 i+ t+ @1 D! Q2 ?9 ~( y
回复

使用道具 举报

 楼主| 发表于 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 ^5 w2 l0 k. G: s, w//  ProgramCompare.java         Provided by: DRS
3 E1 D* u6 Y- ?2 \$ Y//
+ y: m( p+ F( C$ l. D$ G" `4 d//  Program shell for Assignment 2
* W$ N5 U; h, }* W# {* T//
  s: m% F0 J4 L& Q6 x& P//  Compares two text files line by line
  c! s# [  z) s5 G, l' c//*********************************************************************
% F) A1 y  M8 ]. \4 O5 y% m0 X/ v, \  S
import java.io.*;% L2 h& K$ t1 u' }( ?1 A$ U4 x
( b) s7 T1 I/ W
public class ProgramCompare
: B/ e$ h* l" E5 m{  B2 j7 G, t6 |* F$ z
        //-----------------------------------------------------------------9 B8 l, D$ z) \( R! `
        // Constructor9 g3 l  u( E* S8 n: C
        //-----------------------------------------------------------------
2 X1 M% T6 \7 b" w* h5 Z" e        public ProgramCompare()
8 h1 p* i: F! [  y0 o        {3 H; q. g# w/ _3 d* F
        }
6 h' U! T, T8 f
: s/ q! u$ u. _, U% I        //-----------------------------------------------------------------
, j  u6 R0 x1 a  W( j        // Method for testing that class has been reached
  J: Z- Z2 V# d4 z4 p! ^        //-----------------------------------------------------------------       
3 F8 @4 E+ g3 a5 C
: i( u& d5 e0 K' b1 G        public boolean ProgramCompareReached()         ! Z  J2 ^. c/ P* S
        {% t/ O2 `+ u! v; h4 r# R4 Q
      try 0 I" |1 d5 z1 w0 ~
   {        
( C* R( F; l1 L1 A2 _                       
' a- p$ n- m: V6 ]                //********************************************************************
/ T; h8 I3 u: j                // Try-Catch Statement is used to handle exceptions - such as file not found 5 ]  G# S: g+ k& v  V1 o( e; b
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ _7 W" z2 w" F: h, Z                // For more information see page 534 of the textbook
, F3 ~# R: K6 O                //********************************************************************
" B7 a% ], h+ O9 x                    
$ }' `, q6 P$ s% s2 L) J! S        }8 t# X7 T; U; r! _) }% I
             catch (Exception ex) // Exception caught here and message displayed to the screen
& H9 ^) h: i& h3 a+ o          {
$ P4 r$ k( n# n. V; D                    ex.printStackTrace (System.err);5 {7 [- Q' `# k4 `- Q
           System.out.println ("Error message goes here"); // Replace this error message with your own         
' M+ H% q% T; ~        }0 H$ w6 B: g& _8 ?  Q* R/ \( {
                return true;
4 E  s% C# D  }+ H$ k9 f# j* c' z        }3 C+ X5 V1 T0 J. R- }, E

% P1 W  t! ]5 c} // end of class ProgramCompare
. g" \: X) F- F- T7 V; Z* z& T
4 _6 \8 l+ A6 k" ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- n& l4 N6 P- o  `- f3 [  S/ c" B
//  ProgramCompareMenu.java    Provided by: DRS( Y! z$ o2 N. ]8 w% M
//
. H7 J( y, `' s& L& d//  Calls AuthorisedUsers.java and ProgramCompare.java
; W* V: F4 E( ^6 @//
2 E5 o$ a# B. e; V8 z& Y9 f  N//  Driver shell for Assignment 2.! S" t) u9 Q: _2 K% k, X6 D) V
//********************************************************************
% g7 i9 ?6 P' b& B/ u0 b! Q: S8 y: k+ e( L/ d- _) N! L
class ProgramCompareMenu
  R, {! j% s6 l0 A4 s" v+ L{
' m+ Z) E' }7 A  a0 x( l6 O. h$ X    public static void main (String[] args)/ J: S3 V7 t# j) ^* `; y
            {
+ H; L8 l$ W0 _5 d' S8 R! z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 G) j$ `0 J" w7 ], v% K  B                ProgramCompare reached1 = new ProgramCompare();
5 @& w8 Y4 `) M  g' B- P& B                AuthorisedUsers reached2 = new AuthorisedUsers();        3 G5 q: o; T# j( w* |6 [. g
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# O0 u- j8 Y# `  `
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 [6 N) F/ C- \) B8 X! I5 w0 ^        }
0 I/ p) f7 e; V}// end of class ProgramCompareMenu
/ U5 E8 G* E" Y7 Q; z) o( p  W& K. B& v/ u9 S) ?4 l
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 {, M6 \1 v* S9 J2 C5 f
//          AuthorisedUsers.java          Provided by: DRS
. v. c7 v4 P/ T1 U8 W//                , \! [5 D8 z) M# E- U
//         Program shell for Assignment 2, ], N) O: y: S4 k! }! i/ r3 d
//
1 w) M  X/ q9 p% V6 Y4 T//         Represents facts about an AuthorisedUser
; S4 [6 h! O$ ]+ M7 C1 H: d- \* }//********************************************************************
2 m4 g0 U4 ^; M: r& R/ W6 q$ l
4 Y" I/ d/ D7 v1 H* hpublic class AuthorisedUsers
; o7 W5 [  j2 I, m8 A* v5 Q& K5 t0 f/ j    {1 f! d. x3 w6 B
$ q, z8 }7 B. f* U- ~- F" |$ }
        //-----------------------------------------------------------------+ C8 |" p6 V6 I8 l0 i* }
        // Constructor
5 V- |9 N5 t, c( m9 J        //-----------------------------------------------------------------
% ^* _- G' k7 K' u/ h/ s" h) j/ m9 I0 |4 w& N) F
        public AuthorisedUsers(); y9 I; v6 N0 D+ c% n6 m
                {
  I  W; o9 i9 Z. ?                }
  A9 S1 e+ U. Z1 r( E
* ]# O  [% r3 k- @2 H& ]        //-----------------------------------------------------------------
3 t. r; ?3 f& U$ {7 m  A9 A        // Method for testing that class has been reached
, N/ Z9 x# w! g0 M& S' N8 W5 G8 n, B        //-----------------------------------------------------------------        " U1 ]$ K  m7 y1 b7 U
        public boolean AuthorisedUsersReached(), k7 T- O/ i1 V1 c1 ^3 N
                {7 C/ W# E2 V) R% h4 h
                        return true;                        % a% [; w1 y1 Q, r
                }
$ W+ U! E5 A* o3 L# x) t" ^6 z- D               
( j7 l+ l6 Q& s" r# g4 w    } // end of class AuthorisedUsers: ^* b) W( C: r2 P, F! L$ r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: z, b8 W" B8 k3 @9 k' u4 C# M
Shanghai - 2007- V7 J' Q$ }7 N8 p$ R
Assignment 2
  ^1 f0 V- R, M) r5 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)
0 i, X5 w5 m) n$ b- b+ E1. 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.7 U# i% A! J+ E+ [
The staff must be able to:
& X; O, B8 q9 x3 k4 u8 ]. A6 Z; O) [ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ l0 ?8 K+ G9 i1. 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.: A) t4 T5 u, b8 P- e: E
 The interface should provide a menu so that the staff can:5 F; ]4 O: J2 C: G! d
a) Enter the names of the two Java program files to be compared
3 b0 W( }3 y- g; c For this assignment, it will be assumed that the two Java program files are in the same folder as your program., V$ k! U. H1 h) t; h6 b3 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).
. q% o: J& K! a& BBSA104 Business Programming – 2007: Assignment 2
% A% p9 A# ^4 uPage 2 of 5
' l2 Z0 M# w2 A7 P$ R# Nb) Print out to the screen all the lines of code that are the same
' z% B( U: v) t Include the name of the file and the line number of the code being printed for each of the two files, B/ i0 p) ^0 E" o; H8 F
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 @4 ~" b7 E* |( a# i% P. E the name, username and department of the user
3 x& B" W* h) q9 P3 l: c+ s' Y  W+ c the statistics of the comparison3 g0 Z( X3 f# L$ s0 U  G: P
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ Z7 T! @, H& f* _8 q, r# ]+ W: w
 the recommendation for further checking& }, O3 n' N0 t0 c: f, S
- 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! Q! A7 K' x( t
 the names of the two files compared
% }% {( e' k& sd) Leave the program (exit)
* ?' K6 s* c' z. H( q# [3 b0 I7 b# `The ProgramCompare class: (Total maximum 20 marks available)
1 g& A% Q9 a0 @& u4 Q2 a$ j; ~( 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)" ?; n! F- C' G5 B
a) provide an error message if the files are not found or there is a problem opening them
# ~4 ]0 ]3 d+ z* \4 J5 j' A. gb) compare each line of code% d/ Q/ h9 B9 y# E2 s+ I
c) print out the lines that are the same
/ X9 y5 A: M6 A$ _( {6 ]. md) count the number of lines compared / lines the same
. f7 Q$ [3 M2 [* ?The AuthorisedUsers class: (Total maximum 20 marks available)
1 z0 r$ ?9 Z( D$ e0 l3. 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)
0 A  D. e) D- s  J1 \, S$ @7 a4. Provide methods to:
1 N9 a9 G* `4 j3 ?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
: W: U! r# [7 f* U# w$ g9 m9 ]b) return the name of the authorised user9 v, Q/ y% s% X& d) s6 y. Y
c) return the name of the department of the authorised user
, F% V6 x/ j% {( p! j# H) }Individual Data (Maximum 20 marks available)9 d# |2 Z# ^+ r! C
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.
% ~. h0 \. z: q: V( JDocumentation (Maximum 10 marks available)
1 ^& u3 |% y2 o1 {& ?& u$ y6. 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, Z0 D& O% f% x# l
BSA104 Business Programming – 2007: Assignment 2
. _; U) T* R9 U9 z/ [) c, }Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了' Y2 O( |- }+ I; v8 }( ?3 B, t
不过你要翻JAVA的类库说明。你有下载没有?+ @5 a5 P6 U! A" Q; O* L6 w: O
查询关于对比的函数。貌似关键字是contrast,还有compare
# H4 h6 |; \% w9 v% C
$ e: c1 Z3 f, M$ w# p) b# h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 o; C. i3 R& ~# v/ R- r痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 n2 X- n. y; k$ A, p) x; A4 ]6 B可以下载到的 是 jdk-1_X_0-doc
' M! V5 N) a) `8 h/ ?8 ^; P' G, ~, Q" @' ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-21 21:56

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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