找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1266|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " y( b+ l& r& ]: G4 T8 k; ]& q# I$ ]' Q \$ E5 I* m% ]: Z
回复

使用道具 举报

 楼主| 发表于 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 [3 N2 B' C9 y* \2 j
//  ProgramCompare.java         Provided by: DRS
; D) k$ S: C- p0 {2 \/ L- m//
9 I. k1 j- R4 T//  Program shell for Assignment 2" A5 y7 u2 a6 X2 ?
//& ^. f* J! b* D% v' B3 H
//  Compares two text files line by line; x# ~9 X, Q3 m% v/ R
//*********************************************************************
( s4 s' w# R% }1 l* c
8 T: h- ]2 L) t9 m. G) I1 N2 Bimport java.io.*;" E/ r. d# q7 E# K' Q/ }5 a

) x9 f0 ~0 a( _- T& Apublic class ProgramCompare
  _7 s$ g$ {& j$ u8 Z& o: K{9 J; k; i  r2 z: ^" }
        //-----------------------------------------------------------------
8 S) B/ X- k; p5 q9 _7 J8 k& k' s        // Constructor
# Q/ Q% ?# @8 d& J8 ]4 ?0 Y        //-----------------------------------------------------------------
: v9 ^3 F) Q5 F9 Y: c; Q8 x        public ProgramCompare()
$ N1 ?8 N6 T! f! W# P- K        {# g1 q1 |/ g6 ^: c% T( E
        }& `: ~/ e* @/ W0 F

9 z; B/ u( N: C( W( k- G, V0 k' a        //-----------------------------------------------------------------# `- i) M: S* [3 H5 V
        // Method for testing that class has been reached
, `) \- g8 B: c& z) e        //-----------------------------------------------------------------       
5 `' x: z' p7 |3 c% P& f3 A, B9 k/ C! ^. t; k+ G
        public boolean ProgramCompareReached()         . M; {# o, w- o1 ]7 e2 m* o
        {
" I  E* O$ `) P      try 5 z! A8 \  ~2 R$ \0 N" h8 x
   {         ; @4 [9 D" c; i1 ]+ }
                       
5 u5 b$ k, G# }# J                //********************************************************************2 p$ @" o5 r4 r6 O/ f6 z
                // Try-Catch Statement is used to handle exceptions - such as file not found 0 P3 g) t$ E4 Q, S$ z
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ q) B0 e  Y! _) p                // For more information see page 534 of the textbook  `  Z% k. ?' O. j3 R
                //********************************************************************
4 w) q, ^8 l% `, p1 y( A4 }( y+ d: s; n9 l                     * x" e; l% B/ P9 t* k
        }, D! z/ ~/ l; E: I0 d( y! l
             catch (Exception ex) // Exception caught here and message displayed to the screen
7 g0 B; ]$ \# {4 |3 _( k4 C2 ~          {
2 u5 J, |0 M1 L$ Q+ _- K                    ex.printStackTrace (System.err);
1 S5 X0 t9 I; l* M- R" J           System.out.println ("Error message goes here"); // Replace this error message with your own          ! O7 ~, p3 {! X
        }
$ h% Y; t1 \' F( a- R& p                return true;
0 g' w1 S- p, _; R        }- X7 F7 s, u: W9 v/ y4 e

/ F* ?) x! u; R# C* R7 \+ X} // end of class ProgramCompare; o% s& T# ~4 {4 N" G  b6 V' _! ?

6 @% b0 ^7 J5 h& }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************1 ^, h. z: c" t
//  ProgramCompareMenu.java    Provided by: DRS3 `6 _4 g' s& x) B; }7 P! H, u
//
9 S( {7 F9 E; O! O% O5 Q3 G  p//  Calls AuthorisedUsers.java and ProgramCompare.java
6 U! g7 f$ w" w8 w- O3 G: T//( K2 ^9 E# j7 Z; A9 ?% R
//  Driver shell for Assignment 2.
' H5 w" k5 `* k, q//********************************************************************. o8 |6 b! g: f! m. p- J5 f: p

+ p, }! ?+ C) f0 v( x! |' }( O7 pclass ProgramCompareMenu+ Z+ K& I( g* v* K( H
{! S6 Q! C' w$ h  B
    public static void main (String[] args)) D# r. q/ t7 H0 H& O1 m
            {
+ I- q% k  x* e! r3 |6 @! L                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 f( u4 @3 h$ y9 f  h3 j2 T5 T! f
                ProgramCompare reached1 = new ProgramCompare();
& _& L5 v, [! n" d& |" S                AuthorisedUsers reached2 = new AuthorisedUsers();       
5 t3 B8 q# j# D8 C                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 n1 p7 ~/ ]* r. }  X2 _                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 j! B: M) G: I5 H8 C        }' p: \  }' ~% t/ |; r+ Q9 r" \$ u
}// end of class ProgramCompareMenu6 x, L( n$ I. ?) ?/ [) f- S
/ j" K7 J+ p0 Z& w6 [! |7 _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  Z; v# M8 j% i  @//          AuthorisedUsers.java          Provided by: DRS+ R# F  ~0 y+ s' F5 s! E+ L; |
//               
* A1 |" a$ ]; S; d//         Program shell for Assignment 2& i3 H( B  u+ l3 V4 {1 W% h
//
& y$ s/ \, q' k9 z9 C//         Represents facts about an AuthorisedUser
, W2 J* X# l7 m8 D3 m//********************************************************************
7 S" c# r2 _0 b# `2 G" I
( g; ^: j/ P8 A& D. s' k6 Epublic class AuthorisedUsers8 H- x/ K6 _' ]' A$ M8 }, B
    {
% o3 J! X7 X0 U5 h" Q) b) k$ r0 c5 t% [' i$ C1 i
        //-----------------------------------------------------------------
3 R% g5 o+ U( u" c4 a        // Constructor
; B0 Z/ G+ F3 |, }  \        //-----------------------------------------------------------------
; m& S, U4 ^' h/ F7 F# u7 Z5 o, G7 }! H- r
        public AuthorisedUsers()
- o( v/ B5 a$ B$ j/ N                {  B/ Q5 F6 o7 \$ n  i( L& e
                }
8 w% J1 K# Z. f  g+ q# N1 {1 _9 C
        //-----------------------------------------------------------------4 R  m$ j0 A% k
        // Method for testing that class has been reached! P9 Y# T9 ?5 `9 u4 K; s
        //-----------------------------------------------------------------       
1 `) U6 x  W* C        public boolean AuthorisedUsersReached(), j% W9 j$ j; r, b8 a$ S
                {) Q! ]& F; `/ g4 m
                        return true;                       
0 w' W% Y! l6 Z                }, ]/ m& x5 v& }0 c4 c1 i, R
               
1 K4 \7 G' p4 x  b* ?    } // end of class AuthorisedUsers
7 o4 t( {* X. `: n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 |" v. A5 L; \: v8 V
Shanghai - 2007
* U" y( W% E8 d# S* e! Q8 L* }. sAssignment 2
8 c' o& @$ z6 g# QDeadline 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)# N# q# ]$ ^" A2 Q) t, c& k
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.
0 E& r; ^( Z) i, Y# _; {7 R. [0 t: a0 WThe staff must be able to:
; N5 N/ p) Q( v' N" M. e$ v Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 I& y- u0 ]1 {  v3 O1 D5 H
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.0 N3 u% i! j$ g1 u8 n
 The interface should provide a menu so that the staff can:
" h; U: d3 w6 `; \7 `a) Enter the names of the two Java program files to be compared
4 |; {0 E! s% b4 k- h$ t( C; w8 d* f For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) p" i/ U( p" r1 T" Z, o
** 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).3 Z+ l5 J0 T$ H: W/ R; H+ g
BSA104 Business Programming – 2007: Assignment 2
) B, n' t+ l/ x2 a0 @/ j( v* g/ jPage 2 of 5- s" u: V& S) Z4 a) l. C9 w4 z8 {
b) Print out to the screen all the lines of code that are the same# [+ u3 P+ l) v2 b' u8 W+ i
 Include the name of the file and the line number of the code being printed for each of the two files
$ \  {. k2 ]  |, lc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 P. `2 @$ q# b" d" Z% \$ K
 the name, username and department of the user
5 N  b! I  m. x4 Z the statistics of the comparison/ ~4 Q7 t. q/ P
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' f  S8 a+ X* N0 L' Z) D. _( d% L the recommendation for further checking
( t: g+ e  S( A) B- x  J- c1 ]! ]; C- 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+ W0 C' O0 U; _* t
 the names of the two files compared" L+ r% F! _+ w) Z9 S
d) Leave the program (exit)
2 u8 `: C: A  U7 w/ V- iThe ProgramCompare class: (Total maximum 20 marks available)
0 i4 R# s7 Y* U' 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); R, M( m$ \% ^- W0 z
a) provide an error message if the files are not found or there is a problem opening them
' F) P" r2 j! }b) compare each line of code, E, q# ]* }% W3 a) R5 @4 f. p
c) print out the lines that are the same
* B  {- O5 i- ?5 Q1 `' H" R8 d+ {d) count the number of lines compared / lines the same
; s# d, g. g! N# f0 mThe AuthorisedUsers class: (Total maximum 20 marks available)$ ^# N7 {+ u8 Q. K4 Y7 c: J
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)- a* _9 |0 W! _/ E0 Q# F2 y/ e
4. Provide methods to:
. B$ t1 T( [& Q/ {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 match2 v8 R! ^3 }, C" K/ s! ]. ?
b) return the name of the authorised user
2 H* b7 o% g  k# y2 y  Oc) return the name of the department of the authorised user
( D% v: h9 E0 e' _% x1 I- MIndividual Data (Maximum 20 marks available)
6 V% y2 b1 ]# ^0 r* H9 n1 a5. 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' \1 q# L% f' b* W* H
Documentation (Maximum 10 marks available)
; w4 s' _% |+ L1 @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.
# z6 ]+ U7 s+ N' y$ wBSA104 Business Programming – 2007: Assignment 2
0 Q4 m& ], l5 k1 X9 P# ^' \Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& L2 E- g! W* d7 H不过你要翻JAVA的类库说明。你有下载没有?5 m+ W% i. k' [" m' O/ r) }
查询关于对比的函数。貌似关键字是contrast,还有compare
0 ?3 t- h8 F, A$ x7 z  f( L: I) B! l7 h7 k3 Z& Y. r' j
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" E" `3 {+ w! E可以下载到的 是 jdk-1_X_0-doc8 T7 Q. S9 A  X2 @/ J+ H$ z: a# v% w4 c

! |1 s! @! d$ ~( x! A/ ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-12 10:30

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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