找回密码
 注册

QQ登录

只需一步,快速开始

查看: 982|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% M8 ~! k% x% |6 D& o1 X( M2 y" f ; r& E& T; |9 N D5 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 | 显示全部楼层
//*********************************************************************# v, K( Q0 T6 e, U0 D6 g
//  ProgramCompare.java         Provided by: DRS& C" G: h$ k2 k/ [% b. O6 L
//
! {# h, ]. H4 ?5 o/ b0 {/ l//  Program shell for Assignment 2
5 @3 c: h1 X% s: ]! p* H( w$ W//: W$ V: n, Z* j4 H" @
//  Compares two text files line by line
& d0 o8 D! f, M2 p+ Q  G//*********************************************************************6 Q' G! k4 `- C+ S; N" ~6 j
7 r$ f! y3 r' d, ~% @" E  U1 F, S
import java.io.*;
8 ?: l3 [$ k" r, O* w
" m; u0 d* ~6 k2 G; p9 F+ Y/ Ipublic class ProgramCompare! w9 O+ F/ j# S. d7 u; a
{
4 z: X) D8 B* L( L/ W2 D/ o        //-----------------------------------------------------------------
) p- d2 j2 |, c7 R/ T1 {        // Constructor' V% |& L9 y6 L! b* P& t  `$ X$ t5 o
        //-----------------------------------------------------------------' U7 W+ X% X6 N* Z( f
        public ProgramCompare()
% D% ~7 {% m! @1 X        {- z) H4 N3 n# L
        }9 n4 C! r6 y6 m9 N3 x
" `4 e3 U* i6 v1 q9 c; k9 S
        //-----------------------------------------------------------------
; s4 ~& w. I; u& E3 i        // Method for testing that class has been reached
2 {. ^* I: {0 ^        //-----------------------------------------------------------------       
. d9 e7 J3 a6 a+ d: s: n
* c+ ~; [9 Z( ]2 m        public boolean ProgramCompareReached()        
* ?: _. X/ a! J        {
: K8 l  k: l7 s) G9 G      try
$ K2 j, C! O7 C  O1 k9 O( F   {        
; x% P( T+ V/ H! G; G" C9 w1 F                        6 N( H  d( H" b# Q
                //********************************************************************  |) L! z5 F# g4 |7 p* j$ _
                // Try-Catch Statement is used to handle exceptions - such as file not found   x+ [: D" O5 u9 @+ T9 j* q# e
                // Reading the files will need to be placed inside a Try-Catch - just like this one!8 g6 n! {" C* I; N, G
                // For more information see page 534 of the textbook+ ]8 B3 E5 [& |; x
                //********************************************************************
' P# u! T6 x2 E# D" z# w                    
. P# E9 T1 L$ |0 N        }
2 q0 A1 Q0 ~% Q+ c- t7 @; I( [             catch (Exception ex) // Exception caught here and message displayed to the screen
/ e! Q9 R+ A0 S9 E          {' {/ \4 `  n+ K1 U7 w- X7 B; v7 W
                    ex.printStackTrace (System.err);
7 M2 W9 ]7 E# G$ x! t  A4 v           System.out.println ("Error message goes here"); // Replace this error message with your own          ; f! S, m  ~) ^3 q3 V. S
        }
/ Q& g( X! i. m  M0 Z                return true;. L/ v* u. b6 B! F. g6 N
        }
& @1 j5 [+ q5 K  d
6 m6 h* H" G* M1 x} // end of class ProgramCompare; ~6 q1 v" a' y0 u3 F0 r0 R

9 |5 \( Q1 ^# P4 t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ t' N7 m- {# `- l( p3 b//  ProgramCompareMenu.java    Provided by: DRS7 j5 S) {4 u, g( [# O; {, |
/// @, _6 i+ p( l2 Y/ ^7 M8 A
//  Calls AuthorisedUsers.java and ProgramCompare.java! \4 q1 U" C4 w
//
, j* }  {) Y# {6 v' l$ I$ w//  Driver shell for Assignment 2., ?2 K0 H+ }# p+ D
//********************************************************************
4 D1 g- y. }9 i) e+ ?# L& A; F' D7 Z1 m6 j" I
class ProgramCompareMenu" }5 ]* _% I; U+ P8 Q0 q2 l5 S8 e+ b
{2 ]0 i5 s* P4 x0 ?6 {, J
    public static void main (String[] args)5 p$ N  \& p( E% H% i6 b
            {
, C& S0 _+ d: r& y3 B2 L: z) T                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable. A, d4 \4 Y' \
                ProgramCompare reached1 = new ProgramCompare();
  g" y) b0 d* Q* N                AuthorisedUsers reached2 = new AuthorisedUsers();       
# T# l2 P% K( }$ C/ R* }$ z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 C' ?/ j! D6 }/ |+ g! f3 c3 |                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        : s/ O  ~! w8 n" _% Q2 T+ G
        }
# B2 v1 K5 k2 x( |) P}// end of class ProgramCompareMenu
. P9 w) t! v( L6 _
/ p8 A6 L) m# w* s4 c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 o* m' c9 a8 I, v6 w
//          AuthorisedUsers.java          Provided by: DRS
1 w: a" [7 u: e/ e  X//               
6 k+ o! ?4 m6 i) r% p" N8 s//         Program shell for Assignment 2" z2 ]' p) f) C+ S) i  O/ R' R& s
//
: u; j$ Q, b  |! T# f//         Represents facts about an AuthorisedUser
* O  ]: [# v0 r//********************************************************************
. }6 F, v0 m$ g# n  [4 @, q- w. ^, X# X! S' F9 S1 k6 |: B
public class AuthorisedUsers
7 b6 r# Y# }! D% S3 d+ r/ J    {" ?: ~( u0 S% c# t) k+ z1 X
3 [* [/ b& o/ F; L. G1 c! s
        //-----------------------------------------------------------------
0 o1 k# A; F! @- s$ u: V        // Constructor% N' O& j- Z- y: S
        //------------------------------------------------------------------ b$ M1 o0 K- f
; b$ l  l% V: D5 a5 L
        public AuthorisedUsers()% H% E. |  h: J1 j# M3 |' [$ ?
                {1 `8 f, u3 s  `: ]* g, ^3 s
                }. A  N1 w# J4 t9 V% Q' F# o
1 t7 E" ]' A) t+ c* U! [
        //-----------------------------------------------------------------% z  r7 f" x+ ]8 a/ W
        // Method for testing that class has been reached4 Z1 O* o5 e* [( h5 v$ y- t: D
        //-----------------------------------------------------------------       
% e3 b/ e, b: g$ x6 e        public boolean AuthorisedUsersReached()/ j  P. P( Z+ U& D: Z
                {
: u6 Z) z! W0 ^" J" X                        return true;                        & ]- F( R9 u% r% ~6 ^3 q
                }
  }4 ?6 j4 o- U               
. p4 b& S& s( Z, \7 q/ N5 A    } // end of class AuthorisedUsers9 I! ^) A, c/ B  z& G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming* ^0 C7 u. E: x) K
Shanghai - 2007
2 ?% C6 J8 L# Z! P; H( s# tAssignment 2
( i1 p( Q2 H6 Z- y6 [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). {& Z+ q5 o9 _$ x  g) O& V/ W/ i
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 j  k3 U) v- x* k6 ?
The staff must be able to:) c; ^3 ]- D, }; j
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.( F% Q6 [/ w! p6 n* T: N: h" r
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.
) B+ a" L; k: X The interface should provide a menu so that the staff can:9 x0 Z! [8 m7 y* z* Y0 o
a) Enter the names of the two Java program files to be compared
* g0 ?, N7 j' c  ]/ J For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! h9 w4 t1 [# [8 B! F9 E
** 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).% G+ {, o; r5 x* T, i: U% Q
BSA104 Business Programming – 2007: Assignment 2
$ n: I( m! K; {# j8 JPage 2 of 5
2 p" [" I7 D( z4 ?, Y  r5 bb) Print out to the screen all the lines of code that are the same
, M! Y; b% S9 B* N. x2 y8 u Include the name of the file and the line number of the code being printed for each of the two files
" F8 _3 c5 {. H; ?% Ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
) W1 H) `2 z7 d8 B6 Z) t7 w. W the name, username and department of the user5 }% S) ]2 A0 ]) _3 M" I
 the statistics of the comparison
. r9 K$ f! e; i* K. i' o9 U  p- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: w  \+ t7 n$ s
 the recommendation for further checking
. {0 S5 ^- V! w* S  j7 h- 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% A1 A% }3 r3 a' g
 the names of the two files compared4 z; G" w- ^  E0 b
d) Leave the program (exit)
# M  [% a: f. B! RThe ProgramCompare class: (Total maximum 20 marks available)
: C; q: _* d# W3 M0 o  O. q2. 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)
9 N) g+ ?. o6 }  v9 u1 T% {a) provide an error message if the files are not found or there is a problem opening them- G3 I3 }! R4 Z# d6 t2 ?* w
b) compare each line of code& W6 }; o# e9 c" K5 `. u2 R
c) print out the lines that are the same
* h% ^1 a$ g/ x- X7 y2 @- b( Bd) count the number of lines compared / lines the same: ]: x! a5 [( Y8 E2 n& w$ z6 `* t
The AuthorisedUsers class: (Total maximum 20 marks available); d  G+ P5 y1 C* c
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)+ g' {0 _% \. u& v. o
4. Provide methods to:7 P! I9 k" h( {  v1 Q# B5 A) S
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+ x$ K1 L/ D2 F# Q. n" c
b) return the name of the authorised user+ J9 F( g4 y. y; h
c) return the name of the department of the authorised user9 m5 D  K) h5 \1 e" {
Individual Data (Maximum 20 marks available)3 o7 e1 S9 R) Z% a% b. ]; U3 w/ b
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.7 A" R6 }4 A* T* W  H2 E
Documentation (Maximum 10 marks available)7 i2 g  q+ S0 C; P, R$ I' u
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.% `5 f( q6 m" Q) j2 x# U
BSA104 Business Programming – 2007: Assignment 2
6 e; Y/ ^+ J! MPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ b6 |2 ~% C: L! d不过你要翻JAVA的类库说明。你有下载没有?
% W7 {# [- |. K! n- A- S1 N# {6 @: S查询关于对比的函数。貌似关键字是contrast,还有compare, b  m& L4 H9 B$ o

& a4 f- a; @$ J* {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 W) l6 b- t3 G: V9 q3 W. m
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 \4 ^$ u! h( v: H( C可以下载到的 是 jdk-1_X_0-doc
3 K1 h1 B& }, C7 Z0 H+ M
; T( z0 S  R: D  l[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-31 03:23

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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