找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1589|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 N+ E4 c6 ?( o$ i2 g: v j1 z& J1 @9 C+ p" J* 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 | 显示全部楼层
//*********************************************************************
- O! Z& K: ?) I2 Q- W! k2 C4 N//  ProgramCompare.java         Provided by: DRS0 g& V1 R  n# j* }0 d4 W0 O# \
//+ @% s2 K4 e) `  |# d8 g
//  Program shell for Assignment 2. O1 Q! p6 r: V3 c% M9 \; {
//
7 j$ a2 L$ i# x+ ^8 v8 B* X//  Compares two text files line by line
- ]9 c! }; e# W, O+ G//*********************************************************************
+ \8 S7 A9 k$ Y$ ~+ b; G/ |  W- Q/ N: H5 s& N' M) K8 I
import java.io.*;, B; Y) ?* k+ g- L1 s2 j. r

7 g" X' @" {" f8 Ipublic class ProgramCompare2 K  G  D0 g# S9 T% e2 D0 d
{
3 R7 p) s5 s2 W2 A" _$ g        //-----------------------------------------------------------------
+ T6 K0 o& k: `" g        // Constructor
$ |2 L; Q+ m9 L1 F" {        //-----------------------------------------------------------------3 J5 j7 t& c( D  R0 X& t  o
        public ProgramCompare()
* Y9 B" ~6 m) \9 T$ G" m( c, n9 X3 \9 U        {6 O- t; G4 o1 b) W
        }9 n# z# w. N, k% l: C) u. v
7 d/ Z  e9 h" W- c! W" f  Z- w
        //-----------------------------------------------------------------
9 X" E$ U2 F; s0 E        // Method for testing that class has been reached3 S* s; Q, w# Z/ u6 ~4 n
        //-----------------------------------------------------------------        4 f) [7 H" U; z5 n/ t
# P' p' S9 T( J$ z
        public boolean ProgramCompareReached()         1 i4 E6 p' Q0 ^' G) w
        {7 Z" F2 I% d% b& m" b; p  N* [( z
      try - t) C& E9 g4 s* |2 h0 l  w0 V
   {        
& C0 {6 y# [1 J, x/ ~. h, G                       
+ ~7 w2 O2 V. S6 S1 L$ s# ]                //********************************************************************/ t. _2 g$ F0 i6 j! H) X6 h
                // Try-Catch Statement is used to handle exceptions - such as file not found ) b8 B. I- `$ k" v9 [3 ]( f6 C
                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 E5 K7 r7 Z" v0 w' v
                // For more information see page 534 of the textbook! C" A  }1 C9 I$ S9 @
                //********************************************************************7 A; J6 U7 ]0 _  E
                     % ?0 ~+ H% E4 }5 e9 R+ v$ B8 }
        }
7 y2 y2 t7 {, K8 ^1 [8 r! n! ^             catch (Exception ex) // Exception caught here and message displayed to the screen - U, Z1 P; d! K7 Y
          {2 J6 c1 ]% b1 g' |, Z
                    ex.printStackTrace (System.err);
! m! n8 i5 m' G7 U4 q7 Z: ^0 g) v           System.out.println ("Error message goes here"); // Replace this error message with your own         
; j0 r. s1 w  \- M        }
( g, i7 z  }5 y& g' P# g: ^" B                return true;* z" d9 J$ o; T; F
        }
, h; k5 t/ a( @7 C5 O
; _) F: z6 X8 n; {( t  S$ I: F. h} // end of class ProgramCompare
* M- ]; X3 M4 }# A5 x/ U8 n0 f- M
6 E6 Q: e# ?; g4 g6 s$ D6 p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
; |, e, O' }( B/ o4 r: w& P+ f//  ProgramCompareMenu.java    Provided by: DRS
# u8 Z* Z- a; C% D. V; W; x7 R//
  Z& j" d1 z3 q# Q# C) I6 W//  Calls AuthorisedUsers.java and ProgramCompare.java" B) B6 h# }$ p2 X& E# `) A
//( o( o5 C/ D8 i3 a3 F& L
//  Driver shell for Assignment 2.
) Q0 G5 J, z5 `. I//********************************************************************
7 B! R7 s2 Q, S5 Y! f* a5 }  d% b  |- ?0 o+ K9 q
class ProgramCompareMenu
7 F; h& y5 ^% S{
  g7 A$ r0 @" L# I    public static void main (String[] args)1 U* i6 t, M, P* }  A4 w
            {0 f3 y8 b' t# l
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 H8 p- I* ~8 f, V( o  Q, ?
                ProgramCompare reached1 = new ProgramCompare(); - T6 X" o6 Z) N* p# Q0 h0 R6 w4 H
                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 L- b$ \, l) g. {4 w1 X" Q$ y! r                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());" G+ w2 k+ K+ @" _6 _+ j7 M
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; X. H7 }, {3 V2 s& \( J  ^+ R        }. w4 H7 o% f' k! d/ B  r; K$ l- k
}// end of class ProgramCompareMenu( A0 I4 [1 L  \, n! N$ t
' \8 _, C1 I& n% ^" x1 {! v, o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  Y; Z2 C. j, f, i0 M7 ^; o* G
//          AuthorisedUsers.java          Provided by: DRS  e; }6 N, g1 b  J
//                " f. X/ Q% \  t6 N8 }8 K7 Z. R
//         Program shell for Assignment 2
4 E, ]# v+ o" k! V& a9 }' W//9 _& G1 ^2 ]$ ~% L. y  k" z
//         Represents facts about an AuthorisedUser( ]0 B+ G# E/ z7 {0 C; P
//********************************************************************% W; F2 Z6 k# X! {  y+ w0 P2 \
% H8 ~' [7 P8 ?
public class AuthorisedUsers
9 n: I5 X1 K5 i1 Q3 f    {% U5 Q# I; {7 |8 y
! ~2 q2 g4 j8 U' }  B  U! f
        //-----------------------------------------------------------------: Y; k- \6 L" a1 S4 h
        // Constructor: ]% y! B' g- F7 r. V" e
        //-----------------------------------------------------------------' k, G5 ?1 V1 P" l
' B0 J2 E: Q. K
        public AuthorisedUsers(), X9 E* Z9 J0 ]& c9 C
                {
- y0 H, b7 ~/ ?# R2 W4 ^  a6 g                }
3 s1 P  h& d, z) l2 B8 V7 b0 [1 G) i1 D! K2 v# G/ h& T5 r- C5 v6 H
        //-----------------------------------------------------------------; s- F8 m) X9 v+ D- ]! ^, p: l( t4 @
        // Method for testing that class has been reached
! H7 i8 P9 B" _  @" J        //-----------------------------------------------------------------        5 s% \7 F3 i7 C/ `
        public boolean AuthorisedUsersReached()
