找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1802|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - W& `2 ?, C7 P , _) F" |% d. L, O, }. Z! P
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
0 Q4 }6 h9 d' c//  ProgramCompare.java         Provided by: DRS
% ^5 I/ p* W( \- q//
9 p, N+ F3 g1 u# N5 ^% R# E//  Program shell for Assignment 2
0 O- C8 e9 v( @  J& O/// g+ H- g1 o5 T
//  Compares two text files line by line% Y2 A; |3 ^; p5 G9 ~1 d
//*********************************************************************
. D1 I; q6 e$ v5 Q: u' m0 g0 D4 H* B7 s* _' X
import java.io.*;
# ?( W5 i5 D& j! Q$ i1 t( ~+ S0 b4 a7 @7 @
public class ProgramCompare3 F# d- Q6 ?" R, R4 Q0 A4 w& }; X
{
. @1 [. _( W3 V. |        //-----------------------------------------------------------------* f9 ~& N0 E! T% R) m
        // Constructor. l& y% n9 V8 o
        //-----------------------------------------------------------------, ]$ w1 a  \0 |( u/ b
        public ProgramCompare()
/ k4 N% k  }- D        {: c/ p* I, a2 [
        }
, R" t1 p+ h) {+ a# g  Q) ^$ X9 g0 w! p0 w
        //-----------------------------------------------------------------
5 ^# t: j, {$ B# a% z        // Method for testing that class has been reached* w, i# s3 n6 a# O5 O$ [$ m; \
        //-----------------------------------------------------------------       
8 x! o( {5 F- |1 D. F/ G) v7 y9 e. Z1 i% E4 t5 e
        public boolean ProgramCompareReached()        
- M. T. `* q& s% d        {$ S- w! R& Y. A
      try
( D9 y; q) n" H9 ]  J   {         ' [" t$ e! _& {  ~, m; s- [; m
                       
3 b0 v; e$ t) _  g3 d. N                //********************************************************************2 @5 y$ F$ L; c
                // Try-Catch Statement is used to handle exceptions - such as file not found
2 B+ ], g* J5 J7 j: o! j- g3 w- ~                // Reading the files will need to be placed inside a Try-Catch - just like this one!% M- \) ?5 l. a7 W. R
                // For more information see page 534 of the textbook
; @  \% ~* M) g7 Y' p) N$ g7 y; t                //********************************************************************2 ]! |; i) ~  k* o. G
                     3 d1 }$ o. t1 F' F
        }
1 c6 _! N" L4 }% ?) g& e! O& e3 O% u             catch (Exception ex) // Exception caught here and message displayed to the screen 9 N" Q& o& W9 d/ n6 m- \1 w+ Z0 y
          {+ o  I8 L' p, M6 n9 Y3 \
                    ex.printStackTrace (System.err);2 S/ c. R7 l* @
           System.out.println ("Error message goes here"); // Replace this error message with your own          6 T/ ^" o% E  w8 ^
        }& e" x  x& r9 V- D
                return true;/ a4 d! F1 S/ [) w& S  g
        }
: {  n+ Y4 _0 L! @7 Q9 q' N1 D
6 \% F# s6 Y- |/ Y  C+ K3 s8 @+ a} // end of class ProgramCompare( z3 ^3 [+ P1 j5 l8 @0 a' k

, @: O- Y( L7 e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& ^9 R" g' C1 d! p! A
//  ProgramCompareMenu.java    Provided by: DRS1 c: ^. L% I% K- i
//
- B- }: w! x2 x6 r//  Calls AuthorisedUsers.java and ProgramCompare.java
2 p# ]( h( b. }4 e1 r//
- M. _: {3 H. k4 k* G. v% ^//  Driver shell for Assignment 2.2 M2 z4 ^/ }# g$ z. p) `0 g2 C- u
//********************************************************************1 b3 _+ R+ J1 n6 X
1 z, }( }& J9 l+ G& U& P; K  H2 K
class ProgramCompareMenu* q& j7 V& y. W3 r/ n7 X
{6 g2 e3 F+ A9 U, d$ B
    public static void main (String[] args)
/ O" c- X+ L+ t& A            {$ j  U& G+ J+ w, x
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
  L% A/ g2 g  u                ProgramCompare reached1 = new ProgramCompare();
1 N5 Z3 y' q0 d1 Q! r                AuthorisedUsers reached2 = new AuthorisedUsers();        - e, |) h/ K, |0 e0 ^
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
* q, w' _2 T8 E1 R8 _# H- U                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & D' V! Y) m) m- b3 e
        }; X( H* B5 {/ l. Q, n1 ?4 V! `
}// end of class ProgramCompareMenu% B& {1 W% l+ V2 G; k5 i

6 G! v/ {# M0 f$ Z" U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' M9 S; B2 J3 T2 z0 M1 Q4 E//          AuthorisedUsers.java          Provided by: DRS( P5 P2 C( Y; e8 ^. \
//                " S1 x4 Y! F7 V8 z: [
//         Program shell for Assignment 2
1 p! t  y( J* @//
  l! z5 L7 E6 B//         Represents facts about an AuthorisedUser1 V; ?( h, O( Z1 K+ D
//********************************************************************* p" |- m; v: Q- S4 ]& R5 m- C

, Z8 O( Z+ a" h/ f; Kpublic class AuthorisedUsers
% X) s3 z% ]$ L4 W; l    {$ ?4 t6 a' Z6 \) ~2 k& C

9 \, _# Q8 T0 |# Q% `        //-----------------------------------------------------------------
$ }" ]3 Q+ K- e: ]  U        // Constructor
* C$ S7 ?! ^+ w        //-----------------------------------------------------------------
  P' y9 {  m/ x' t2 E% _5 z4 c9 ]  c- j: s/ M3 I
        public AuthorisedUsers()
