找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1476|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急* _: D: S) f! h: F6 t9 s& Z ( I( H5 Y. g4 y9 B( C! U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************. g7 a" @+ ^6 N9 W( d' D) Z
//  ProgramCompare.java         Provided by: DRS6 |% m2 `8 r8 A" u; {& [, C
//3 _4 l) ?; I5 q* Q. L- s5 n0 F
//  Program shell for Assignment 2' B. j( ~' J3 v" t" f. }
//
& {: n0 ^  C- e4 W; Z//  Compares two text files line by line3 L4 t- K" ?9 M9 ^* F
//*********************************************************************
( n" T9 j, y# \1 B5 [% F
8 C7 h+ O% c( x- A, {3 bimport java.io.*;& S  r! _7 g- a+ n0 i
4 @- G7 B+ s3 I+ n! Y
public class ProgramCompare8 I: E+ n; A$ L- ~  O
{6 C& ~) ?) G) @' @& P& o+ B) e/ l
        //-----------------------------------------------------------------
0 k3 v* \5 f" Y/ ?+ |        // Constructor
2 m8 g$ M4 ^+ _, m- M- m        //-----------------------------------------------------------------, G& r% s% d3 ]  P" U$ P6 g
        public ProgramCompare()0 S6 V2 Y; o1 s) J+ |3 i& e
        {" U* Q6 f# T6 P! o$ R
        }6 ]2 u3 ^! S6 J$ t+ L. X, ~  Q
& }: t% m: X3 i+ F
        //-----------------------------------------------------------------1 t( h0 d7 }1 L4 a# Y; {- B
        // Method for testing that class has been reached
6 _" ?$ _6 [4 w' z9 K. E9 F6 R        //-----------------------------------------------------------------        / p0 h6 K, _  {( a5 O/ O
4 W8 z. p5 x" Q0 ~
        public boolean ProgramCompareReached()        
0 ]- ~8 {2 O5 @$ T* ~6 N& q' Z" A4 N        {6 t; S. f, A6 z
      try
- A* a& M) l4 @: K   {         5 o- D( i8 H1 z2 I% L0 V
                       
+ Q; l' d5 a  f3 o                //********************************************************************4 I+ u2 H8 D1 v# d+ m
                // Try-Catch Statement is used to handle exceptions - such as file not found
3 g( L/ V4 ^2 o5 Q' g, @% q                // Reading the files will need to be placed inside a Try-Catch - just like this one!, L- l4 S' g( ]/ B  b
                // For more information see page 534 of the textbook
2 b, |/ h0 e) \7 f4 M$ G                //********************************************************************
8 s5 z; {- E* y. I& J                    
8 {" c; s; }2 N) g" \. i        }) q" r% M& Y1 ]) d+ u, c. Z
             catch (Exception ex) // Exception caught here and message displayed to the screen " B, N8 ^: |" j# d3 }
          {
- l+ i( W! t% F2 H                    ex.printStackTrace (System.err);
  e" S8 C0 |& A1 j; ]7 G/ e           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 E1 Y5 |. N* s1 s* y  I        }
. n4 u; G+ [; F                return true;
  o4 G* B9 u0 c5 D( z        }' x* M5 Z: v6 X4 N+ S2 E

+ z3 ]# D/ ?, o2 c9 ?6 S  P( o} // end of class ProgramCompare; d  Z7 W5 k, F( T: q7 k; |
0 }5 K" C, h! x5 _3 [4 \3 X
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. Y! M" x! ?# }. P) ?; D; B
//  ProgramCompareMenu.java    Provided by: DRS. u4 M+ |# G. P' T" d3 a! h; A
//
" L4 ~9 I. k  Z# w# v//  Calls AuthorisedUsers.java and ProgramCompare.java2 b/ ^# L# B( h' t
//
+ |& O  @0 h* h+ w//  Driver shell for Assignment 2.
5 r; ]' u* E9 `' Z! x5 \//********************************************************************
8 {  F+ `& K" W5 f% h; \5 Q4 W5 d8 [& M  N- N
class ProgramCompareMenu
% @$ O4 q' a, i{
- m9 G7 r8 p, K, x2 t    public static void main (String[] args): o+ x4 M# L+ Y8 f( m
            {
& f7 L: X# T$ P$ R                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 C6 C4 c+ v5 O. E  a
                ProgramCompare reached1 = new ProgramCompare(); # W0 d8 ^3 Q, u8 V- s' Q
                AuthorisedUsers reached2 = new AuthorisedUsers();       
( R) h, K/ p- H, l# s                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% J( m  ^" d" C. R/ G* n" [                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 K- X! o! s2 ~* T1 {2 U9 ^" }        }/ c: w8 b: L: b7 d$ }2 w
}// end of class ProgramCompareMenu4 S+ T  D1 v+ k' n! I

" \0 C$ K, _3 p1 O/ s7 {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************1 B) g( W9 V+ }- f8 J
//          AuthorisedUsers.java          Provided by: DRS
% K9 h) G4 D% q: z, R  {5 X//                ! J/ s3 K" m2 z- v4 S, E; {
//         Program shell for Assignment 2
- o8 Y' Y1 _1 @. Q) A# I  K: ?//
$ o+ O$ z* P+ x/ u$ `3 Q//         Represents facts about an AuthorisedUser
7 s# I* N, O. l- W; @/ ]//********************************************************************" Z( W8 Y; z  v+ |. E
# {$ H, A. t& X, [
public class AuthorisedUsers
- B/ K* }0 g& z- p3 p. r7 t5 M    {
4 d# L; e# j' k  O0 h& m
7 A$ }" |2 L; E0 C: V: I( h, T        //-----------------------------------------------------------------6 {2 N- m4 n1 S" W, K! A' a$ x
        // Constructor
  e5 G' ]7 S, l; G        //-----------------------------------------------------------------
6 j) Q' E1 r: x" d+ r  ~) f8 }2 K: B, b) i) Q
        public AuthorisedUsers()2 B! D3 N- W' {; N$ x4 T- i
                {: |* e/ j% f, ~; c
                }
- l5 N1 [( K$ j5 t" f( }$ @' ~; `) J- v
        //-----------------------------------------------------------------
% Z4 o1 ~+ ?+ r% m        // Method for testing that class has been reached2 D3 d' s. t( v+ N
        //-----------------------------------------------------------------        * W# y2 m. L* n* L0 ^7 k& @# K
        public boolean AuthorisedUsersReached()/ [( t$ V) Z6 T7 D. }
                {
7 l2 ?# \# s) W- @& t9 Z& _. J5 |                        return true;                       
% m6 c0 \" [9 N: m" P                }. r- [5 U4 F- K$ g$ C
               
# M" W. u; x5 o. U0 z; a    } // end of class AuthorisedUsers' n' ]  ]' H7 F5 S
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# B! S2 Q  T( W7 \- t* w
Shanghai - 20078 J# M. u5 F$ }- m( s
Assignment 2
* A' I6 W$ O  t5 E& fDeadline 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)
) B' @/ c* f, ~# }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.
8 d4 _5 Z$ L) u0 xThe staff must be able to:! J* X) t% J% c4 X( x/ c
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
; g$ D  M5 d) y1. 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.
6 ^% F9 `  K4 T- Q! D9 @ The interface should provide a menu so that the staff can:
& S4 p4 _( U  Y! U) B8 la) Enter the names of the two Java program files to be compared
9 _9 E) ^. \4 j- O7 p, a2 |: t For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( t" H4 O7 u0 f
** 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).* d) L) j. I+ f* G6 @9 z1 p# U
BSA104 Business Programming – 2007: Assignment 2
/ p% V) R4 e7 E& q$ D8 _Page 2 of 5
3 o0 W' R8 n1 e. a2 A7 Y+ Cb) Print out to the screen all the lines of code that are the same6 D/ t# c; |: ^6 y$ }. _/ m) D
 Include the name of the file and the line number of the code being printed for each of the two files
7 t- b& V! [8 K* H4 A( Xc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
, d" k. p& @% e1 ~ the name, username and department of the user
1 R& J7 Z7 }( u) n$ v, S the statistics of the comparison6 h( Q5 e- G( h% B6 ?
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 t  _0 ]6 c# X( I7 l the recommendation for further checking
- Z# ?7 E& W; }+ d0 F' j% u# K3 w- 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 closely8 \+ ?& u2 _  u! g, w
 the names of the two files compared' c0 Z. _; I8 \8 V7 _8 o8 N$ ?6 g
d) Leave the program (exit); e5 b2 s. w' R7 i# P
The ProgramCompare class: (Total maximum 20 marks available)% n: @4 A. I# \* I" r
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)0 m5 C' h& _! F. J8 p7 Q: X+ |
a) provide an error message if the files are not found or there is a problem opening them- c  I( B5 f( E! V, h& N
b) compare each line of code5 V- h: e: i2 I# p: }+ P- z
c) print out the lines that are the same
4 E- ^" J, g' U) X, W. F: Zd) count the number of lines compared / lines the same3 K5 Y* ]1 }1 O: \& L( A5 h) h5 i& A6 x8 y
The AuthorisedUsers class: (Total maximum 20 marks available)
. X* y$ V! I+ S+ ]4 S3. 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)) F0 y: }/ q* @( ]. x. J1 l
4. Provide methods to:/ v  E6 l9 S* \
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 match1 ?1 r+ }( [0 T; j/ j( U
b) return the name of the authorised user* z  ?2 m8 ^$ g
c) return the name of the department of the authorised user
) `0 j8 o. l0 y2 nIndividual Data (Maximum 20 marks available)
# Q. j7 x' |7 Z' E# P5. 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.
  n$ ~* {& |$ e1 CDocumentation (Maximum 10 marks available)
" J% k7 u& P( R/ ]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.
# m- X2 k" n, Z4 J2 aBSA104 Business Programming – 2007: Assignment 2/ M5 o$ P* C" j0 J% ^
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 M4 E/ d8 S  V" N2 q! w不过你要翻JAVA的类库说明。你有下载没有?4 |$ O  J5 u( c
查询关于对比的函数。貌似关键字是contrast,还有compare
5 e! v: N* {+ Z. o3 E0 \4 N  {& d0 z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -: Y( @' ^- D  t) P
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
9 l/ S) H" ?/ F4 Z# Z0 `可以下载到的 是 jdk-1_X_0-doc# P6 p2 V3 G# z; T! |

0 w# E. I% ?/ p[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-23 00:25

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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