找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1869|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " G1 g; X4 _* Z 2 v0 j* Q$ R) J
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 N0 h' m, y9 @! [
//  ProgramCompare.java         Provided by: DRS
% m" f) u0 d. w//! x. j6 l5 H& t
//  Program shell for Assignment 2( V" o: |( C- u! J6 k) V# I. z! R
//
) z. q5 @2 i1 L5 j$ r: V$ y//  Compares two text files line by line
0 ^& x* I# ~2 g) S. h+ a//*********************************************************************
3 Y, }# p+ F' O5 ]
* n3 B  k" M: j# Zimport java.io.*;  I. K# _, O8 }6 n7 r

4 D6 R+ }& P+ Q, o, |' mpublic class ProgramCompare( k. d  ]! \/ F+ N' e/ D% b
{
9 e) ~2 x, c7 T1 {7 u  w& {        //-----------------------------------------------------------------* Z: q0 e' p  a' R
        // Constructor
$ b, K8 `9 n* P& Z/ r; u        //-----------------------------------------------------------------5 n3 h/ \4 q( G! N2 Z3 V: l/ i4 H) x$ N* }, ~
        public ProgramCompare()
9 H7 E" Z3 J5 y        {
7 M! d  p9 z9 V. e; q8 J" f        }7 [( `$ F: O4 N6 A
1 l2 F/ a- ]0 u- o3 i+ q% X' _
        //-----------------------------------------------------------------
: Q& D0 @3 @5 D" v        // Method for testing that class has been reached
+ Z% W& w3 f6 F        //-----------------------------------------------------------------       
# b0 W" n7 B" H3 ~# m
" w9 P# q: _1 X- Z7 O/ Z3 m        public boolean ProgramCompareReached()        
) H9 w/ G7 q' T7 J$ Y1 M        {
, q& d6 k0 E& \/ h8 b( ?- w4 L2 G      try
4 j0 m% Y1 b: t, k6 a+ b   {         ! {" E8 Z9 x) N
                        / ]. G$ _4 \% I+ ?5 j) {: z6 {& L
                //********************************************************************
8 Z9 \) v% K5 g; k: a9 [                // Try-Catch Statement is used to handle exceptions - such as file not found
) V) D' `# r2 y) @8 y+ W* s                // Reading the files will need to be placed inside a Try-Catch - just like this one!
! C- S- F' h2 N/ k                // For more information see page 534 of the textbook
1 E5 N! @& ]6 u) P3 m/ X                //********************************************************************/ V0 c: U; E- t
                    
3 N  w! ~' |8 }6 a, h) k( K$ \        }
5 Y$ I2 _5 t: V             catch (Exception ex) // Exception caught here and message displayed to the screen & c' I- d3 z% s, C# s1 u( ?
          {8 }+ b3 C1 {/ U5 H" R! D- H/ _
                    ex.printStackTrace (System.err);
& w: V3 W- p% d4 }5 i           System.out.println ("Error message goes here"); // Replace this error message with your own          ; [# |" P2 y; w
        }
1 u: Z( n2 ~4 n9 u& Y" |9 E$ g                return true;. o5 z# s6 v2 a2 i: z
        }
9 E  n% V# r1 _6 W( y
0 x( w6 S; f0 }, A} // end of class ProgramCompare9 t. T5 N' H. q