9 T$ W5 D4 U: w8 Y4 J* x7 ]+ N                {
& u) Q! `+ r, e, G                }
- S+ w" E; y. i+ c
& G4 F: V+ V& i" }$ N* `- X        //-----------------------------------------------------------------8 Y7 |" B# s& x, W+ d7 f* P
        // Method for testing that class has been reached
4 d+ F" ~9 j  X, S: o9 w2 w        //-----------------------------------------------------------------       
: h2 N/ W" Z2 q        public boolean AuthorisedUsersReached(): a: j' G- Q6 e& M( O
                {& J5 N/ W# G, |/ I6 o9 r
                        return true;                       
* _5 P8 \5 ~6 H% Y) |                }
5 ]0 }9 y! k/ ^1 w5 _: E) ^% t                ) L+ `; u# T" `) g9 c! g
    } // end of class AuthorisedUsers8 ~4 j; D: ?4 C; M1 F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming- h, n6 l/ ^* Z: V+ u
Shanghai - 20070 l8 |& s! _( g" @) t
Assignment 2
& A8 A) p# w7 t9 i7 g/ K+ GDeadline 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), j+ y! L" T) D. V, V- U
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.
8 n" x4 B$ B) A: vThe staff must be able to:1 _# o8 z2 F% N& d* f# }; o, k
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ r, [# F$ u  S* R
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.' N5 l5 {* w. V& y9 |6 Z
 The interface should provide a menu so that the staff can:
4 e% [  a; B( j: [9 E# |$ Da) Enter the names of the two Java program files to be compared
) o7 f# R/ J8 S5 J0 U For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
" }1 z8 v9 s/ b** 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).  v  k" Z8 E; r$ f) R* N3 T
BSA104 Business Programming – 2007: Assignment 2
* ^+ _+ _1 j" nPage 2 of 5# l  o1 Z( a( y  g" U
b) Print out to the screen all the lines of code that are the same7 r5 A6 L) S; D2 @
 Include the name of the file and the line number of the code being printed for each of the two files
9 [9 v7 k% H; Wc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 @2 f- `3 j4 k the name, username and department of the user! t# l* f; _; R! F, n
 the statistics of the comparison. y6 o- C9 y0 |2 S  V$ Z+ ]) s% g
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: l$ n" H& a3 p% ?
 the recommendation for further checking' P( }# z+ j* x' w6 j5 A% j
- 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
  D  G$ i  m: s, k the names of the two files compared
8 m/ w. l) Y5 l8 \- T/ e; Ed) Leave the program (exit)0 W) o( S$ j7 y) L
The ProgramCompare class: (Total maximum 20 marks available)
/ u4 n7 _  n8 O& E$ J, G2. 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): K# c$ v+ O/ [4 E' `8 ^
a) provide an error message if the files are not found or there is a problem opening them
5 n- V/ ?3 }  e* }* z) _b) compare each line of code
" F6 ]  U6 x; D9 R9 P, W0 s8 zc) print out the lines that are the same* Y& T, Y; U5 Y  g: N8 S. i" J5 p$ ^
d) count the number of lines compared / lines the same  v9 s" h( N# q) F& R) l; F
The AuthorisedUsers class: (Total maximum 20 marks available)
0 J6 K# i$ n: Q6 y! @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)
" e% ]. V# `2 v4 ?( K0 D' k: k4. Provide methods to:
& M0 Z  I2 Y1 A* Q% e/ H& w! xa) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match5 f7 s$ I- t3 z& }
b) return the name of the authorised user$ }. o4 A. z( T+ W! s3 L
c) return the name of the department of the authorised user
! I4 _0 |0 [5 M2 R5 ^Individual Data (Maximum 20 marks available)6 A! x& w5 m  k( O
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.
7 G6 E9 C4 Q2 ~! hDocumentation (Maximum 10 marks available)2 g2 ~3 \0 ]9 {/ T9 L# z+ 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.# v6 M. l; V( l1 o1 n2 K
BSA104 Business Programming – 2007: Assignment 2$ Q9 O  o- `  U4 C& ]3 H7 U9 \% z5 g( f' n
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 b# n7 b+ k1 |7 I- y/ n' ^不过你要翻JAVA的类库说明。你有下载没有?
' f2 ~' _, y7 M' V查询关于对比的函数。貌似关键字是contrast,还有compare
+ T1 J6 T3 ~8 f" z, U3 {- u$ Y1 o8 D; b6 C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
6 D, J6 s5 c7 x! ?痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 K$ A$ h9 p, R$ q
可以下载到的 是 jdk-1_X_0-doc8 r; g" I' l. N/ Z
, `# q/ E2 G# M$ G0 p
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-5 16:09

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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