找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1461|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 . i! T% f+ _4 a# T. M9 ?5 | 9 ]6 X0 D3 \7 V' a+ z4 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 | 显示全部楼层
//*********************************************************************) y  M; I% @2 G# [
//  ProgramCompare.java         Provided by: DRS
% ~# I6 t$ _. a) T% ?//
2 {& W, I4 V' m/ g//  Program shell for Assignment 2
8 i! @! R( D- ?7 t* z3 }; i//; v1 g- a! ~, C6 a) d2 [# f2 y
//  Compares two text files line by line
: J9 m0 P9 N# i  s+ l/ \  L3 w//*********************************************************************
8 l0 T% B+ m* H% K5 ~9 L, q  x6 y" I! c
import java.io.*;$ T" [, q! a2 {6 s0 b2 K- y0 Q
# @1 ~* |3 H9 V
public class ProgramCompare
% |* a+ V! Q0 C" a4 a: {{
! u  m# m5 D" h: d" W& |3 R' G" U        //-----------------------------------------------------------------$ b: |% H# t! @- h, {
        // Constructor+ h& K9 E" ~+ o% S2 K! E- r. r
        //-----------------------------------------------------------------1 B$ D6 Q# d* D% O
        public ProgramCompare()$ Z4 T. M3 X. i4 Y! x) b
        {/ s6 {. l) m/ U
        }# }, z% F/ `) @2 r4 y: O6 u

- z) E5 B  V" \# D        //-----------------------------------------------------------------
2 @$ `! G& |7 x  ^7 v- Q, s        // Method for testing that class has been reached! L8 \4 G+ x+ a  ?  K
        //-----------------------------------------------------------------       
- M$ G, Q8 q1 q0 ^, F  E' l( l! U' a* ?+ G' m
        public boolean ProgramCompareReached()         7 w0 m% ~, G! \2 E
        {: E( @) f8 x. Z" o4 N, a) c
      try ! k, V8 i1 k: G- w/ j
   {         7 B1 V! s3 @+ ~: Y% I: D/ g/ E" Z, ]: i
                        5 Y) l: @! `: K
                //********************************************************************. u8 g. N/ Y$ m  k: c, D  x
                // Try-Catch Statement is used to handle exceptions - such as file not found ; o% \1 u( b! h8 R1 W
                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 a* R8 R2 e$ c3 N* I
                // For more information see page 534 of the textbook
6 A0 n; q# h. U/ E& b! D                //********************************************************************
9 |1 u, J9 a# R/ @& x8 K                    
) v! H- V/ G$ `( t* _. S        }
5 j+ Q0 i1 p3 m             catch (Exception ex) // Exception caught here and message displayed to the screen
1 J$ `  ?% i2 _7 i' Q  h          {9 y  a3 w/ i( O9 m3 O* [
                    ex.printStackTrace (System.err);
# l% k# a& y! N& F& B           System.out.println ("Error message goes here"); // Replace this error message with your own         
# N( B7 g7 b8 a0 c: ]* a2 h& L3 a) H        }5 C5 U+ t2 g9 U7 Z% t( U4 J" O
                return true;
  s5 j( B2 f; s        }/ }/ a9 }2 T/ ^% L+ k) h+ R

