找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1485|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 r4 z7 x! S* _: M ! `' L: @; P3 Z% W' o
回复

使用道具 举报

 楼主| 发表于 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 O9 u  `$ j9 E) W
//  ProgramCompare.java         Provided by: DRS+ @' l- C( ?2 `' o2 d8 u
//
9 Y. b- Y, ]5 n8 s//  Program shell for Assignment 2
9 x$ z1 m# C/ o1 U/ T/ e//
8 o, g2 g2 d" [. i/ J' V& b//  Compares two text files line by line
$ ~2 O% [( a6 R+ d7 Y//*********************************************************************
* y. {2 h8 B) `) t' \" C( o' V4 [4 E& o. u, y  U. u+ A
import java.io.*;1 q3 }* P/ r3 W5 d5 v
1 p7 @1 i# N  B! i
public class ProgramCompare
, T4 l* L( s8 j: ?{7 k- j3 J# [( C; s2 I
        //-----------------------------------------------------------------# H6 d  E/ }& h) ~9 r
        // Constructor; l( a- R% y2 p
        //-----------------------------------------------------------------6 Y( E+ a- l+ b( k% S: C; J
        public ProgramCompare()9 T9 G. G2 j! M6 j9 h6 \: W
        {
$ d! d9 U) ~9 E  H8 ?        }
7 k- `* K# k% D9 b$ n* ~
3 I$ r4 J, y9 A7 f3 `; r        //-----------------------------------------------------------------
! o* _3 E+ d1 c- o        // Method for testing that class has been reached
2 L8 X) I6 n) y, l) K, k% z, }8 m$ L        //-----------------------------------------------------------------        ; ~/ B/ H! C2 O8 r8 c* Z
8 r  O- v3 u. b, t
        public boolean ProgramCompareReached()         ( O; P! Q9 U  k  m, S) o2 h% f3 l
        {
. p  R* x: p$ ]! C- }9 h      try ( A. ?( S' A$ y; [( {* k) T# O
   {        
1 [( E" a, v, o$ v' O" q4 d1 }                       
# \0 m2 _8 X! m2 i7 \                //********************************************************************
* u9 T% Q  B& J3 Z3 h2 m                // Try-Catch Statement is used to handle exceptions - such as file not found
0 c4 i9 t& T! ~& ?9 W5 N4 f5 [' }                // Reading the files will need to be placed inside a Try-Catch - just like this one!* V4 O& Q% X9 h* k: E% a" B
                // For more information see page 534 of the textbook
  ~0 O& U% t! @                //********************************************************************
( p3 V( Y) F/ J. _- @4 X                    
% R' K  O, |6 K; Z6 J        }' a, m* S! q$ S7 l2 q( ?* E
             catch (Exception ex) // Exception caught here and message displayed to the screen
* ^, f& w- V, ?1 o          {' ^8 n( Z  j2 K" ~
                    ex.printStackTrace (System.err);
0 |; d  q( P, ~( X           System.out.println ("Error message goes here"); // Replace this error message with your own         
  C3 P# n) I1 S        }
' W8 s; o0 |& f: k6 K                return true;+ q% f/ Z% A, \* M. D$ ^
        }
; ^( u3 G5 v1 B- J. b  P1 W7 W3 Y( [# j- H0 w
} // end of class ProgramCompare7 z! B4 V8 J. q

$ F  X- }  F7 _  `' E& b7 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# j. D( A$ c$ _& Y. h//  ProgramCompareMenu.java    Provided by: DRS9 J: X( w- ~+ i. ^# X
//% O' ~" D3 [$ q3 K: k# \2 S% g
//  Calls AuthorisedUsers.java and ProgramCompare.java$ f) F4 J6 i( _: o7 n
//
( T" s+ [' \" h2 U! q+ a( ]//  Driver shell for Assignment 2.
8 _/ p& W2 f7 p8 p6 z- `+ q8 |3 H//********************************************************************8 A- d' g7 C6 c9 |" |9 n
% I. b' R! X+ C% y  S* l: o  Z0 \) @
class ProgramCompareMenu
9 x/ s/ {& t- H2 m6 N4 T{
: |& X; o' U1 h6 ~! u0 F6 Y9 X2 ]    public static void main (String[] args)
: B/ ^: R* T' h3 C) h+ w            {
' k6 C3 {. M5 Q                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 a- r- E  a; C6 E4 [                ProgramCompare reached1 = new ProgramCompare();
; f9 u0 J1 E0 s& p" e$ ~+ G6 M. p" k                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ X' Z$ F5 X5 P: N3 t                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, }' o$ R+ b, S, @3 a7 P. M9 p                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 d( S; d1 e! C9 j' C+ w6 ^9 ?
        }
' t% e# Q9 h/ e' {6 E}// end of class ProgramCompareMenu
; z# |4 U2 k9 u: v3 a: s# I$ y! _, F7 K8 s, I4 |
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ y0 u! Y  d3 F0 u! s
//          AuthorisedUsers.java          Provided by: DRS
1 C( A% r8 E' M1 X; {  b6 g0 d9 v//                2 I6 r, U( [1 B3 b3 H- y
//         Program shell for Assignment 2
3 G- f' c  b( J1 i//
. l; z/ s  z1 {' O, w/ H. l/ P8 J( \7 z//         Represents facts about an AuthorisedUser% X* W  M7 g" L: B9 b, |& ?
//********************************************************************
" G, m! h0 ]  K$ O. f; K/ h# X8 a9 l) j; U# Y0 @. B, I' F. d* L
public class AuthorisedUsers; e, t3 b7 g& p! A
    {, L2 g  P) j  K8 t
# \8 V0 [! c. A- |
        //-----------------------------------------------------------------8 @. \6 o! V9 @( @* ^  [" v8 R
        // Constructor
6 [$ J* T3 U! S$ ^        //-----------------------------------------------------------------
6 {. c" }# R+ H+ A5 v/ e% J, ^# L! r% e; D9 [* }
        public AuthorisedUsers()
4 Q" k3 @. t# ?) a                {- J8 p/ ?: F/ W7 k5 w
                }
# Z3 ?3 m$ [* D! ]% g3 R
: t. R( m! W- [* t6 }  X        //-----------------------------------------------------------------9 b0 A6 P; F; k8 R
        // Method for testing that class has been reached  H: Q1 Q/ x: M& _& p6 A1 k
        //-----------------------------------------------------------------       
4 E6 \8 E8 [2 ]- l% ^9 \  O        public boolean AuthorisedUsersReached()
% N6 g' g6 J) \+ Q7 |0 K2 w3 @                {  t9 h' k! ^+ H2 e8 h3 G
                        return true;                        + p' v  X: h- C& i
                }* V2 B) b6 [+ l+ E1 z" T; P2 {
                * f1 n+ g0 O$ E7 k, C# s
    } // end of class AuthorisedUsers
/ G' N) s3 J3 p. B: H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming' V# ?" m  ]! p" `
Shanghai - 2007% w: D, D$ y- N/ C% w. j; k
Assignment 21 M) ?5 n0 d7 w( v7 N
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): W$ ?$ Z( U% i8 B: L0 o
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.
' D1 M; D6 @: ?& \The staff must be able to:
" [5 A( A( A, L  T% B1 ~0 ~ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% X$ U/ b1 \/ T' u' R1. 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., W5 p  L. o# h4 t
 The interface should provide a menu so that the staff can:( ^. u7 O' A% ]" H3 `' K. ?
a) Enter the names of the two Java program files to be compared
4 v8 p" k1 p) s5 R" L/ @+ y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 m6 Y1 ^  B' Q, ?
** 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).4 I  T; F3 F1 C
BSA104 Business Programming – 2007: Assignment 2
- i  w. @- t! E; B+ y1 tPage 2 of 5+ `' G% F. j) E5 w1 _! Q% e8 h! J$ x
b) Print out to the screen all the lines of code that are the same
7 y6 X6 n2 d# _. h/ O* x Include the name of the file and the line number of the code being printed for each of the two files
# R) w) R3 G: @/ Oc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" R4 B9 r# h3 Q* F. \3 v
 the name, username and department of the user
& z. B; D0 y3 ^, j the statistics of the comparison
6 ?3 s$ F. p' o8 U8 w- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! L; a% Y/ i4 @. `( B& Y the recommendation for further checking% c1 l$ q$ t0 Z2 Z6 S6 r# J; T; w5 n
- 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
* X0 T2 ~  M% |& M* t the names of the two files compared* _) P" r+ d/ u0 ?& n1 O4 ?, m% L
d) Leave the program (exit)! v- J/ T2 E; O$ k  |) L6 H3 \
The ProgramCompare class: (Total maximum 20 marks available)& B) a2 R( Z+ F* M+ t& l& S
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)
$ e: a9 Q) z1 w- b, Ca) provide an error message if the files are not found or there is a problem opening them
7 g1 _2 E1 N4 Y$ e" N) `) Db) compare each line of code1 |# W" X2 v4 {. j
c) print out the lines that are the same0 j9 T* A% ?2 k, @
d) count the number of lines compared / lines the same8 ]( O  x+ o) K3 b% s
The AuthorisedUsers class: (Total maximum 20 marks available)
( p% v2 B/ |* k3. 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)
. T+ N, @/ f2 E7 v8 _/ d4. Provide methods to:9 W7 B  C1 X8 H
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
; z4 x5 ?  T- E) U6 jb) return the name of the authorised user
% c7 P. I" d% C- Z" ?& fc) return the name of the department of the authorised user4 }) Y. K% v1 M" d* C# I
Individual Data (Maximum 20 marks available)
3 g1 g9 v# m2 d5. 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.
6 `1 Z4 z# {2 K9 `% UDocumentation (Maximum 10 marks available)
" R7 Y. a/ i5 h9 o" I4 h3 p6. 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.4 n/ Y5 p& _6 I, i, {
BSA104 Business Programming – 2007: Assignment 2
! n5 L- l1 ?& [* v$ R# Y0 GPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了* m; n8 |( d, X% i# }
不过你要翻JAVA的类库说明。你有下载没有?
0 l1 Q* t9 ?( i/ L+ [+ G9 h查询关于对比的函数。貌似关键字是contrast,还有compare
- y& w) H- b+ t: i& X
& J! O3 b2 Z( A2 W8 C9 Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ Z7 W+ @4 ^" b/ A9 ?/ j/ n% }痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 v4 s7 S" E. z' e( I
可以下载到的 是 jdk-1_X_0-doc( p: Y. c* i( }$ G
' [+ Q; L4 w; U
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-25 01:39

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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