找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1289|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " R6 k \0 t6 f0 Q# a |+ d$ k% l- P7 Z" K6 |
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
7 k7 r3 B( I1 ]8 _" Q% T//  ProgramCompare.java         Provided by: DRS& m9 q7 m# @& |
//
" F9 e; ^& c# [: {: ?//  Program shell for Assignment 27 l' \* q4 Z. ?6 V0 E
//9 |; N$ r9 W/ A% e
//  Compares two text files line by line/ U7 p1 X) P' u3 m
//*********************************************************************- E" ^+ j4 j8 C- c7 K# A- ~0 _# }
" @7 }/ x: {* t. ^, h% ?
import java.io.*;5 Q& I+ W" N# C0 r
6 [' w( y6 V$ c9 H
public class ProgramCompare% p+ J& o" s3 `1 M* @
{
1 r$ |" G" `3 o2 R; Q6 p; m        //-----------------------------------------------------------------
; @4 A5 {& m: |) ?        // Constructor9 G* Q! s3 J& @- x& g* J
        //-----------------------------------------------------------------
+ i& x) k7 t) _/ C0 r3 o# X        public ProgramCompare()
4 b! m( b3 G3 J) m( L5 }3 t1 \$ P+ U" ~        {
/ h$ B* |4 ?+ Y% u- f) l- m        }/ r1 Y- ?8 \  K  T) y& @
9 `0 d1 k" V/ N
        //-----------------------------------------------------------------  n& w6 d+ f  V$ M, _3 w! u
        // Method for testing that class has been reached  _5 H! e" f% k& t+ i- R8 e( [
        //-----------------------------------------------------------------       
1 L& a$ b. c$ s: z) P5 z6 f8 ?& w  O" V" X8 C2 {
        public boolean ProgramCompareReached()        
4 G- l% t! g9 u( [        {8 h# {( i9 J; F" I8 p5 O
      try
9 K1 f# e, T- B/ I! Y   {        
5 v3 C' ?/ {! ]: k% k' T! ]                        & W4 Y9 R, M4 k5 X4 |; @% r' z0 C8 [
                //********************************************************************
- z6 N' B& R! [8 S                // Try-Catch Statement is used to handle exceptions - such as file not found
: g# g4 @& {' l+ ^                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ y% P) l: X! @8 t/ V% Q                // For more information see page 534 of the textbook
; {7 ~1 C" P; t8 A. V9 P                //********************************************************************% X# a3 f0 k7 \% J, i# X4 u' ]
                     7 X. H% O8 \% B0 e" W
        }
; d- l3 J* G- ], _$ C8 f9 J4 J0 @             catch (Exception ex) // Exception caught here and message displayed to the screen 4 U, \1 G7 i* q& T$ q
          {
8 F  U7 u; u2 l                    ex.printStackTrace (System.err);
. x2 k; Q9 [: \% e) t; Q0 _# Q           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 G4 F/ L4 v5 ^( B% d6 ~( P/ z8 X        }, p. S) y7 Y4 j4 y, z
                return true;
' ]4 s& m4 A0 `. {/ z5 ~3 {        }+ }$ u5 ~2 b  W0 {5 w; i

0 r; z& i* P9 C5 e} // end of class ProgramCompare
- M% ]; F: @$ W5 t
' n' Y+ H1 l( m# v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************( V7 t+ ^4 m0 Z5 v: ]& t
//  ProgramCompareMenu.java    Provided by: DRS
" [: O: D$ U, B  o1 W6 a8 @: r//- k* ], L7 e" N4 o/ M; s
//  Calls AuthorisedUsers.java and ProgramCompare.java
* h3 h9 P% ~  g+ W, S8 O# B2 `//8 j' w2 W) ^  U# [/ G
//  Driver shell for Assignment 2.
" x. F+ b0 L9 K: C  O( E//********************************************************************% o" i& I# c0 a" [2 r
/ C3 z+ m. J- _3 I( C
class ProgramCompareMenu/ h2 w6 c0 T. A7 n" ?+ V' \- ~
{8 l5 q8 S) ]2 J9 U: A7 H/ ?+ p
    public static void main (String[] args)
# C5 M" \! I* V" N3 e            {, t; e' O; K- m& f& g1 ]
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& n4 J; |! t  N9 J* S6 S) E3 z
                ProgramCompare reached1 = new ProgramCompare();
2 ^! {% B4 g6 J- a" Y; b                AuthorisedUsers reached2 = new AuthorisedUsers();       
( |8 ^& ?" i' K7 F- B4 [3 e( y                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
: s* l! i' z; p                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& X: O5 ^! M% N7 H        }/ q/ ^6 e- V! B8 v8 l
}// end of class ProgramCompareMenu4 b# `& e# d( U3 R: c" ]
- s* O5 f! q; b5 [8 o3 U; \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************2 T" V4 T9 o( e' w
//          AuthorisedUsers.java          Provided by: DRS
: U4 {2 o1 c) I! @! D//               
; o4 Z. T8 f! |- x+ X$ v//         Program shell for Assignment 2! w& ?1 ?0 T5 M% R
//) [1 l: b3 P% T: V4 a
//         Represents facts about an AuthorisedUser% H! p9 T6 K' W4 s' B) |
//********************************************************************  f/ A+ c4 H7 {$ s* Z# z0 `
, Q4 s* Y0 Q$ J: |) i* j+ @+ I
public class AuthorisedUsers
9 Q, Q) l* |/ Y% {    {
, t/ Q9 e0 d% i' A* a) h* [! f6 G: [8 s! X& }7 o& s* \9 W
        //-----------------------------------------------------------------9 P9 P0 t! A; F, u; x* h
        // Constructor
; z8 a8 a( l+ J* ?        //-----------------------------------------------------------------
. K, q" ?( K, T: Q; |0 O0 r# q5 ], G
        public AuthorisedUsers()
, U0 h$ r* e5 H4 _! }) }                {
) A2 Q6 i1 o/ j$ J                }+ W0 Y$ s4 J' k( d& P& Y

# ^$ p/ Q4 P4 g+ l' c- r" q        //-----------------------------------------------------------------
2 j0 {  E) Z& b' H5 s        // Method for testing that class has been reached
. u/ @2 R7 i. O& O& M9 p& O        //-----------------------------------------------------------------       
) y  ?9 N) t* E  R( D0 v: n& G- @        public boolean AuthorisedUsersReached()
, |9 j. }: ^, B8 {! ~, w                {
8 z% s( v+ s" G$ [4 l                        return true;                       
$ V! _2 G* ~0 s2 f/ R                }  K" J2 v$ [1 m* J& _' `# H3 H( S
               
, V! S4 U$ e) K    } // end of class AuthorisedUsers+ o* W, ]& ?. k6 C% L: {7 h( T  G& C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 {) I: _9 b8 Y2 M6 VShanghai - 2007
' O, k$ a, S8 a& D0 OAssignment 2
. u4 l+ H) E! M, b# ~+ |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)
  b7 }) _- _7 o+ C1. 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.* U1 l. e, n3 V) A- i  A  L