5 {8 N0 \) E; Q$ U. D} // end of class ProgramCompare
5 s5 x- a" y; u4 K, t3 a7 r9 I" n5 a9 Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ c  \# s$ m. d; g8 g6 \& A//  ProgramCompareMenu.java    Provided by: DRS1 M2 k8 S5 A0 j* u. q7 ?1 u0 n- F
//
$ J" Q9 R3 R3 D//  Calls AuthorisedUsers.java and ProgramCompare.java
3 \1 I) m% I5 N* K" }/ b//
/ C  |7 N( x; p2 O$ x//  Driver shell for Assignment 2.2 y! p1 C( {, _3 I, S* u' y3 Q
//********************************************************************
6 D: s$ ?7 @( C% b0 [
4 ?% k0 Q# j# `0 |, lclass ProgramCompareMenu
4 d  G1 t$ L0 P3 l% y* P. ^% G{
4 b$ M; X: `" r    public static void main (String[] args)
- o& f" w3 ^" Z( y# E9 }2 k, G            {' O/ V- y3 F% P
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& R9 {- M) `! j8 ^4 x. U* ?
                ProgramCompare reached1 = new ProgramCompare(); 9 S. Z4 k( M! u6 Y# `, b
                AuthorisedUsers reached2 = new AuthorisedUsers();       
# k  O( D5 Q9 W( ~" `                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());$ U6 T7 {- a0 g. P" W1 {- L
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          u+ |, g* t' d  ?3 }0 G: u" R
        }% P1 p. O; M. X" E! C4 y2 e
}// end of class ProgramCompareMenu
4 {/ j: _8 H$ L9 d- V' c8 V/ q$ W7 F; c2 {% Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
( D* T) U# B3 {) `//          AuthorisedUsers.java          Provided by: DRS7 c+ r1 k- \0 o1 X, {- m0 E4 `  p
//                & l' T, F$ d( l( u
//         Program shell for Assignment 2
. V" E6 y* ]/ V6 O' d1 p9 X//
4 {9 |1 K) P0 U1 D//         Represents facts about an AuthorisedUser
* g& E) I! U7 v  Q/ k4 y//********************************************************************- E2 F3 C7 K0 l0 v7 F% L) V5 v& R

! E* X$ t. J7 B0 n. n( y2 Zpublic class AuthorisedUsers
, e9 ~' K& [5 p- b% L. W! F' h% Z! d    {+ E+ Q. r) t1 k+ |- r8 i
0 m& k' |, m0 u; U
        //-----------------------------------------------------------------0 o/ k/ R- c% D! u; w$ Y# c* a
        // Constructor
5 R4 `& D, R: t' M* @        //-----------------------------------------------------------------
8 _4 ]& C; c" l, k4 |- b7 O  D
1 t0 [3 O+ u+ U! f2 d0 C, n        public AuthorisedUsers()6 z( B8 V% T, n
                {
0 @$ x$ W) M. d2 H& D+ j) F( o                }
6 O: F8 w: n4 u1 ?) \
; z8 J, C6 ]' ?; C) m& c        //-----------------------------------------------------------------
+ S# {2 L7 R3 T" |/ H. w* w        // Method for testing that class has been reached: n: L7 s4 u- V
        //-----------------------------------------------------------------       
& f4 D; q. M/ d% C        public boolean AuthorisedUsersReached()
9 a8 l/ L/ Q: E& @& `! S  M" @                {2 S1 a0 T/ _, e, Y7 j) o" @9 Y0 o: F5 y
                        return true;                        0 E1 Y: ]; k. P
                }
3 M7 U/ u  u, e  ^                , `: x$ U; _3 J
    } // end of class AuthorisedUsers2 f- q  @8 t/ F* s7 w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: A) ?7 G' J% }8 ?) p" PShanghai - 2007
( w& ?; O! A$ g9 K- o0 xAssignment 2
, _/ v" ~; x8 X, C% O; ~4 X6 dDeadline 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)
% r4 {0 J/ ]# L4 L* k$ K1. 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.
+ d3 D1 F3 ~4 `: t/ {The staff must be able to:
6 Z7 _# t/ m6 }% O9 G* W: N2 ^' S# f Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
/ ~) E5 {: Y$ `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.) p* Y* }% Y* a8 @5 k" B; z
 The interface should provide a menu so that the staff can:7 `3 W; S) _9 `' S5 |, N
a) Enter the names of the two Java program files to be compared
4 _/ n  F; S, ?; Y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ u& t* ?8 I: N: I
** 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).
4 l/ S8 e2 s! K$ ?, n$ JBSA104 Business Programming – 2007: Assignment 2
7 d9 G! l( \/ b8 _) d' m- l) TPage 2 of 5
* {% [' r9 a3 s) d8 T# L6 D& z$ Nb) Print out to the screen all the lines of code that are the same
" ]  o. ^$ q$ ~) | Include the name of the file and the line number of the code being printed for each of the two files9 R+ |9 b& j# G! [  K
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 A( j! ~0 X8 ~, P
 the name, username and department of the user
' C& t- E0 r8 D0 | the statistics of the comparison
: O4 S7 h* x3 P  e$ @- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& m/ r' u9 [3 c; P1 N% W! J the recommendation for further checking- y7 H. B. [6 }. h5 ^) 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 closely5 H. @1 U2 ?3 t5 }) `* m# u+ l' b
 the names of the two files compared
! ]) o+ R% n* H+ f1 pd) Leave the program (exit)
$ `  {( o* A9 s) F; O! |* cThe ProgramCompare class: (Total maximum 20 marks available)3 C( _6 c6 A& j/ _2 c0 Y
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 q, e& H% \7 A* R6 G: Y- `
a) provide an error message if the files are not found or there is a problem opening them
# j5 S9 S6 y- l0 h, M/ _b) compare each line of code' j% o% h2 n* i1 `
c) print out the lines that are the same# b; y* y# M  ]: g# {) a2 \
d) count the number of lines compared / lines the same/ G2 D/ a" F: R; L3 U# ^
The AuthorisedUsers class: (Total maximum 20 marks available)
0 N. g: g8 S$ E3. 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+ l% G  C" U& `9 P
4. Provide methods to:- I0 v3 ~/ X5 `% b6 [9 G
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- ^, z0 ~4 W' ~
b) return the name of the authorised user
1 n; w; v- b) z9 z$ A" }c) return the name of the department of the authorised user" o  F. v* b  \8 c" a8 H/ K0 j3 H
Individual Data (Maximum 20 marks available)4 f6 e0 @5 x7 o; r. r" D1 ^0 m8 N
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.
2 i4 V' m6 O9 rDocumentation (Maximum 10 marks available)
! }/ b9 m0 H: }* E) p6. 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., {  ]' v" Y+ [& j: w
BSA104 Business Programming – 2007: Assignment 2" z2 I  b0 B6 v. T, ]# V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 |* x7 k! R5 f4 x5 b2 g不过你要翻JAVA的类库说明。你有下载没有?8 J$ u4 W' a# D4 D
查询关于对比的函数。貌似关键字是contrast,还有compare
: u$ T6 c. C2 p7 x% m% E
& e6 v  H) H7 N/ _* U, j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& G" U. X9 P0 C) W( R# k; H  V5 v' }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; ]3 J% P+ s- @) c可以下载到的 是 jdk-1_X_0-doc  O9 b4 Z3 ^$ d% {0 W+ D
+ i8 B3 l: j/ w. \8 \& `( g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-16 20:58

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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