+ a5 Z# Y! h0 x3 b) q% E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  w" C% b5 z/ T; l$ Z, [
//  ProgramCompareMenu.java    Provided by: DRS
. \8 i6 s# ?7 U. ?2 N. \" X//- k3 L9 P/ Z: M- s: H2 q7 @; J
//  Calls AuthorisedUsers.java and ProgramCompare.java
1 R$ l! L: ]2 l# x" B! `+ l) }//( a4 u, u0 u2 ?9 P
//  Driver shell for Assignment 2.3 l, h" B# x/ e' _. g8 ?
//********************************************************************
& z, _) r2 C8 }  J8 q+ M/ e' h0 l, d& B+ u: S
class ProgramCompareMenu0 V8 r2 |) O2 m. F: i+ s
{
+ A+ c' g* I$ ^. \3 N    public static void main (String[] args)9 R: p" H; L0 P! F; Q/ o
            {+ v' |/ h# e6 R
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- D0 o- v( r* H+ o1 h' Y7 V2 ^9 [0 g                ProgramCompare reached1 = new ProgramCompare();
! F* U; ?/ i& g                AuthorisedUsers reached2 = new AuthorisedUsers();       
' }8 c2 B6 o5 C6 X& j5 e                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());! i/ D' j1 O' H  r) C' T' [! z2 ^
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ m: ]$ k2 y7 x& O( D, \6 X- f        }5 x) U- _' u) u7 Z3 d( f4 ?
}// end of class ProgramCompareMenu: R. L; ]6 |2 }1 |2 m
: w+ H1 r( y. \! @: X. s! P/ Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" |1 n" E! i* f( p" j
//          AuthorisedUsers.java          Provided by: DRS+ F" a9 M$ l$ M: a3 V
//                . `( ^/ V& y# i: h2 n9 h
//         Program shell for Assignment 2
" u0 h9 {* s: U, M8 a' `1 ]//
4 |1 G9 n/ H+ I//         Represents facts about an AuthorisedUser) `+ w  W9 M. _  A. c- R2 j5 [
//********************************************************************' P6 i( b5 K4 V) U$ v

3 y; X& o& x, K' A  x- opublic class AuthorisedUsers
9 M9 P! W# B& I4 |    {
8 y* R3 U; T  g( ~6 V1 a
7 `" {3 Z" q$ b        //-----------------------------------------------------------------
: F) Q8 _$ u& R! I) F- I        // Constructor5 o. l/ ?; O1 V1 O
        //-----------------------------------------------------------------
3 @; D6 |" a9 x: y7 J
5 m& t- b3 D7 t, ^: g* }, s5 b        public AuthorisedUsers()
  D. g2 a- j% X9 ^- a& x2 m                {
" i/ D* @$ V# z, K1 N; U. v( n                }
6 u1 s% B: q) D0 K$ ~
% E- `. T8 I* q2 @( v9 @        //-----------------------------------------------------------------
/ r$ C5 _0 k1 B7 K* S- t2 s        // Method for testing that class has been reached5 F( K* l. b, t; r: _7 s
        //-----------------------------------------------------------------       
8 ~3 f2 B* Q- ]! H1 x, u6 u2 X        public boolean AuthorisedUsersReached()
& w& ?/ Z8 `* }6 w. Z( K" Y" s                {
: n9 D  k- x0 E7 ]2 q0 {  u& I                        return true;                       
' y$ {- S. a  C# k! ~# N                }% O) u- }& t+ i4 I* ^3 B. e
               
7 A$ M$ a  h2 H( d& _. v    } // end of class AuthorisedUsers9 I( X: U/ \  r" Z6 N5 Y1 w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
- Y% [$ q5 u+ Q5 Z0 f' RShanghai - 2007: z5 L; q' l, g8 i
Assignment 25 \. x" H& f- O+ Y" D, U' n' z6 o! x, g
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)$ j: D" L9 c% ~) ^1 I6 U7 W
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.
9 M( E' v8 c* e% s. D& P) T0 BThe staff must be able to:
: x: Z7 R, t5 w1 U5 u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* @: q" c' ?4 b4 N% v  B5 |! a
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.3 q3 d" p4 i+ h. g) a1 f( p
 The interface should provide a menu so that the staff can:
4 q$ t7 U  _5 r- o& w* t5 Ra) Enter the names of the two Java program files to be compared0 R$ \9 E0 D' X' ?( |3 A3 v2 ?
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( O' _4 d/ @2 c7 N' Y) g** 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).
9 `  {1 h. M2 ]3 O' l% uBSA104 Business Programming – 2007: Assignment 2% w% \6 J4 c# Y) X* u# v# W8 w
Page 2 of 5
6 h  `2 V: \* j/ p/ h8 g2 ob) Print out to the screen all the lines of code that are the same. f, W5 b: P( [0 ^! P, D
 Include the name of the file and the line number of the code being printed for each of the two files, e3 c5 |5 y  L1 N, {# p+ U
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 z1 G: `& o3 \- C! L) g the name, username and department of the user
5 c: m7 Y7 e4 P- @$ u' q the statistics of the comparison
3 Z9 v& P  f) n9 {. b- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ r$ u& t7 @; h7 U+ l4 Q
 the recommendation for further checking
. ?$ B4 @2 \5 A- 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
1 x5 t" t8 j% }- r8 i the names of the two files compared
1 V/ D/ n# q/ d! P& gd) Leave the program (exit)! x. o, H2 `) I2 ~8 h& O$ k
The ProgramCompare class: (Total maximum 20 marks available)6 Z& X& ?7 z1 E& H- ^
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)
: o! r( f% K$ R2 ?8 c" f% Ba) provide an error message if the files are not found or there is a problem opening them
7 G# W1 G) g6 m3 s" \b) compare each line of code
! P" {$ L2 t2 t, f* xc) print out the lines that are the same
9 }7 z2 V8 z) S' vd) count the number of lines compared / lines the same
+ Z& |( S$ V$ F1 m, c7 MThe AuthorisedUsers class: (Total maximum 20 marks available)
. w/ `+ \9 u* G/ w: |* L: I3. 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): S  [. r; }" l* \+ a& P; U' ?
4. Provide methods to:
( i6 T2 s+ C2 ^; `" ^" Ua) 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: T* O/ @! u! e0 p: V9 C
b) return the name of the authorised user3 y( w7 a; t3 J) Y) c+ V9 U
c) return the name of the department of the authorised user
  g. W  e* r' I' E+ n3 xIndividual Data (Maximum 20 marks available)+ |7 W8 [. D6 v* i5 x# d4 Q
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.
$ u0 c* Z0 u: N/ J% JDocumentation (Maximum 10 marks available)! j- F6 ?  B$ ?0 n
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.
  J5 @2 i5 _+ k8 e6 MBSA104 Business Programming – 2007: Assignment 24 C9 W% k3 U+ R6 ?3 Q6 Z
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ P5 t1 U! j4 c/ q* U  y( W4 |0 J
不过你要翻JAVA的类库说明。你有下载没有?5 Q% P9 o# D# b& Q0 \
查询关于对比的函数。貌似关键字是contrast,还有compare: ]  j; M" M8 ?; W0 L

) ]" E1 J+ I# F1 k& H. ^9 J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* ~  Y( T$ D; y+ _) E: G0 @7 X痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。( Q* `/ Q% [3 K
可以下载到的 是 jdk-1_X_0-doc+ |  w7 Z8 h0 s  h! _$ _1 y- O7 A

8 h  q( Q. C% Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-12-2 17:08

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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