找回密码
 注册

QQ登录

只需一步,快速开始

查看: 973|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 R7 k3 `! N; p, ^8 @& ? + u* ?' j+ V& |. j6 C+ o0 r
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; ]1 e, H6 Q8 s' g$ ~* }+ i& f//  ProgramCompare.java         Provided by: DRS
$ p7 N9 i/ y8 k9 c//
$ g' ~7 ?3 E0 X  f& q//  Program shell for Assignment 2
& a! _- f0 J, @# C+ }//$ M5 P0 l; Y* o( c
//  Compares two text files line by line
9 ^+ O& g& L# K! c9 J  X//*********************************************************************
3 o  P; q9 E, v5 t: z- |! H, B' P7 f8 ^+ G9 E& q6 U7 t. I
import java.io.*;
8 z8 t+ W2 D- y" }' @) Z* C! B; f4 ^+ Y0 w( S
public class ProgramCompare7 C8 y" Y% v/ I5 s9 X
{4 ]0 ?7 {4 w' X* T
        //-----------------------------------------------------------------5 ?0 h  c5 ^$ f3 n$ k, a1 D5 k
        // Constructor3 C! V. l  o; `' G* @
        //-----------------------------------------------------------------) j' h4 s& `- _: |" U
        public ProgramCompare(), k2 l9 j% g5 f. u# t
        {5 H6 `6 M5 `# D% r# f
        }
) K2 {; }  H, w4 ], y4 S) R
  Z& q+ H9 ~2 h: o$ ]( H: I        //-----------------------------------------------------------------+ m- l% ~1 I5 E* Q* R: |. E
        // Method for testing that class has been reached) ]. t0 W/ O+ F% |$ j) H3 a
        //-----------------------------------------------------------------       
0 |2 ]6 k4 a8 Q3 ?: ^
2 |- C7 F* m1 A# h* [        public boolean ProgramCompareReached()         0 q8 Y2 y' M; o
        {
6 [3 O* A- o; ]8 |& d      try
! K8 Z1 P. n) D   {         $ Y) F3 r$ B/ v
                        ( x: n  V2 m# G' ]# B7 x; H
                //********************************************************************
" k# o  A, E, v                // Try-Catch Statement is used to handle exceptions - such as file not found " }9 U3 E0 O7 [0 ]4 G
                // Reading the files will need to be placed inside a Try-Catch - just like this one!: d3 u; _5 B$ v- K% F
                // For more information see page 534 of the textbook
" d7 k. {8 v2 g                //********************************************************************  u, Y2 y/ r$ [7 U) Q" T
                     5 e/ B- Y3 ~0 [  H2 g
        }$ u( ]+ ~( ]8 _/ S0 r
             catch (Exception ex) // Exception caught here and message displayed to the screen
1 `' T, Y& T& b$ L          {
! k. K1 w8 T' u  u1 N; q                    ex.printStackTrace (System.err);
) a3 \; z' z5 o3 B, n& i# m           System.out.println ("Error message goes here"); // Replace this error message with your own         
9 H0 T/ S/ S) d, ?9 ~- ~9 m        }
" ^% E  s# t8 X                return true;& ?' G# ^0 M. y# i" X( c
        }
, ~; B2 X6 Y/ i4 N+ Z
4 ]. X+ h6 q' @$ J} // end of class ProgramCompare3 U  f0 ^9 d' a, l7 z
. n* X& O1 B. j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' n4 |* c7 u! \. U4 v& S
//  ProgramCompareMenu.java    Provided by: DRS
( b, g& ?! E& N3 y9 m# r. d! ]//& e. ~0 I1 O5 a$ o6 b
//  Calls AuthorisedUsers.java and ProgramCompare.java
+ R7 y% `. z+ i//- Y$ `! {6 s9 R+ ?7 ]
//  Driver shell for Assignment 2.
1 `- N( V; c5 o* ?! t//********************************************************************+ ^; p7 h- R" R9 z. y/ k

" j! q( K7 }( {! V# qclass ProgramCompareMenu
; Y! k" r5 Y- o& k0 ^{
/ W5 e$ {* W. w7 `4 p$ ?9 b5 y    public static void main (String[] args)6 m+ I0 X8 \; b+ F! p- _+ t
            {% U. Q/ L4 `9 W( A8 f
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable" \' X" A* k# x$ g# Y: c- T8 j4 S
                ProgramCompare reached1 = new ProgramCompare(); 0 x/ g: b1 q$ ?# E6 y
                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ n% w; l9 `: \, h/ ~( H                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
( p. U0 A2 L, j9 _! Z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        3 n; ^: @7 F. Y! g& v% l
        }
' A  k% w9 U( U% _}// end of class ProgramCompareMenu
0 t$ b8 h+ l: @& F! T5 B: O3 P9 w4 L" n4 N7 e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************; E- |& e: M. p# A! W
//          AuthorisedUsers.java          Provided by: DRS
8 b7 i& C9 y; X9 j  o) ?//                , y0 Q5 {+ R- ?6 G3 C' u3 O" F- v
//         Program shell for Assignment 2
. m& s# h/ D; ^  e# y5 ?* Q//! ?/ h6 l- S$ r4 A5 g( N
//         Represents facts about an AuthorisedUser4 v4 Y& |( [  X& n0 m! w/ \6 \
//********************************************************************
- |5 |/ i# Y; [! @, w3 C1 y2 M& [6 ]
public class AuthorisedUsers
- \% o) u0 l! q# R( E    {
. l$ t- X& x9 r9 s' D+ v) {3 M" r# n5 X4 F: R: n" L
        //-----------------------------------------------------------------( N/ m! J7 P: ~2 I
        // Constructor