The staff must be able to:
! [6 a, L7 p2 f& B Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 G( o$ I' S" 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.
+ C" m7 j( x; H- }) U2 P- L1 U The interface should provide a menu so that the staff can:1 Q4 x- l. q8 G& g- {6 o! `: i
a) Enter the names of the two Java program files to be compared
  ?- u/ ^6 i' T& [8 N6 V For this assignment, it will be assumed that the two Java program files are in the same folder as your program." R8 S# E; P4 [5 E: D2 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).
8 Q6 [. y7 ~' _# ?" _BSA104 Business Programming – 2007: Assignment 2
8 N( L! i3 V& H" t2 fPage 2 of 5% X( W. H; [6 u  b3 }2 v! |
b) Print out to the screen all the lines of code that are the same
" R$ p6 e. n* ^1 t, w+ ]; D Include the name of the file and the line number of the code being printed for each of the two files" S3 i4 j' O* _
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared+ {6 t1 ]; A7 r, G5 z% S( Q
 the name, username and department of the user' r( B+ z$ m7 ^# k" ?% b
 the statistics of the comparison1 x) p+ T1 R5 ~: ~
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different9 \( z  b: o0 e  C7 X7 C. d
 the recommendation for further checking
( c( N2 n/ y! d$ o! K' D% A- 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# I: o, G) E. _  c6 |  S
 the names of the two files compared' P5 \/ G+ l# V+ _- D$ d; ^7 @% a
d) Leave the program (exit)
2 q! J/ [* i% Z( b) [; |+ }8 ~The ProgramCompare class: (Total maximum 20 marks available)  x* x" e& k: q( ^# j
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)
+ w- a- K% U6 c/ h# H7 sa) provide an error message if the files are not found or there is a problem opening them
8 G- Q) q; @  E+ y( cb) compare each line of code/ z) K( o8 X! t* l- W6 l0 ~
c) print out the lines that are the same
& K' t; V, f; \, X: a0 cd) count the number of lines compared / lines the same
6 U! \4 [" K: C' ?' B- c9 SThe AuthorisedUsers class: (Total maximum 20 marks available)" C: Z6 V0 l: o( r
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)' w, q3 ?% C0 A! |
4. Provide methods to:
" G' _0 K0 T+ h7 O0 i( |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
& C! f, I( _' R% e. c% Nb) return the name of the authorised user
, {2 V$ P; K" s: b$ }c) return the name of the department of the authorised user5 ~; s8 C( j/ Q% x  w; u' ]
Individual Data (Maximum 20 marks available)
6 _. v! g& @* N, L. t5. 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.0 S' ^  ^6 q9 |
Documentation (Maximum 10 marks available)
+ Q* C1 X  q' _- }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.! e* [  _  Z1 y
BSA104 Business Programming – 2007: Assignment 2- H$ Z$ ~; l' g$ ?
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. p" }6 i5 @1 |4 M不过你要翻JAVA的类库说明。你有下载没有?& Q% h7 N% e4 _- ?  ~% o6 u8 q1 q
查询关于对比的函数。貌似关键字是contrast,还有compare2 n8 X2 C2 W) m
1 V" ~2 g6 X  d" y/ P! S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; L2 D% |  m& Q# T& u) J, Q痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: }4 r! t9 _/ H+ `! K可以下载到的 是 jdk-1_X_0-doc/ F6 @4 f; K& ?4 y1 ~7 G+ U- }3 C

1 v6 o- T: i/ S+ U( ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-16 22:55

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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