找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1240|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 ?. k! K- I4 J. T5 G( H6 C, ~/ b/ S / M8 J8 s/ d$ e. `8 b6 ^# j6 f1 ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& L; B2 \3 U* T# r+ {1 Z- t
//  ProgramCompare.java         Provided by: DRS8 F5 F5 U+ a7 P& W$ O* x4 u: B" ^
//0 M$ p/ I8 M7 C% V
//  Program shell for Assignment 2
# c) J% e  `8 I, ]  j6 Z//3 W- J( t& r* }& k! {+ R
//  Compares two text files line by line8 [/ w1 a- R' G3 Y. X. k& `; i- L
//*********************************************************************+ k0 g/ b- G* c
- M7 t  @# I: _4 I7 X
import java.io.*;% ?. P2 @/ o( s6 C" @
! z; k: X- |: m1 ?/ j
public class ProgramCompare4 Q# Q5 D4 @+ g# |* P2 u
{
$ Z, {# Z; f7 ~7 t        //-----------------------------------------------------------------
9 l" ?$ h2 R7 V8 ?        // Constructor
" W/ i# b# r' m3 [7 D! {        //-----------------------------------------------------------------
! I% N: p6 ~/ c' s        public ProgramCompare()
3 d* {) G5 |/ C) n7 l0 e        {
8 \: i; e# }$ b* S8 |        }
; q; x/ e2 D& G" S+ `1 r$ F$ b0 t1 j# Y% \. a
        //-----------------------------------------------------------------+ \# g) ~1 f. S4 b& {9 {3 T
        // Method for testing that class has been reached
" @6 M" d" \) F) |. G' o. l        //-----------------------------------------------------------------        8 z! h' Q% Z1 w& T" N

7 `1 @4 l, v5 V, x: R9 G0 U! R1 S        public boolean ProgramCompareReached()         : Z7 [( D* \0 C4 S
        {
) h3 X$ K" d2 }) S      try
% f- `; t& Z6 [# Z, a$ u   {        
( z# V$ U8 z' ]+ j5 J4 m                       
0 O" O, r- M/ ?                //********************************************************************/ C7 Q' t, B; ^0 A& |
                // Try-Catch Statement is used to handle exceptions - such as file not found / u( b' [4 T2 [2 M
                // Reading the files will need to be placed inside a Try-Catch - just like this one!2 f9 t4 `6 E; ?% C
                // For more information see page 534 of the textbook: H) D5 U2 n3 c  t& \) y. p
                //********************************************************************
% j8 {5 y. ^& m& y, x# h' y4 \. l                     3 j5 O6 E1 A9 \" m
        }  ]9 B0 a! |$ M8 s2 W+ F
             catch (Exception ex) // Exception caught here and message displayed to the screen
! T/ d5 ?% T6 m- U          {2 \& s' e$ h- p; F
                    ex.printStackTrace (System.err);8 m! x# G& I2 a  E
           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 n$ U% v5 ^# h" L6 W        }. I3 I! G( }4 m6 i# X
                return true;
8 L: g% N6 |1 D  [/ h        }
7 Y  c/ N. f% M! B7 L6 }) K. D: i$ J* }$ m; _" b- o8 i
} // end of class ProgramCompare& X' g4 r2 r2 e8 v# s3 ?

4 \6 E9 k" ^0 u+ D! W5 }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- F1 B2 K7 o+ S# L- \//  ProgramCompareMenu.java    Provided by: DRS$ \$ f6 C) U8 i8 L- h, I
//5 i0 |5 @1 p! ~6 [3 K3 x
//  Calls AuthorisedUsers.java and ProgramCompare.java( i+ T. e, `- h8 Y1 c, _
//" }2 W1 }+ q8 f5 k
//  Driver shell for Assignment 2.
+ ]% x" k, K; S//********************************************************************
% ~* X( I" }  A1 A# y0 x' t9 _! A' B- Z
class ProgramCompareMenu
+ c, ~9 n, l# H+ U  [{
5 j2 J# i8 s, X4 [% [) L; ~: c    public static void main (String[] args)8 ?7 B+ i+ Y& @
            {& N+ I. h4 P. T& P) Y* X
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable# h" Z- N4 N! r- X9 E
                ProgramCompare reached1 = new ProgramCompare(); 3 X$ E  J; }2 Z, y' M9 v
                AuthorisedUsers reached2 = new AuthorisedUsers();        $ C1 s4 r0 I) |
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- I' }3 E  Z6 C/ [2 g4 }
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# l4 t4 a4 X0 Y/ ~        }
1 l: S: |6 G  z/ z  }) z}// end of class ProgramCompareMenu
$ X9 ^5 N2 g* O8 q# W$ I: k! o9 ^* m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- _/ W' Q" g, c' s- n+ O4 R
//          AuthorisedUsers.java          Provided by: DRS4 v, {- k" A7 H
//               
9 Q+ L: U8 d. A6 i//         Program shell for Assignment 2
  Q* u! u2 V$ Z6 R$ b9 Y1 g  j//