8 W3 N  t; l$ ^: h        //-----------------------------------------------------------------. W- q& p# r* j: S" f- I* W& s

# g0 |7 |( X# \$ X* F8 \        public AuthorisedUsers()
* U7 z8 L/ u$ J* C  X                {/ W5 l0 V+ @0 u( p+ D5 U5 b
                }
3 N3 R5 \, ]4 y8 d: X8 {( ^8 g) m+ J3 E  F  M0 r7 X0 p- ?
        //-----------------------------------------------------------------
# a2 N; D; l- O1 E0 N3 Y        // Method for testing that class has been reached- |' {- a6 A5 S7 Y" b6 F6 M$ V& o
        //-----------------------------------------------------------------        9 e) t7 d/ e! A
        public boolean AuthorisedUsersReached(). q0 D$ u2 f9 S0 [6 x9 `- N
                {
' y7 j+ M% h- `! S6 L! x1 H  s                        return true;                       
, x9 c3 H9 ]; [3 e                }/ U& H/ U- b% W' m: Y" w
               
  D  }8 e9 p/ @, J2 D. @    } // end of class AuthorisedUsers
, }$ t/ h# N4 @' H% ^1 S6 e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, n  ?$ M( {# b4 L
Shanghai - 2007
- H% n+ n$ X1 k- \# aAssignment 2
% ~" }0 v) v# CDeadline 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)
" Y! }/ `5 ]* X' m1. 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.7 D$ I  C; i5 y% e
The staff must be able to:
8 }  g  J8 J" {8 r1 }# s* u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 d9 v* j" u. g
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- |: k5 S$ Q) }
 The interface should provide a menu so that the staff can:
% O/ Z: ?, Y+ v6 F) a# Oa) Enter the names of the two Java program files to be compared, _  m( S) h# ^( b. ?
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 T) }5 a5 j( l* H/ g** 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).5 ]" |% S) S0 x
BSA104 Business Programming – 2007: Assignment 2
! b7 R* g# S! c/ HPage 2 of 5
) W  W, p# W$ e6 y( \8 J7 v6 Yb) Print out to the screen all the lines of code that are the same
" h7 u  ^" [  d Include the name of the file and the line number of the code being printed for each of the two files# R/ d+ S0 t5 ~( C, x- |
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 M; r# j9 h: a" r  K: R8 I3 |
 the name, username and department of the user) N' b2 H, Q2 t, `6 g' r& k
 the statistics of the comparison
+ G5 ^* ~+ Z# S+ H- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ ?) D' _1 `5 h6 Z- `
 the recommendation for further checking, z/ q& v$ I$ b- k  S/ R
- 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
/ {& U7 ^* l# f* ^ the names of the two files compared
+ J8 k- N0 B3 T6 Sd) Leave the program (exit)
& Q# F3 K/ C! K; j5 A4 t$ uThe ProgramCompare class: (Total maximum 20 marks available)
' Z6 I( N6 w4 o3 n9 G2. 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). ^1 k# Z* o0 Q# I
a) provide an error message if the files are not found or there is a problem opening them
! d! `& G4 W) n+ n8 Cb) compare each line of code
3 h3 ~' I3 p1 I7 ~6 m- f5 oc) print out the lines that are the same* a% T) r; t* t
d) count the number of lines compared / lines the same
, h6 {7 C6 p, R! Y' [! uThe AuthorisedUsers class: (Total maximum 20 marks available)
- r' f% T2 a" L4 c  m3. 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)
* ^( f( c# X7 b4. Provide methods to:
: _# z( y2 D" a6 \; [6 Qa) 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) ~4 R  y; W& U. }
b) return the name of the authorised user) i+ E# u6 d9 D0 T0 b/ z  \
c) return the name of the department of the authorised user
+ c/ x+ U3 Z, k$ n' N4 f; Y$ EIndividual Data (Maximum 20 marks available)
2 T. I5 j9 U. m$ k% e5. 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.
) F+ |; `5 ]$ m8 j  M: J+ @$ m! QDocumentation (Maximum 10 marks available)5 _! U" R# G5 C
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.  \7 _0 {0 s) S
BSA104 Business Programming – 2007: Assignment 2
0 P- U8 Z& m# c8 HPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
  j; ]  C/ x# ?; }不过你要翻JAVA的类库说明。你有下载没有?
* E  a, `6 v4 r8 Z% K0 p6 h( l  I查询关于对比的函数。貌似关键字是contrast,还有compare
3 k( p9 u+ O. R# T9 {
5 `  t9 d+ A0 ^2 z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- s; ^: w, I! p+ z& j" s7 w, ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
3 q- J6 \/ Q+ x5 Y可以下载到的 是 jdk-1_X_0-doc. t8 H8 T0 \' [- q* W+ r

, u# n6 x' t+ z& C' ]' }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-29 08:30

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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