找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1138|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 O0 `0 R M/ N- K* R 4 C+ ^0 J$ @0 w) i4 S; d9 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 | 显示全部楼层
//*********************************************************************
' L8 _% q' X0 t$ _0 ?//  ProgramCompare.java         Provided by: DRS
: G# F$ W) ^3 Z/ _: v+ s//1 ?* Y. J' Y; n* k! o  k% E
//  Program shell for Assignment 2
% N5 A' ^" w6 a5 k! O  F! R//' }6 C6 x0 V1 }' e' r4 Q
//  Compares two text files line by line! R. i" G; C9 c  n- S/ c/ J
//*********************************************************************" o8 _7 x+ O4 D6 x9 D* H

3 a. Z* w5 x: I; m/ \import java.io.*;5 s9 ?$ w4 [( m. l% U# Y

9 d3 n" [7 Y/ [% Q: ypublic class ProgramCompare5 h% r, `/ I% u
{$ _+ `7 w0 z+ D" y8 j# M/ i* J
        //-----------------------------------------------------------------4 g4 I9 K0 s2 h& [# _& `! G
        // Constructor
1 o0 z7 l  M9 L5 Q( p9 ?. c        //-----------------------------------------------------------------; R) F8 x" W4 Q6 W' L; v; Q
        public ProgramCompare()
- u3 M. d% y1 `" G        {- W4 y1 n) x) \" |
        }" |4 I6 z, ~- v% ~# H1 J, }/ K! l" u
, ]  ]& r% z; w+ ~/ W. q& c
        //-----------------------------------------------------------------' r2 ^: w* V* B/ V% V# ?
        // Method for testing that class has been reached
* @, X$ E; q) ?        //-----------------------------------------------------------------        8 S  T* S+ O' o+ {5 o: @
3 ?, O, b" \# q* _1 e1 i: ?
        public boolean ProgramCompareReached()        
# t. `6 J1 p" p5 ], `        {
& u  M5 w& R+ e2 F/ E2 U      try ! o+ h/ G9 F( t1 p
   {         3 [' I: ~3 W9 }" |
                       
8 |% U% Y. y3 H: W' T; ?                //********************************************************************
' `' g& r9 v0 i' |9 \& P                // Try-Catch Statement is used to handle exceptions - such as file not found   [# H3 k6 a! f- y2 D
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
# k8 U5 Y4 x  v6 K                // For more information see page 534 of the textbook
% i- z$ q, q! f5 ?                //********************************************************************
- w8 {1 s8 x8 g) G3 |                    
/ @9 e, v9 h" @5 ]3 e. l: O        }' ?! X' q3 J- |
             catch (Exception ex) // Exception caught here and message displayed to the screen
2 G2 |4 s9 t7 A# f% \          {* I3 T9 F3 e) x
                    ex.printStackTrace (System.err);  {, D# ?5 E) T. d; O
           System.out.println ("Error message goes here"); // Replace this error message with your own         
6 w& f( H$ V: c8 _$ e        }* z+ Z6 A/ y9 H3 v6 n5 e8 R
                return true;
+ t" i1 l+ S! R$ f1 ?+ X        }
/ e  z7 v) {4 M% \3 z& B
+ l3 D: Z/ @$ V# \* Q: s2 p} // end of class ProgramCompare+ d- G" V2 j5 s% V1 c" n

$ J2 o- U6 ~3 Z- t2 K6 d  c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" u4 z. N; @7 L+ Z3 N8 c" s//  ProgramCompareMenu.java    Provided by: DRS7 D/ ^* m; @5 q% `* S1 d7 D
//3 X. X7 G% p/ |
//  Calls AuthorisedUsers.java and ProgramCompare.java& R$ D* O- F! N3 H: E# y
//2 z1 u( s; S+ {$ ^9 v
//  Driver shell for Assignment 2.
, ~9 J4 Q$ j! z& p) c: n//********************************************************************
* T3 e3 D5 F( |( G
. f! G% f/ G2 `4 t. q2 f* e) x( H* ^class ProgramCompareMenu3 t& Z4 \0 l/ I9 ?2 ^7 o
{
0 j! a6 M  \) ^, ~) P! u' q0 i' D    public static void main (String[] args)
8 H9 g) W& p9 V            {: M4 O3 ?) q; D. n2 }& o4 A, ~
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! q$ _4 R* M0 Q" x8 ]/ T- `: u
                ProgramCompare reached1 = new ProgramCompare();
8 [* f# _9 i' @: M# U                AuthorisedUsers reached2 = new AuthorisedUsers();        . D$ ~7 X& j6 @4 X& ~
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  |5 Y! D7 R* _4 G                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          r1 V0 l& A! f' F3 M5 ]2 O! f+ n
        }) [* T7 o% ]. o  x. M
}// end of class ProgramCompareMenu
* [/ L$ R7 P, b+ s2 j  N: a
: P$ K( X6 I9 J9 I! L( G. N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************% z, G) X2 }: `2 c( p4 s5 H0 N
//          AuthorisedUsers.java          Provided by: DRS! t5 L2 c9 _' }9 m
//                7 B) C5 z- J: ^; j( ]' C# y
//         Program shell for Assignment 2
- i. C6 \$ L9 q1 B//  j3 G7 B" T$ B( S
//         Represents facts about an AuthorisedUser
% d# a) h7 d6 w& W+ V8 @7 }; g//********************************************************************! U" o; N0 w  A6 g
# D2 H) i2 G1 S7 J
public class AuthorisedUsers
7 ^. s6 e' a9 P3 _7 Z5 r! q    {
; Z* x' t6 s2 O& J4 p
2 e# l) }! e. L! Z( r        //-----------------------------------------------------------------
% C! m3 a% {# e+ j8 N' R% ]2 j        // Constructor9 n4 R4 R. H! X/ o; T+ }
        //-----------------------------------------------------------------5 A" ~& K( B, [9 x4 Y
) K0 D$ @; h6 F" N' y9 H
        public AuthorisedUsers()0 B% ^. |4 I! [$ X" ~
                {0 l! ~* V: S( R/ B8 I0 i' Z
                }- C9 [4 i5 ~1 {4 f3 ^
& J" Y& C7 |) n* j) J
        //-----------------------------------------------------------------+ d0 m9 `* {8 W3 d  b! f# m8 ]2 \
        // Method for testing that class has been reached
$ S6 D) v6 u: t! v7 o4 M& J, R        //-----------------------------------------------------------------       
- k& M2 e( _: g        public boolean AuthorisedUsersReached()* N& e0 V9 [3 i' ]) w% W
                {
- A$ z4 W  |1 l6 @8 E                        return true;                        . l) Q8 J1 y6 [  \
                }, Y6 B$ x8 s7 g5 h. y" f
               
8 G( Q2 W# d6 ^: M1 r    } // end of class AuthorisedUsers
$ V! B# p8 A  p5 Q. |* d//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
- h% l: i0 o/ F. tShanghai - 2007
! I4 G1 F' R8 [$ N% V: DAssignment 27 @9 F7 r( k  B% f* M5 x
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)) y9 C  e) J# ~
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.6 V+ t, z; e: O  G8 P- j
The staff must be able to:
. A$ h6 f& q- A6 x0 C% b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% b  p9 h) \$ O  f" L& [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.
" {+ Z! [1 I7 d The interface should provide a menu so that the staff can:' S/ G8 k( p# U. \! L0 X* W; Z
a) Enter the names of the two Java program files to be compared/ U6 T! L% z, r) x* ]6 p
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ n, @1 S8 |6 g* p* n** 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).
/ ~8 v8 y# X2 \( ^' G9 oBSA104 Business Programming – 2007: Assignment 2" p" @# r" j" C1 L( @
Page 2 of 5
, w6 m3 K# B/ |) yb) Print out to the screen all the lines of code that are the same+ `* k3 s$ Y  ]/ O2 d/ E
 Include the name of the file and the line number of the code being printed for each of the two files
, f; n, M1 t+ F7 [$ Y# t, s* jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
8 G7 b  w6 f/ ~ the name, username and department of the user
4 v2 H6 r& e, \2 n7 \ the statistics of the comparison) B) `- C7 r% n4 G* E9 a, l
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different3 x5 f% Q% h" B2 u+ f
 the recommendation for further checking7 g' _9 W; m# R5 O$ A# s8 X/ 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
' p5 l3 }! e1 J, @2 p the names of the two files compared/ w$ R+ t  ]- J3 @
d) Leave the program (exit)
# C( d5 q# i! U9 @The ProgramCompare class: (Total maximum 20 marks available)/ r5 i2 N' E7 g
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)
6 j0 o- d& K3 p# a- ya) provide an error message if the files are not found or there is a problem opening them
5 t+ p2 K2 O3 O/ ^b) compare each line of code( `* N! ?: m! ^1 N' C+ m
c) print out the lines that are the same
! l$ N6 B% X& o' {' ^4 bd) count the number of lines compared / lines the same2 t/ Q  S. D$ d: d& T  ]# f7 h1 l
The AuthorisedUsers class: (Total maximum 20 marks available)$ B: p: H/ f2 L2 h
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)
* |+ q+ Q! ?2 @2 B: R4. Provide methods to:8 ]- r' |6 ]4 D( L+ J' q9 Y$ O
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
: d( U8 L' r) l0 f% G& ib) return the name of the authorised user3 f- F1 k0 [" r% [. ?1 }
c) return the name of the department of the authorised user8 B$ y8 r! L) t8 M/ V
Individual Data (Maximum 20 marks available)
6 C8 ^. u1 z. z! A/ i9 r3 x5. 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.% Y0 h6 m& `4 c6 c
Documentation (Maximum 10 marks available)
# ]8 J' ?! q6 a6 Q5 f7 B# o! 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.
( H- j; H6 B. v* gBSA104 Business Programming – 2007: Assignment 29 M. ~/ J0 x% [- e
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 a7 t9 l* B& b( C( {不过你要翻JAVA的类库说明。你有下载没有?
2 D4 B7 l1 _: q6 z查询关于对比的函数。貌似关键字是contrast,还有compare& x' J- H. D. C% d, Y7 B) n
# U( n7 k- `1 \6 r+ X% M8 u1 q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- @) r5 |5 `- S8 t8 d9 M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. L$ r  [2 g7 @# f( x) y可以下载到的 是 jdk-1_X_0-doc6 Y' Z; O; i4 Y5 t; ^
* K1 ?$ l( e$ \5 }
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-24 07:42

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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