找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1378|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( n. S; G5 I) _# [! D3 p 6 Y8 F0 K d/ M& a# V2 E5 e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ ?; K; y+ Z. |//  ProgramCompare.java         Provided by: DRS% }5 D: |& b" _  V7 |% c
//
% o8 u! l* [# ]8 I  m+ e//  Program shell for Assignment 2
& C+ a  E6 ^/ h* G//
! ?6 f0 K# W) l//  Compares two text files line by line& \; y  M6 ?: m, |  r
//*********************************************************************
$ x, t# |# s$ s2 p% e" C! T7 d0 i* ^2 u' Q; J
import java.io.*;
& u) P. A1 W8 _" s) D3 Q$ D
3 j, L7 Y5 P: bpublic class ProgramCompare
& R. o) y' A3 l3 c, W3 M8 x{
4 X6 `6 H' K% ?3 f5 q        //-----------------------------------------------------------------( ~! V- B2 i" K, m
        // Constructor
3 _2 u7 n3 w9 C% v$ S5 p        //-----------------------------------------------------------------0 ^% ]. u  h, [: d; G9 e) L8 K( X
        public ProgramCompare()
1 {$ l  D% \! S& @        {) k5 L# D8 `1 n6 x  \0 g7 \4 a% ]
        }: w' u& f; @7 `. ], u) d
2 b* K8 b: M: x$ R" @/ t) |  r
        //-----------------------------------------------------------------
' E; f- c& K- K4 Y6 T3 o- f        // Method for testing that class has been reached# S1 k4 j. [0 ?
        //-----------------------------------------------------------------        / O" v6 g2 W. b3 @8 `3 s
/ F3 V) ]& W8 p1 ?; Y) u
        public boolean ProgramCompareReached()         : E* V3 X2 `( t% ~- w" m
        {$ O% y3 Z4 \6 n; u
      try + G, t! @$ u; \$ w3 u! Y
   {        
! V; q/ m/ `: j8 i                       
/ m  C: E" r$ H# P6 _" M                //********************************************************************
2 ~' }# Z3 T3 Q1 R0 b                // Try-Catch Statement is used to handle exceptions - such as file not found
, l5 h3 @8 l$ A7 X                // Reading the files will need to be placed inside a Try-Catch - just like this one!! r, f( N. k' R2 {3 \
                // For more information see page 534 of the textbook  v4 _6 b2 k5 r3 x% u# X
                //********************************************************************
  {' c# Y: ^4 n' V- [; F                     8 f, }% H" {+ m# i# t8 `
        }
: }1 r+ _  d8 a7 S             catch (Exception ex) // Exception caught here and message displayed to the screen . Z  ]$ }; H/ k3 @7 N3 [" G
          {
8 [; Y2 E- s0 R! a. x                    ex.printStackTrace (System.err);% W" r) o' w8 l+ S* m
           System.out.println ("Error message goes here"); // Replace this error message with your own          - U* Y: V2 u& k+ K/ c$ L) b
        }! ]' {1 F" h; M
                return true;
: G# N, m9 p, H8 H% @/ ]( P+ O/ v( A        }8 V& X3 n# T1 n7 O- w

! ^2 E8 F# A# [. k& _% ?3 G} // end of class ProgramCompare  G5 Q8 ~2 b/ _) Z
7 i- L. s. k3 J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' m" `# |+ N: I2 ~% Y% o
//  ProgramCompareMenu.java    Provided by: DRS
& [9 A1 Z: {9 a, S2 s! G+ }( M/ W3 R2 U5 Y//3 ^3 ?: T  E4 n
//  Calls AuthorisedUsers.java and ProgramCompare.java) K  @8 M0 t$ G- A
//
7 N& h, x; S" c//  Driver shell for Assignment 2.5 |' }8 C# }1 O/ E
//********************************************************************  f! h. J. W, t' f

* T) t0 m: X- }. s# @class ProgramCompareMenu$ `9 d3 y8 l2 ^
{' a9 X+ A! g3 B. B
    public static void main (String[] args)
1 G% P  h5 t$ E1 V( |7 U, x! v2 u            {5 V* K9 I$ r$ Y6 ]8 c: f& T2 N
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
' N; E0 A" h# t; A" ^8 C                ProgramCompare reached1 = new ProgramCompare();
7 N( w0 E% N1 Z3 j6 k$ \                AuthorisedUsers reached2 = new AuthorisedUsers();        0 S2 L4 X# q) b% E
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& ~7 Y  N8 c7 d* l& L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 M3 e) t4 I1 U; ^9 h3 v* Z/ V  v        }
& X2 `( U* H( K3 B6 W  o}// end of class ProgramCompareMenu5 z' a7 a: J, a$ b% U3 i# i/ M
* }* [4 {/ _/ j( k! x1 V& `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: }) E% ~4 I0 k" P- W//          AuthorisedUsers.java          Provided by: DRS
: x; V+ }2 W6 U//                0 `) o* k3 `$ ]
//         Program shell for Assignment 2, \# ~" X, \7 ^3 I) k
//
! Y& H2 `& I6 B//         Represents facts about an AuthorisedUser
3 E$ q5 E; {' m. G/ z( W//********************************************************************
! W7 x0 i4 R1 Z* Z1 R9 ?
. |( ~% j+ ~3 m$ }public class AuthorisedUsers
  \* w) U: A( U  R    {  A+ E! ~; z+ {8 U

7 I4 k/ C$ [* L/ E        //-----------------------------------------------------------------
) k/ X' N1 B1 @: \; z0 v        // Constructor
& q& k$ ?7 n! r. q        //-----------------------------------------------------------------. M$ u! |; `( [) P1 z9 `% a: d
+ e/ v, t3 X3 ^. U
        public AuthorisedUsers()
4 D) {5 Q$ P- {7 m; r                {* @8 {; H- ^' `, S. p+ m
                }
  ^& B* O* l' S) k# A5 W1 D# D$ P5 z$ ~
        //-----------------------------------------------------------------