% [" D2 f8 a% h% }9 n//         Represents facts about an AuthorisedUser" f% h! ^, \0 |8 ^
//********************************************************************
7 g$ m) {9 V. }6 ]$ v" N, G3 m- K7 |4 P' e0 c; o
public class AuthorisedUsers
4 r3 s8 U/ V" H$ T    {( h' D3 H4 T9 m2 z1 v# G
6 `7 f6 b2 P8 @- W. `: [+ \' o
        //-----------------------------------------------------------------& p' m- b: w2 ?( O
        // Constructor, _: E, _2 }/ Q5 x+ `- [8 X6 Q7 u
        //-----------------------------------------------------------------
& t6 V4 I5 @0 R0 ~- f1 c7 `
& o1 _3 {, x( K* q. D! z        public AuthorisedUsers()
* b6 Q: ^* m% p6 f8 ?                {
- ?) K5 `- ^8 P# t! _0 h, v                }
" S+ E, U, T: [5 A; k4 S3 {) Z  S, ^3 a+ m9 b8 }8 H- h
        //-----------------------------------------------------------------8 K: n6 x  D' g( Q
        // Method for testing that class has been reached
' }6 ?. ^6 v$ z5 D        //-----------------------------------------------------------------       
# b2 ]* M3 J: d% {% g2 E. {& _+ w# _        public boolean AuthorisedUsersReached()
1 Z; ^7 c3 \' \1 r4 A                {' {) P. e) k0 t# T
                        return true;                       
8 q$ _( n) |1 u- j2 W! Y                }
1 s' }/ e& d$ l5 ?$ i                . z8 _! s5 F6 _
    } // end of class AuthorisedUsers
+ @1 x; ?/ e) R4 m4 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% Y$ `$ O8 M) l& L1 ]* e( |+ k7 f  [
Shanghai - 2007
7 R$ E8 M( c7 s0 CAssignment 25 F7 s  \- n9 x. a
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)
9 {6 m" Q0 M/ Y. v9 G$ w+ K8 h1. 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.
: Q6 ^2 l! j2 u+ L# {The staff must be able to:4 f& Z4 q+ L2 ]9 p
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! T& `% L6 C% p( 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.# T( v/ o+ [5 S3 Q5 h
 The interface should provide a menu so that the staff can:
$ l4 D7 I5 ?% Y% N- u4 _5 r  [a) Enter the names of the two Java program files to be compared
% f: O  Z* d5 L( p4 M& M0 y# x For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( d* E2 B# H( J7 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).
! g7 E9 ^2 k: r2 x7 |BSA104 Business Programming – 2007: Assignment 2. n$ ]! l5 C! d$ `7 Y# ^6 C+ I
Page 2 of 5' x: S: d) t3 @& \
b) Print out to the screen all the lines of code that are the same! z% s2 z4 G3 ?% J$ S7 ~, C
 Include the name of the file and the line number of the code being printed for each of the two files7 L; }0 J9 A; O" s' e
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
) O3 m2 ~- o4 G' { the name, username and department of the user: X* N, p! N8 Q# b
 the statistics of the comparison' t9 b6 C# K# L! G2 e
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 q6 ]* w8 O2 h" Q" M
 the recommendation for further checking
3 F+ t2 Q% f) H) _( x' I( S; t- 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
6 F* D0 I" B, \$ E: h- o7 C the names of the two files compared
- R, u8 @) U3 V8 [d) Leave the program (exit)
% s9 k( N$ ]6 b$ x  u  }The ProgramCompare class: (Total maximum 20 marks available), Z1 S1 _6 J1 \6 T' q/ ]: v+ z# f
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)8 ]6 E8 a/ D* p0 Z/ A! [1 h
a) provide an error message if the files are not found or there is a problem opening them
/ Q; J; a" \8 J  hb) compare each line of code
' w  K2 h6 r/ b; F0 ?+ V+ ?c) print out the lines that are the same
8 `$ T! R! I+ t3 l+ C  h0 D3 |$ Id) count the number of lines compared / lines the same
2 t6 T7 Y4 X# b$ MThe AuthorisedUsers class: (Total maximum 20 marks available)* Z1 X4 ^7 R" h7 d
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)
. `4 Z9 _9 y2 u& w1 h0 I4. Provide methods to:
. u1 W3 X( o" g8 }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$ i9 o! y* E2 x. N
b) return the name of the authorised user
1 ]) P4 \2 Y  m* O+ oc) return the name of the department of the authorised user
& j% k# V7 Q2 a2 ^) Q, R# aIndividual Data (Maximum 20 marks available)
2 {, S: Q. N5 `; `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., C; T$ ]" B$ c" S" @: q/ z9 {
Documentation (Maximum 10 marks available)
! {1 E& K3 I  x. ]2 j6. 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.
1 U3 t2 C5 q3 h5 z/ Y9 ^1 F- b. ^BSA104 Business Programming – 2007: Assignment 27 g# c2 o$ |* l: v) ~  @% c
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 y. o* p+ D# j+ `) F9 x不过你要翻JAVA的类库说明。你有下载没有?' V3 {$ P% G+ w: d) `7 O# k; T( L
查询关于对比的函数。貌似关键字是contrast,还有compare
- `4 w1 |$ {- O5 f
" V$ L) |! ]6 w% g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; n; L7 [. `9 X4 y" t1 e痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* ], X& \% C; t! H可以下载到的 是 jdk-1_X_0-doc' I, _4 y! F! J# ^9 G
5 L! u1 S- X( E8 @9 I, c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-29 17:22

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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