找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1396|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急- o1 G e* l* l* e0 z 7 ?8 M: {0 u) m
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************$ N7 Z( H/ @; _
//  ProgramCompare.java         Provided by: DRS% @8 q0 B0 S3 M" \% ^- u
//. F! e9 \- g0 h2 V7 O1 }! b! W
//  Program shell for Assignment 29 k8 o  m; U8 K4 `5 `; L3 h8 U: L
//
$ N, r8 b: \8 v6 X8 S  J//  Compares two text files line by line
/ a: p/ [$ r& \. n//*********************************************************************  s2 J7 P2 L5 U/ b! J% ?/ i

6 G$ h& h2 I1 u" H8 T8 F3 Himport java.io.*;
9 T2 X. E) y5 j# l: A/ ^* z2 k4 r% J
public class ProgramCompare
/ K9 }$ W% x' i{
* E  u5 k( q4 H5 F; J        //-----------------------------------------------------------------
( j9 x/ h; X' q$ ^" P        // Constructor
$ L& r7 {% Y0 ?7 X        //-----------------------------------------------------------------
, ]* N& F6 j4 M; n2 E        public ProgramCompare()$ \7 N* f# v: W
        {
" }% h  P) g2 y$ e. U' J        }- D9 R: j  w- Y/ M6 t7 Y. U* E
# _" l6 \" \) P5 T* N
        //-----------------------------------------------------------------
* h' t% r+ b* j  s        // Method for testing that class has been reached" m' a! U" S9 N5 J# Q4 L( ?: E
        //-----------------------------------------------------------------       
7 H  i( R0 Z- N: t6 A
/ e3 m3 i, \$ o. J        public boolean ProgramCompareReached()        
! \! H4 q( J5 q- a6 l4 L, ^        {: `, K; ~/ u" S" |! R, r/ v
      try
/ }6 [' i& _" b7 I3 W   {        
% c% ]$ Y8 d! ?/ q8 t9 k, W                        ) h4 p/ o9 T! d8 B6 O2 d
                //********************************************************************
5 A% j, _6 _1 Y7 H                // Try-Catch Statement is used to handle exceptions - such as file not found 9 L" E1 e% D" {% x- i; l9 w8 x
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
; }% V1 I3 I% y# x) C' C0 G                // For more information see page 534 of the textbook) [8 v' F$ Y  |: H/ v
                //********************************************************************) ~  j* f& J+ v* i" ?, h- ?, C8 X
                    
: o3 S$ S- z+ h( c0 i$ n' E        }
( Z& `' o: o: E             catch (Exception ex) // Exception caught here and message displayed to the screen 9 S& Q8 m7 ~0 y) `" J; X
          {: p) w8 w# b- k
                    ex.printStackTrace (System.err);
. d  y; @: }: Q* s8 |' w' L           System.out.println ("Error message goes here"); // Replace this error message with your own          ! F+ X6 X1 M# H+ D
        }" _( O: _. p& a: Y  O
                return true;
# B! G+ [6 y* j        }/ n7 f3 y5 K2 \! z  j3 ?' B

6 X& ]9 H0 X! b8 O9 U} // end of class ProgramCompare$ b+ i* I' t  d4 C" y1 a
6 u9 p5 x- Z) l. M' G, B; z9 G6 \( g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" P: F. i3 C8 j( p/ O' x( s& p
//  ProgramCompareMenu.java    Provided by: DRS
5 h: r! O: p5 j, ~//
5 N* G3 ^0 p. ^0 v//  Calls AuthorisedUsers.java and ProgramCompare.java4 |5 T. W8 a) _! b& N: s6 O
//) X2 {$ |/ N, Q# N3 _; z# Q: D
//  Driver shell for Assignment 2.
6 J: Z  H2 P: ?( I: `+ G- H//********************************************************************
( m0 R. @& P( Y/ L$ Q( E6 J5 J/ v! J; H, L4 Y
class ProgramCompareMenu2 G- l  N6 O1 D  \9 ~/ i: V
{" n7 P- i; Q9 e/ Q$ ?
    public static void main (String[] args)
5 ~; O5 n) l% Y) N: _7 i            {' P  Y6 u- J' l8 S* Y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 V; `! X0 U" |. ]6 ?% G                ProgramCompare reached1 = new ProgramCompare(); 8 V( [3 M% ]) l. |: z/ w
                AuthorisedUsers reached2 = new AuthorisedUsers();       
; c8 h' P7 }) C% c                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% w, L4 Y! p3 C* R7 Y& {! \" v( o; d                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        1 o& H% ]9 j" `& S' E( g4 m" U7 h
        }5 H5 H9 {- o) B) K5 b2 P) Z" o# a
}// end of class ProgramCompareMenu  f: Z7 o, f; X0 L, V2 X" M
. |" o! }, ]: I# k! S8 H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, ~8 l/ J5 S/ ]
//          AuthorisedUsers.java          Provided by: DRS
2 Q, h  _& A9 V3 t//                % p+ y, g: @9 G) V8 _6 [; {1 {$ \
//         Program shell for Assignment 2
/ d% u! a, K+ I) h//
0 |1 {+ ], N) Z6 x/ T//         Represents facts about an AuthorisedUser
  T% r1 h+ C0 H//********************************************************************+ A7 x5 o6 D" g% b

