找回密码
 注册

QQ登录

只需一步,快速开始

查看: 989|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 q2 ~: C4 C5 _6 k6 ~ % v' q; k5 s6 ~- Z, Q/ M) K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************( c' X7 r. v/ l
//  ProgramCompare.java         Provided by: DRS/ f* a/ }- @7 X! T  Y5 g
/// w. V' W6 l! B; ?
//  Program shell for Assignment 2! D6 i9 ]; c/ q8 T4 E6 q
//; p; V3 L9 h( e2 z
//  Compares two text files line by line
' s# T+ L* D8 U# o9 ^//*********************************************************************# _! t7 y" L. q4 H

7 g7 A6 R# u0 o: G# {4 T+ ^6 Fimport java.io.*;7 C9 v: W* X: j
6 j3 g% F! U8 v& A
public class ProgramCompare6 _+ F$ z9 Z$ G# n8 `* N* _/ N
{* J+ p/ o! q* u
        //-----------------------------------------------------------------
3 G9 d+ [* r( ^7 ]+ L" G9 S1 _) \        // Constructor
/ e$ y1 Q1 e8 [# q% O) G        //-----------------------------------------------------------------( X! o5 R3 c0 c1 f: \* G8 Z* S/ v
        public ProgramCompare()* m5 y9 C- }, W& o
        {; `- u5 w" k4 t% t2 I
        }
4 ?- ]0 _3 Q5 Z# l4 t) A) c! M7 M
$ Z' Y9 \% U3 ^: U! y& t        //-----------------------------------------------------------------* f0 l, w7 p5 D
        // Method for testing that class has been reached" k9 g1 G4 m! q2 f8 V( v! C
        //-----------------------------------------------------------------        8 n; j. Z8 j& B& x  n' ^2 E- t

0 ?; Y$ ?$ `  c        public boolean ProgramCompareReached()        
" P: t0 Y. s3 C9 |  \$ u        {$ ]# W8 U$ g( o$ c
      try
2 v  N7 L# r- C# {, w8 @/ U   {        
& @+ o) {! D5 |. c4 v                        ( K3 D& M! d( t! ]6 X9 W4 E* n
                //********************************************************************
0 s& Z  y* M- D- A/ |0 q3 W                // Try-Catch Statement is used to handle exceptions - such as file not found
& \/ H! B  G' c; `) v, M# k                // Reading the files will need to be placed inside a Try-Catch - just like this one!
; B5 I2 k+ P9 ]; G                // For more information see page 534 of the textbook5 r, L0 {, V5 _& J
                //********************************************************************
$ P1 u" _7 k% I# ^                    
  K2 c9 x) S" g6 m$ h% B; L        }3 B5 s' T4 j8 d
             catch (Exception ex) // Exception caught here and message displayed to the screen   F4 m$ A* m- o
          {
9 r2 r$ y: A) V4 G5 |+ d+ b) [                    ex.printStackTrace (System.err);( N+ f  P' @$ _& s
           System.out.println ("Error message goes here"); // Replace this error message with your own          ; [+ t9 v% o7 _
        }
$ p2 c& e' C# e+ \                return true;8 d5 K; G9 Y+ O9 ~! J3 s
        }
* q7 k' J# u0 K4 R8 q0 x  l7 k% O* t5 t' A
} // end of class ProgramCompare1 M9 ~, \2 g* ]! l' W

