找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1157|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 , p! }" B9 k: r2 R0 J g% }6 B 4 a# j- @1 Y$ K# j) Y# a! `
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; v' b: l! _+ {0 e0 L//  ProgramCompare.java         Provided by: DRS
5 V% i. s9 b2 R/ D//! N* W# U5 U) @4 n  o
//  Program shell for Assignment 2
' f4 C& J  ^. R- M0 T; B2 C$ D//* X# d# k. k6 t/ J
//  Compares two text files line by line  ~7 ]* V2 c9 L  O
//*********************************************************************
$ `* L* @% c. j& t& S# B0 s7 w( F$ V& x& e9 @1 V2 l
import java.io.*;0 L# _0 q+ d( {* ^" o9 N! ~
& |0 b: O$ W  p2 w
public class ProgramCompare4 L# f, s' i* N/ {' s% ]
{* y0 [- u- i$ ?
        //-----------------------------------------------------------------6 X1 }' e/ S& C* ^! b! ~8 K
        // Constructor1 F2 B8 `7 X) c
        //-----------------------------------------------------------------
5 L7 ^: e( E% o' O' \3 J        public ProgramCompare()
  q% a1 n3 ?- I9 s  t7 H* A+ }4 C3 Y        {
% h( o& \# n, s0 o8 I        }+ B5 Y$ m. H4 p& [& K( h

5 R8 h& ~3 g, ^  _7 G        //-----------------------------------------------------------------
: W7 L0 J+ r2 r  |        // Method for testing that class has been reached
  d1 s" {( g& V  n        //-----------------------------------------------------------------        : \4 F; i) O% Q" u$ U
* Z0 Z% J* h$ N
        public boolean ProgramCompareReached()        
! s  r, F) k+ h        {
' l% `: \( J8 ?      try 3 H2 Z0 d. M( j  f6 e+ F/ S
   {         : W7 p, [0 R7 Z1 d! ], j
                       
  Y& f+ q4 ^" y9 x                //********************************************************************" j# P# e# e3 L
                // Try-Catch Statement is used to handle exceptions - such as file not found 9 v0 o4 Y9 _+ F
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
2 p9 H# S$ [$ s- w2 R  A                // For more information see page 534 of the textbook9 X* u5 u! s0 p2 a# a  [
                //********************************************************************
( n; J+ |0 t( P; {" H! v/ |+ L                    
' I, a& E5 C0 c3 a2 U( r2 W        }4 N7 E* b5 i! o( ]" \! c
             catch (Exception ex) // Exception caught here and message displayed to the screen . G+ v; `& t7 z) I# a) m8 q* h, Y; W: c& P
          {
1 C: O/ W& S! T9 r0 S                    ex.printStackTrace (System.err);+ y7 S% m- N% Y
           System.out.println ("Error message goes here"); // Replace this error message with your own          7 g7 {' v! C7 h1 p
        }8 X/ u: q$ V2 e$ P
                return true;
0 {  c: C: @' A* J" z9 g        }# C7 r( }/ V3 G0 Z( d

( x9 g2 o' i3 A; l" P- j. B8 e% d0 g} // end of class ProgramCompare- {( d) i( E! K' @

. [! ~" O  p4 a' @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 T! g. L6 Z  E& L//  ProgramCompareMenu.java    Provided by: DRS
1 h& U5 L7 [8 z$ E//4 ?8 @! F" s7 r" f: Q# Y! b
//  Calls AuthorisedUsers.java and ProgramCompare.java
9 |  x" r. L7 p* C8 @//  j4 g& r( O0 ?% {
//  Driver shell for Assignment 2.7 n7 p0 x- k" `& c0 R" j
//********************************************************************7 q: c0 y4 x; W/ G7 c6 G; k
1 _+ o) C1 ]2 X7 |1 }% Z
class ProgramCompareMenu0 d7 v* A$ C8 Z) P# f
{1 v: y( v8 r0 o6 d2 z5 \* u
    public static void main (String[] args): ^1 h. ?2 k0 p7 R; r% ]$ u
            {6 G; s+ u: D. |# v3 M' D9 s# K
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 o  l7 G( B, ^& ?/ c  Z                ProgramCompare reached1 = new ProgramCompare();
; T) N- B0 g2 w% U1 l                AuthorisedUsers reached2 = new AuthorisedUsers();        ' q! B4 E3 m1 n
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  h* G' R6 H  a8 J3 g                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 R% J- @" P. l, W. S
        }
5 k) l1 P  S# P3 j$ [% Z}// end of class ProgramCompareMenu
; X  T# l+ l! L* _) w+ j1 n6 \
- B6 {6 _) ^; C0 d  F1 N/ G4 j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 Q- Y4 S- I( k$ f% o+ |//          AuthorisedUsers.java          Provided by: DRS
% @1 M' q) H1 ]/ p  ^//                / P# `6 h5 a4 ]1 y
//         Program shell for Assignment 2
% p8 K  D  Z* f, Q" S& @//
; j# k, c: f! ^& g' q9 Y; B//         Represents facts about an AuthorisedUser
3 e4 a( y& F" O1 Y/ h4 c- o//********************************************************************4 a" e5 y3 o2 z  e& Z
9 d$ x" q( v8 m4 L  Q9 A
public class AuthorisedUsers
6 `" n& _; b4 a0 O; T" C" ~2 ], Y    {
3 X; d2 R% ]. [' @, R: x* F6 H5 {* b! {
        //-----------------------------------------------------------------
$ y# o& f9 N" Q+ i( N8 V2 B$ f        // Constructor
; y1 S( N$ i, F3 B9 X        //-----------------------------------------------------------------
# c2 b8 \2 |, V2 Y* O  s; k% ?0 g" p) x$ i: |! s+ \1 B* G5 T6 W
        public AuthorisedUsers()$ `7 E4 v  z9 w& G0 J, S
                {
6 ]' F! C* b9 T) L( c  M: a9 U& u                }
# @9 ~$ t$ w! f+ g& @0 l6 Q9 l2 I+ |
        //-----------------------------------------------------------------9 s2 u7 T" L9 G8 m7 {) f
        // Method for testing that class has been reached' |; P9 q/ u7 g8 g
        //-----------------------------------------------------------------       
1 c: r  J! e* X2 B6 s- D+ b        public boolean AuthorisedUsersReached()1 _. {0 ^4 x# H' r' a/ S: s, X  s
                {
) h$ @9 K" f- H1 L$ J                        return true;                        - b  x! |+ w& |( r5 |: m, v0 }
                }
* N" ^6 u. W; a) N6 W               
, M! P/ m# _" `1 U/ T9 ?0 \2 i    } // end of class AuthorisedUsers
  ?: U6 p0 X2 o/ R$ X& S' Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ I) b; v) R- }; j8 y3 _7 Y' w
Shanghai - 2007! A: Z8 |) Y+ j1 \2 n1 K
Assignment 2
! x- ]8 {5 Y& e0 J- v' h; bDeadline 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)% ]- D' [; o0 Y9 F! Q2 O9 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." ]' t* H/ T* Q
The staff must be able to:
; M: E; P: d; q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.0 p$ i5 d, y; `3 {; m  _3 D- S+ j
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.
9 A; A+ c) G: m' V The interface should provide a menu so that the staff can:% \2 @+ z" j  s8 e( ?$ u
a) Enter the names of the two Java program files to be compared
; C" ?! k4 B0 p7 A0 F For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
" f2 J( k0 b# ^" c** 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).* P& I% [7 G/ X2 V
BSA104 Business Programming – 2007: Assignment 2
+ ?. t5 c  Z6 wPage 2 of 5
* [0 O0 X/ H; G$ W6 ]b) Print out to the screen all the lines of code that are the same
3 i" r8 g6 ?: l) c) B9 ]: a$ D Include the name of the file and the line number of the code being printed for each of the two files( c. e; F; f% ?9 f
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# L! Y" e5 h, D1 m the name, username and department of the user$ D& x( j! V2 b. I; x
 the statistics of the comparison
) s1 l5 s+ k" u! n2 l0 `- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 f/ Z5 p. M# r9 W8 ]
 the recommendation for further checking/ h: ?: r; v. @) L. ]2 U# b
- 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 closely3 k( r6 E* k( ~) M- V7 e
 the names of the two files compared8 L& X1 R: o: k7 s
d) Leave the program (exit)1 J& O$ W1 `9 f; s$ N7 O( _" o! z
The ProgramCompare class: (Total maximum 20 marks available)
2 K& \, q% Y* {6 W- n; y2. 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 K& z" @8 z  ja) provide an error message if the files are not found or there is a problem opening them
" {$ x4 k: S/ M7 ?& {& D0 {b) compare each line of code2 w# O* S8 f; m  X. K
c) print out the lines that are the same
5 ?! e* ~8 r- S( f7 v8 Pd) count the number of lines compared / lines the same& s0 U3 x/ Z. u! Z# w# R4 d
The AuthorisedUsers class: (Total maximum 20 marks available)
* l) \4 K9 O; |7 t+ c1 t3 @  X2 |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)! ^4 d; f! |8 B% \% u1 r( _
4. Provide methods to:8 S! |3 a( I; F
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
/ K- \  F' I% j( ~0 ^& c( s2 A# mb) return the name of the authorised user
7 b; `8 Z3 a' x1 U. z% H) G- `% Nc) return the name of the department of the authorised user. \# ^1 X" H+ k
Individual Data (Maximum 20 marks available)
! U; G% @, n$ i+ u9 S5. 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.; s+ j* o$ @, @
Documentation (Maximum 10 marks available)
  w' Y/ w- w4 W. d6. 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.
5 B3 G) s* d0 h8 BBSA104 Business Programming – 2007: Assignment 2
* M' ]$ J5 J  e0 S" VPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& R' h1 L+ H- B: a, t不过你要翻JAVA的类库说明。你有下载没有?9 t+ a% i& ?% C2 Z
查询关于对比的函数。貌似关键字是contrast,还有compare9 w' h6 t; V% ]  U' R; z

2 E7 C' p$ j1 D$ C+ D$ h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 z& l2 I, P+ A( m' \. q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。7 z+ ^! U5 [. r; Q& u8 {- _; B2 v
可以下载到的 是 jdk-1_X_0-doc* u  ?5 H/ m; D% U6 N/ \

# K0 s( C; c( l+ X0 n1 l, Z& _8 I$ K[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-4 11:15

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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