8 n8 u% G! |0 kpublic class AuthorisedUsers4 |' U  |  ?/ G8 x+ f
    {. g" A! l+ W3 _% M( a, ~! j

: H$ r5 M4 u, C( P3 [        //-----------------------------------------------------------------
8 T2 y* a# V* }$ U        // Constructor; `$ P3 q' M8 @9 {' ?1 `' n
        //-----------------------------------------------------------------
5 D) r# V7 v/ K" O# |; C3 F! U9 @; V( [4 a$ f0 A
        public AuthorisedUsers()4 y8 |5 {' ~4 m: g+ K4 A: p/ D
                {+ O: v4 m. N: X! B. W& g& X0 c+ M0 f
                }, f+ _7 t) m7 C2 m% I, L/ |2 L
+ q+ Q! Z0 q& a" t: o( H5 I# a4 ]- n
        //-----------------------------------------------------------------3 |9 E% H, e5 d' A
        // Method for testing that class has been reached
4 V( w# T8 c' C  p7 `        //-----------------------------------------------------------------       
% a. S( B& F  j0 J9 f8 B/ M        public boolean AuthorisedUsersReached()" l6 X/ Q4 ^: e; ]2 J) e
                {
6 G4 D. g5 V; t                        return true;                       
1 t5 J9 |7 e8 ~  [9 C; B                }3 ]$ W! y) }  h4 W) m, h
                ; _: O# j% O3 C( h* E: h& j+ k
    } // end of class AuthorisedUsers- ^8 {% e  Y; c5 Y4 }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" F% H) D/ g( w! X6 G& V' T( a7 o
Shanghai - 2007
$ e; I, B- f, ^$ S  k7 x* i0 Q# WAssignment 2& m* B/ w  A; D' {6 y. r" Q
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)
& i: p, o1 o9 h( _1 P- X1. 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.
( }  u0 I  s5 \9 P6 V3 h( ZThe staff must be able to:
$ P/ N. k1 m7 h! K Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! d9 `! h( U' T+ m5 j
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., W% h/ ~0 z3 x* X/ V
 The interface should provide a menu so that the staff can:3 e+ Q/ e/ H4 }( S
a) Enter the names of the two Java program files to be compared0 T; R- Q( E7 q1 N3 C
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! o# K' v( b* e. m4 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).
) y4 [% y: t) E4 CBSA104 Business Programming – 2007: Assignment 26 ^  i. b; _  O2 k( g
Page 2 of 5
0 P! I. _5 Z0 kb) Print out to the screen all the lines of code that are the same: Y. p- M9 B2 o' _/ p
 Include the name of the file and the line number of the code being printed for each of the two files
  {' M2 D3 A4 p% H9 l& S/ Lc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- m3 t8 M# g# ?& b, |' {3 X the name, username and department of the user& c5 c: ^7 ~$ i( I
 the statistics of the comparison
. E# n! N0 a) `: c2 m  g+ U" q) i- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ o4 j1 z; z# L3 ^
 the recommendation for further checking2 B! o8 v; Q0 P. B0 |# g" q
- 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  ^  Z; U/ X
 the names of the two files compared4 E' ]  i* b: H, P1 h- S/ O
d) Leave the program (exit)! d, w- D2 X( x% C$ o4 C3 }
The ProgramCompare class: (Total maximum 20 marks available)
# b' X: O" r8 L: {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)
5 l* u' g  S. q) p( z6 N# G8 {! ba) provide an error message if the files are not found or there is a problem opening them
" x$ _6 d0 q! |  P, H/ q4 f4 m+ @b) compare each line of code
) }7 W' X/ y" d; x" g% `0 O: U6 Ec) print out the lines that are the same
6 I4 |6 X# p! V  T2 h( Sd) count the number of lines compared / lines the same
6 k7 t4 y( k9 z  [& E. \The AuthorisedUsers class: (Total maximum 20 marks available)4 y8 s' Q( w0 D; v$ S! \/ ^
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): @' x! K4 y  e0 C  X. ]
4. Provide methods to:
2 y3 g% D% |6 S3 l1 xa) 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
" ^6 C8 N" _- fb) return the name of the authorised user
/ U! x( N3 O2 [c) return the name of the department of the authorised user
0 V; L5 W" F  J$ h  n- t' [Individual Data (Maximum 20 marks available)
' c" \$ a; e- _4 u4 G0 v% r5. 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.
. Q1 D; `1 t/ a( qDocumentation (Maximum 10 marks available)
  |2 z4 F& m* F0 D9 T0 v. I0 {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.
+ E  Z- c# E" j- N3 L* UBSA104 Business Programming – 2007: Assignment 2
6 h0 U7 L$ E: [! ?) h, S3 RPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ C9 ?. k+ {  i/ o5 m1 H4 I不过你要翻JAVA的类库说明。你有下载没有?3 ~# h, \% w7 G: Y5 _6 m
查询关于对比的函数。貌似关键字是contrast,还有compare$ Q9 R1 F3 y& C- u# y4 u' L
' A( w8 @+ _% i+ S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -) ~/ y9 w) [! K$ H
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ k( c4 n! E: i- x可以下载到的 是 jdk-1_X_0-doc
; ^( c9 T: ]' n# f6 E5 Q' v) r$ G8 j
; w. [: [9 Y8 T8 J[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-20 12:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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