6 i+ y2 \+ S8 d2 A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************5 [  e; k6 I; U# [* H  g
//  ProgramCompareMenu.java    Provided by: DRS
4 U- w6 e0 x. P2 Y; B1 B8 Q//
3 A1 F$ y5 a' v  B# |, @4 I//  Calls AuthorisedUsers.java and ProgramCompare.java3 H7 y. v' D4 m* W
//1 ^1 d% _1 S7 x5 q
//  Driver shell for Assignment 2.
) n0 ]& n0 b2 w$ a( y- F//********************************************************************8 x& H: S9 b+ V: R# i

. Q0 r% y& I# u+ Tclass ProgramCompareMenu
+ X- L3 L* U1 t1 _7 \( t' k7 q5 L{
9 [! k% U* ~. N  H& O: s    public static void main (String[] args)7 ?8 j' {0 f+ ^
            {% q( ]  m" u, B8 d( S
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable% d0 i/ }) k. \" c
                ProgramCompare reached1 = new ProgramCompare();   f" m) w: U1 ]" d* l
                AuthorisedUsers reached2 = new AuthorisedUsers();       
  h; h2 h2 I6 R0 S# `4 B/ k                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());/ ?3 W, Z6 ~3 f$ c$ Y# O' j7 _
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& b6 Z8 N* r3 u/ f* w7 b- E        }9 h8 f4 E# h5 S
}// end of class ProgramCompareMenu3 \. B* M. X7 R* i: E
$ a9 g3 J0 X2 Z) u7 W8 K+ [" H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- [# @) P: `0 b: R/ M- m. t' N//          AuthorisedUsers.java          Provided by: DRS: z) R( C1 D4 S
//               
" J. a, g/ A* q//         Program shell for Assignment 2; D+ e- o! X: r& v# j
//" U3 i* v& @( l5 i. g
//         Represents facts about an AuthorisedUser7 Y- f$ N- H) g) o9 Y
//********************************************************************5 i, b$ X# i/ E) q0 s; q% b# T

& `" \7 r3 Y5 F6 kpublic class AuthorisedUsers! J; M. r/ o& Q2 q' ^
    {" q( [$ {( L3 `6 P, q

4 s( [9 r5 T- i- U; ~% i, n+ }! X; X        //-----------------------------------------------------------------8 f- K) @2 J' X
        // Constructor
- J3 V6 d) H  r* h. e1 Z        //-----------------------------------------------------------------8 N; }+ ]" x0 ^, N, v8 |
; I9 T! g/ N( y
        public AuthorisedUsers()9 g# w$ ]/ e- Q! C' a1 H8 T
                {7 c9 r9 d) f+ B. `
                }' ^. k5 J! x) B% Q( |
+ e6 i" ?+ r+ T  d/ i5 G# l
        //-----------------------------------------------------------------
' x& ^- c- d9 g; y* z6 Z7 ?$ O        // Method for testing that class has been reached
; X, {6 L  a, x7 [) b        //-----------------------------------------------------------------       
% B7 V8 E" S# O        public boolean AuthorisedUsersReached()
# B- u8 I* S  c& x- E3 i; w                {& b, @/ l9 a, _/ G! y  {% B& }% @
                        return true;                        1 V  C4 J9 y7 ~" J7 ?  t
                }
% x! ]/ z9 s% Q; F2 v               
' A! x% R! S& V- s) X  K4 c& F    } // end of class AuthorisedUsers$ D* I7 V- |0 u& o5 ^0 g; W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
) t, c. m+ t) PShanghai - 20071 r4 i8 J: B$ G
Assignment 2/ L- G: m0 S9 n7 x) m3 k" d
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)3 l! h. H$ P8 E7 }5 @) {9 q
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.+ o$ B$ T; E, ]$ K/ M2 ]+ |
The staff must be able to:
1 J4 ^! p6 w! ~$ C2 q  q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., E" D; j; U* q  v, ~) O3 Q
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.
. e+ o1 R4 b4 d: ^9 } The interface should provide a menu so that the staff can:
3 S1 h5 ?1 Q$ Wa) Enter the names of the two Java program files to be compared
% H6 ~9 }# l4 m# d For this assignment, it will be assumed that the two Java program files are in the same folder as your program.* Q; B8 W% S" \; V6 v" A
** 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).
" a" ~) b% X' i: I# RBSA104 Business Programming – 2007: Assignment 2
8 z! c, W2 j8 i8 j$ O% B& m- B& qPage 2 of 5& J. d* r' i& \2 J6 D
b) Print out to the screen all the lines of code that are the same
9 J+ l- y; ?/ {- S Include the name of the file and the line number of the code being printed for each of the two files
& L& Q' ?3 \* _- e- xc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 d& T2 u( F/ q the name, username and department of the user) z0 H8 K8 q2 u( X% t( N
 the statistics of the comparison
* D/ ]# F5 J. {5 R5 {& [- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( ]0 [0 `4 a* F# A# S5 _ the recommendation for further checking9 Y" m# h2 i. r7 {8 y! `0 @
- 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 closely1 H3 H# C. R& N3 `
 the names of the two files compared+ U) `3 i4 s9 J& c& f
d) Leave the program (exit)
0 Z1 b4 S: ]; {, ]/ ?The ProgramCompare class: (Total maximum 20 marks available)/ G% o$ u+ Y& P
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)
) [: Z; d! S! e4 }7 Ha) provide an error message if the files are not found or there is a problem opening them$ P$ t: c& E( V% H
b) compare each line of code
# G5 I2 a5 V! s# Qc) print out the lines that are the same/ |6 z: s! H& t. [- S6 I
d) count the number of lines compared / lines the same
& }# l/ m) j- xThe AuthorisedUsers class: (Total maximum 20 marks available)" z1 k1 M; |) a0 U7 {; Y$ C7 Y  `
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)
" U2 C5 I  K+ n6 _+ Y: _4. Provide methods to:
* D( q: B. i9 w$ x( N5 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
0 E0 {+ }8 a- }( ^4 pb) return the name of the authorised user% E8 _+ P( y' g& \2 s6 U0 ]8 `
c) return the name of the department of the authorised user
2 ]# C2 _5 |  ^( V! n+ k4 WIndividual Data (Maximum 20 marks available)
$ O. P' @1 Z. P- m3 t" w5. 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.
4 t8 }* L0 r& [Documentation (Maximum 10 marks available)0 U! ~( S) |7 i- N; I: j
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.3 x. ?* p8 j  e6 ~
BSA104 Business Programming – 2007: Assignment 27 ^) ?% a4 x. C3 ?
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ ~# A5 f2 b5 R  {/ x& x1 |! s/ Z
不过你要翻JAVA的类库说明。你有下载没有?3 I: S* t: e6 \* U& d
查询关于对比的函数。貌似关键字是contrast,还有compare/ P# D" y1 x/ E% F. B

8 p: N+ I/ X* M! r, S# d0 K/ c2 ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) V6 B# e* h% T# U6 \痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% j+ N2 @  C9 o- h) i
可以下载到的 是 jdk-1_X_0-doc* e1 a* d5 J* \, C

8 Z% M: a# E; O7 G+ g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-3 02:15

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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