/ D4 v6 J0 V% s; p! R/ R, A                {2 K. i$ p! z' q$ a2 c
                        return true;                        , u  J) e* p) h# |$ Z( V- n
                }
: o) [5 `" R1 k2 @! O               
2 Z6 O" ~6 h# e  w    } // end of class AuthorisedUsers
# p7 J+ x* V8 v; T: o" `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; T9 L- R- l, k5 Y7 [Shanghai - 2007
. ^/ Q  F! y* h7 W& `7 |5 y* q% C2 ?Assignment 23 h2 r- n* |& o. P
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)
, s6 }0 }5 m/ K& S) y. g) Q1. 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.
) `$ c/ ^) S$ R2 u3 U: r5 t; tThe staff must be able to:6 o$ w8 [7 H& G' c8 ?  v
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 i. t. c( o4 ]6 d/ O4 K
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 {! T! h( P  D4 E, _) q
 The interface should provide a menu so that the staff can:/ X+ L: f1 U6 X. q! D$ s
a) Enter the names of the two Java program files to be compared
: @0 \" r( U/ C1 F2 V For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! t: J8 }3 _, o, L$ ?9 c. q+ k
** 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).
) w, Q- o' Z" J3 UBSA104 Business Programming – 2007: Assignment 2. [5 f3 H* L+ u# Z/ w0 y8 l
Page 2 of 5
/ n+ B& {! ]1 \/ Q; Cb) Print out to the screen all the lines of code that are the same0 g# Q3 {) T/ t1 q# J- P
 Include the name of the file and the line number of the code being printed for each of the two files
* [% ~9 _0 A1 ?' }5 Tc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared* |) z2 f/ e4 s0 x1 G8 z4 y
 the name, username and department of the user  l6 a5 I7 o8 ?& R& l" H! ?# X0 Z  g' ?
 the statistics of the comparison7 g& P4 A4 J" h# i( P4 g
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different' X4 h# w5 F% M+ _5 s
 the recommendation for further checking+ }! _( Y. u$ e# E* L2 b: r
- 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
% R4 i0 P6 x6 f, G the names of the two files compared
+ x3 L6 Z3 X+ [2 l8 C4 O( _d) Leave the program (exit)7 j9 [  \  a" h) Q% o
The ProgramCompare class: (Total maximum 20 marks available)
6 J) J9 a: Z! c6 a. J2. 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)0 m8 U9 x& J6 \; n5 G* D! H
a) provide an error message if the files are not found or there is a problem opening them
5 d1 O& O' M# R* ]/ `b) compare each line of code
5 l  z# @( {" _( @; D! l. a# m9 cc) print out the lines that are the same' ^1 ]$ z8 V  `/ ^; U
d) count the number of lines compared / lines the same
5 N4 N' l3 K5 v" c3 AThe AuthorisedUsers class: (Total maximum 20 marks available)
6 J- m- g7 D5 j) X3. 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)
; c; W4 x, }* ~: K* l# A4. Provide methods to:" a$ k3 q$ S9 ^8 u9 _- J
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, y- }; J. s# K( l0 y; n
b) return the name of the authorised user
' u( r' s3 l% P: K4 ^  x+ M; E1 Fc) return the name of the department of the authorised user9 }' G, ?! Q! ]% u
Individual Data (Maximum 20 marks available)3 N' G8 y5 C. F7 H) k( i
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.1 \$ R# g' ^6 v( F6 D
Documentation (Maximum 10 marks available)
; |$ [/ r  {. L6. 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.
1 N5 L* n/ D0 w* V3 z' tBSA104 Business Programming – 2007: Assignment 2
7 a' C: E( |3 K3 e( `Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了6 a; x! `. b, V$ M! o
不过你要翻JAVA的类库说明。你有下载没有?! A, c% H6 n, }' u; j& b
查询关于对比的函数。貌似关键字是contrast,还有compare
) M4 b2 C' p; x: G
- G! P6 t# }( Y2 |2 d- G7 w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ d7 n/ D) U7 C4 ]/ R
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。7 E( m2 G& Q' {" l3 f1 H7 b4 P
可以下载到的 是 jdk-1_X_0-doc4 q2 [2 B6 w+ O) h. W  a) u

& G# G) V! f6 x& J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-29 20:18

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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