! X  I+ V# h9 N6 @5 c$ }, `" e        // Method for testing that class has been reached
; n) L+ N2 W9 B0 Y% V& Q! a4 Y        //-----------------------------------------------------------------       
7 o9 t, i; y  L/ [# M        public boolean AuthorisedUsersReached()
: y" Q4 B5 Z1 Y# U8 ?                {/ k0 S, m+ l* L/ {
                        return true;                       
  Z4 f/ d0 s2 {# V: ?! W" f0 }  ?                }
% N/ _6 b6 e5 p                . f0 A0 }5 T) q; I) T) Y3 f
    } // end of class AuthorisedUsers' t$ i  o8 _3 T4 D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! P' t$ A( S/ ~6 }9 A& e8 r0 ~* S, PShanghai - 2007" n3 M- d$ B) j# [( f  @
Assignment 2
6 U2 A( K5 u& X: g+ W; hDeadline 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). A% W$ V2 }. X; i6 c
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.
, C- R( s4 L2 E6 dThe staff must be able to:" V- n' H. c. d
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.- N+ `8 H1 I* M" t0 I. ?
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.* \; S0 d" p! t, U7 `3 [& x
 The interface should provide a menu so that the staff can:1 ^5 C' l# r4 R5 q9 m& E8 Q
a) Enter the names of the two Java program files to be compared1 [0 V. t7 z- H/ }3 D+ _' M+ d
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
) E( Z! b$ k) k0 u** 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).
1 W% \1 U5 D+ SBSA104 Business Programming – 2007: Assignment 2* l5 D6 `# y7 ^( f
Page 2 of 5; l) \8 E1 d5 B: U; A
b) Print out to the screen all the lines of code that are the same
' z' [7 V& H& M7 |% y Include the name of the file and the line number of the code being printed for each of the two files# m( W: R6 W# u1 K, ^  P' C' O( e
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
' ]! b7 S, L2 U! P the name, username and department of the user
- c4 s0 ^" @0 j0 Q+ t6 c the statistics of the comparison
8 A' L) e$ F& `! f# X! l$ |- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' \# o2 h5 `) X- J1 L the recommendation for further checking4 ?( \" P" u# d, i
- 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
4 S0 w! ~- l6 B the names of the two files compared* a9 e, r' N+ [1 a5 C% K
d) Leave the program (exit)% ?/ ^/ J" e5 r
The ProgramCompare class: (Total maximum 20 marks available)1 n* [2 C; X# G* N* b2 R. S% G  m2 ]
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)! p# ^+ W. g8 ?( r! p- S' _" V; }) m
a) provide an error message if the files are not found or there is a problem opening them; `! _% b% y( S
b) compare each line of code
3 H( g2 n8 Q" Q7 V  Hc) print out the lines that are the same
" n  C0 ]/ a% O  [8 nd) count the number of lines compared / lines the same
. y- |6 [; o' n% }& TThe AuthorisedUsers class: (Total maximum 20 marks available)6 O0 ]0 H. D' P" H  V
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)
$ V' N: N9 C4 J& }. \' \- w4. Provide methods to:: |5 |2 k6 }, u7 J5 E8 \
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
8 ?# x0 T, X3 F- w7 Ab) return the name of the authorised user+ U0 G! ]" d: R9 C$ c' e
c) return the name of the department of the authorised user
4 R' m5 B3 t; m, w4 C* t; cIndividual Data (Maximum 20 marks available)+ v- [1 j7 K, U* F+ [3 f
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.: ]2 Y5 e/ C/ N. X* n' x+ ~
Documentation (Maximum 10 marks available)
! f! e2 y1 U& P0 t8 M; Q( n  |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.  v4 X# S/ d$ {3 t$ h5 W
BSA104 Business Programming – 2007: Assignment 23 m' ]( Q' r7 H+ D( [! s; N) i
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 }8 v  D  A; d
不过你要翻JAVA的类库说明。你有下载没有?& }# }) ^  u; J3 _
查询关于对比的函数。貌似关键字是contrast,还有compare
% V/ `4 p: O+ }# l
( o0 S- P: r( Q- i* L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' x- \8 n9 U/ ~+ P
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. ]; Q; Z. p9 f0 @; k可以下载到的 是 jdk-1_X_0-doc
$ ^" `8 _+ J$ b; r4 A
! w* |- x, P; s" `[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-12 10:02

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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