找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1328|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ; Q/ D1 E3 Z; k) W; Y/ n# C4 T / T7 z) V+ M6 G/ _! {" q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************- r* b8 q0 P- B. ]. V
//  ProgramCompare.java         Provided by: DRS
, B" I' h/ ?9 s. o! ~+ e5 o//
0 S: c5 o7 U/ z3 ^4 m//  Program shell for Assignment 2
; m* {8 d. T0 B2 Q//
  i: V0 P4 o# V6 T4 h//  Compares two text files line by line
( a1 s! F9 T% s+ X+ Z//*********************************************************************; ~( D% c+ U' w

  B& W) c  H+ M1 W, M/ J0 i6 k2 U# Limport java.io.*;
/ q3 \  J5 n: c& U9 f" E8 @1 D3 F6 @2 l0 U4 I  w; k
public class ProgramCompare
( M9 u5 d( ?: g* x* P& E{
1 V' d3 |' M; I% J4 o$ k5 B6 {$ D        //-----------------------------------------------------------------3 E1 V2 i4 T% C: N' n$ _
        // Constructor! Y, x* r* [3 ^- R* K9 H
        //-----------------------------------------------------------------
) B# ~9 Q1 G3 s. I        public ProgramCompare()
, P  v+ z+ F6 i  S' y$ y        {
& F* r" o1 b; i        }5 s! A  O! m3 E# W2 G

* U4 t' Y; L' l        //-----------------------------------------------------------------! x! G# @4 f1 g7 {) L, P
        // Method for testing that class has been reached
) |2 J+ f* [/ X* D% G        //-----------------------------------------------------------------       
1 N3 j7 d5 b# f
+ ?3 _! B( ~5 I0 [, F; F8 }        public boolean ProgramCompareReached()         / J* G  E) ~: @6 X  F6 A' S$ N
        {- z6 I8 U5 M0 }0 Y: `
      try
5 y6 \: w* ?, z6 P9 J  z   {        
4 t$ l+ H) Q( L                        8 W0 @, |7 i7 \& _
                //********************************************************************
* A9 j* b0 ]" |( f/ Z/ M- x                // Try-Catch Statement is used to handle exceptions - such as file not found
  T7 l4 A8 A* u% e  b; ^% G3 X( B                // Reading the files will need to be placed inside a Try-Catch - just like this one!. u; d2 x" i* v& I6 w0 a$ `
                // For more information see page 534 of the textbook: o* z8 s" g8 e+ ~" y
                //********************************************************************
2 L4 h. u  F5 M7 l                     ) ]& o' v: e* p3 x
        }) P( l% \/ V9 ^5 I4 @+ T. X
             catch (Exception ex) // Exception caught here and message displayed to the screen 9 H+ M: B$ E0 t( j
          {
5 i# z( I: D. U: K  `5 m  ^# A                    ex.printStackTrace (System.err);
: @+ _6 u1 n" @           System.out.println ("Error message goes here"); // Replace this error message with your own          1 {+ w1 p, o( [2 B
        }
# E( q$ H6 K& s) P& R8 ?                return true;
% H+ n% l% U7 ~8 t, \7 I# ?        }
; }- {) ^; U+ Y! y; `/ \5 X. Q+ F' w) o- W7 ?
} // end of class ProgramCompare0 s+ q3 _- p$ P* b# q

( B9 a* O9 t7 e7 s6 B: w  A7 G& Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************: E, k( o. f4 i: k9 r9 g3 [
//  ProgramCompareMenu.java    Provided by: DRS
! s2 c2 ]" U2 K# F  N& `5 p  b# l: A//
$ ]# k$ Y3 |9 b* q//  Calls AuthorisedUsers.java and ProgramCompare.java
4 q; r6 y& d! P/ ?: Y# [/ w1 W4 w//7 }  e# t( \+ R4 W
//  Driver shell for Assignment 2.3 @1 o1 q  M0 M* r7 I' M+ H. g
//********************************************************************
8 Z( |& d; s+ o& ~- z9 d7 `( B+ P0 R) {4 ^' n7 V) w
class ProgramCompareMenu5 Q" ?% F9 p0 A! j
{& k8 {( H' G4 W$ |
    public static void main (String[] args)
' G  ?+ |3 f" I7 p6 [, f& T            {
) l6 b4 b" C4 P, u                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; v1 h1 t  M$ x$ R
                ProgramCompare reached1 = new ProgramCompare(); 7 z/ }! |4 b2 G6 T( q& h
                AuthorisedUsers reached2 = new AuthorisedUsers();       
$ F& T3 t7 {1 R+ e) [: Q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 Y; [3 O. ^" j  F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
: ^1 r% r! W  ^, b6 v+ I! _: F  t$ Q2 K        }- C9 ]  v3 C. ^# k; @" }
}// end of class ProgramCompareMenu
' y1 i8 W* G6 I( h. i; ?
1 b0 w. j1 z: X: C& }+ c; e$ k( Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" ]- Z  f, k; I2 F6 t6 Y0 z
//          AuthorisedUsers.java          Provided by: DRS
, q2 F3 b# n* M8 |1 U+ q( B//               
  A- m. F+ W& b7 G4 t//         Program shell for Assignment 2: b) B9 g8 w9 |* W5 R- b# t; ^7 S
//! d- p3 m2 ~6 g) F, g2 P' g
//         Represents facts about an AuthorisedUser& j4 P$ C0 G9 ?
//********************************************************************
) y6 g: b$ D" [# g; i* I& T7 K% L$ G6 q6 Q* m% K3 g# [/ ]
public class AuthorisedUsers
: c+ I0 V0 y  x" Y7 \$ I% d: R    {' Y+ c3 D8 t( `. G

' s$ m; N1 @2 A/ _  i        //-----------------------------------------------------------------
! E% U8 w5 H, Z: K* _        // Constructor: U1 R5 r* Z1 e1 u# K/ p
        //-----------------------------------------------------------------) m) Q' S* C+ C% X. G
2 \7 `5 ]* D! m" @1 Y! T2 U
        public AuthorisedUsers()
& _$ k+ J. y6 B+ P  ~5 s                {
9 D* F" W. l; J                }
% I7 b: i% o1 ]9 l9 A
7 R+ b- l( ~$ E        //-----------------------------------------------------------------# D5 c; _' L9 h- v' W$ {  J, F
        // Method for testing that class has been reached; |" f& O9 O8 |! h, \# X
        //-----------------------------------------------------------------        5 D7 x5 s* ^& N2 d% q1 n
        public boolean AuthorisedUsersReached()
" w) w6 g" u! f5 x+ ]6 H                {3 A7 u1 i" A+ u( C4 @
                        return true;                        ; E$ |+ g" ?9 k- F2 E, {2 N
                }
' k, ?( h( C- [) s                6 u. B! }# ]+ x  Y) R
    } // end of class AuthorisedUsers
9 w! N$ h1 f4 G! K' w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ \/ w' f! Q% _& q; K; y, Q% m# V  jShanghai - 2007+ Y2 |+ s7 V: t0 _" B. v
Assignment 2
6 i* ^, x" i; u: Y9 h  `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)5 f5 c* D! I- J/ z. l
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.
5 W  \$ k5 A( }8 A- B; T1 VThe staff must be able to:8 M/ ~' r+ ]1 }7 e$ K) y$ y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 i! \4 I7 w9 A1. 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.
8 Q5 O5 K/ u& S, n! x The interface should provide a menu so that the staff can:0 Z& P0 F" b0 [( N/ t  n
a) Enter the names of the two Java program files to be compared2 n2 b- @; a* l- m/ t" f
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 M& H! n! i0 I, x. u' a& y** 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 B' L" L* t  Q' e* \BSA104 Business Programming – 2007: Assignment 2; O9 b0 i2 K4 s+ Z3 c
Page 2 of 5( T9 F% Y6 R, K5 ^
b) Print out to the screen all the lines of code that are the same9 b( v  E4 I4 s0 d0 [9 D9 y* k, n
 Include the name of the file and the line number of the code being printed for each of the two files
  P1 {: X/ a: b1 c' v: t  Cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
' z0 {' T. v( [# ]% \4 e& E the name, username and department of the user" h4 W) e0 U! W8 w
 the statistics of the comparison
. O  s( y* T8 ?5 F/ K$ V" c1 }- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
2 S: F+ \8 C) r1 A% h, d7 ?$ e3 P$ x the recommendation for further checking- Z% b; N3 s$ f( j: j
- 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
' J: q  e, }7 Z/ e# ]6 g$ p the names of the two files compared
& c( @* e3 f! n7 K+ Y1 |  `7 gd) Leave the program (exit)
8 c! s7 U  d: F9 ]1 BThe ProgramCompare class: (Total maximum 20 marks available)% u2 A" B" ?! ?
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)
( l* \! M4 N# X! {8 ]. }a) provide an error message if the files are not found or there is a problem opening them& n8 E% k* ^/ n6 X+ r0 W$ M, r
b) compare each line of code
2 G0 u7 v% |8 S" u/ dc) print out the lines that are the same$ D% |9 F5 G9 T3 ?
d) count the number of lines compared / lines the same* w/ N( ]! `9 }5 A* f/ e% e% g! X
The AuthorisedUsers class: (Total maximum 20 marks available). f3 H" g/ p, T% H
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)
# k* b5 p- P8 h* Q4. Provide methods to:
4 V- N( Y( d3 E5 j1 ma) 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
: e7 M+ |: E) [b) return the name of the authorised user) B" o+ v: p; r9 H9 F$ N8 w
c) return the name of the department of the authorised user: y2 G( D7 p1 Q6 g
Individual Data (Maximum 20 marks available)4 P1 e  E3 V2 w% j  _8 u3 |6 w% c
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.
3 Q( h& ?6 ~1 W) Q" w2 [Documentation (Maximum 10 marks available)
2 N0 c# _& f0 ~  \% A( w) w% b6. 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.
# y' |4 E- q8 s8 j0 h1 ^6 S7 L& N9 ?; NBSA104 Business Programming – 2007: Assignment 2
( G3 J# Q5 R* Q, e) `Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ b- I- U" t; m不过你要翻JAVA的类库说明。你有下载没有?6 L" l! _) j/ J+ Z0 l  `$ t' g' R
查询关于对比的函数。貌似关键字是contrast,还有compare
- L+ N* Q3 }+ x% k
% n- J. K; Z& G* `  _5 w1 y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -- t3 G. s1 k8 ^3 I4 ?% ?8 s
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 c7 i3 s  ^0 k1 c* r, a' Y7 x可以下载到的 是 jdk-1_X_0-doc
' Y% w/ q, O1 f( b3 `! I' F  B# W" k9 I) c% w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-30 13:06

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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