找回密码
 注册

QQ登录

只需一步,快速开始

查看: 957|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 ]1 K. T/ a7 `' D6 I1 h+ I4 [ 9 L: q1 k( c) \) n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 E5 W1 M, ?/ d- H+ V& n. q
//  ProgramCompare.java         Provided by: DRS
( t0 p2 K! T5 S2 s( c  W! e6 _//
) `6 w" h5 ]1 w% h; K- Y' Y//  Program shell for Assignment 2* m7 O  a3 g* Q5 d
/// |1 N( P% Q' d7 m& Y3 o$ @
//  Compares two text files line by line" v1 {" m9 N9 s" ^
//*********************************************************************
- `, b7 {+ [: o) q
# A" C0 G8 \% U! }import java.io.*;5 @' G. ~. A5 a+ Q- W+ P" o  p3 Y
3 w2 W2 C8 m5 k9 r  p  r
public class ProgramCompare( ?1 N1 h1 y. s# T* C% p$ `! l
{1 H5 h4 `4 \  _
        //-----------------------------------------------------------------+ ~( c2 A* j& M. i$ f, B
        // Constructor( @1 W& I- Z+ j
        //-----------------------------------------------------------------
+ h# j. T& n# A        public ProgramCompare()
( v8 A9 S; t3 r0 ^, @& b4 m2 m        {6 q3 P4 P4 p7 z1 `7 c/ A, I( D
        }
0 ^% V. `" f0 d  C% r: ~' m
% c3 B3 `% \: }2 Z, {0 E& c3 g        //-----------------------------------------------------------------# E7 m) `$ U, }- T- u8 ~. i
        // Method for testing that class has been reached
& I8 P3 @6 [" \/ ~( W        //-----------------------------------------------------------------       
. e* [8 }  @, {6 e2 {* P
) u, R6 }! L! n  q9 n* M; A        public boolean ProgramCompareReached()        
/ c' f# k' d7 U0 W4 b$ ~8 Z4 j        {
: s4 Q. h: K. X, p5 N! r      try
# u/ q8 }; f  s& _! B- [; _7 W! S   {         2 c3 x1 N, e$ L
                        . r+ N$ r$ o/ t5 r6 k, x' k
                //********************************************************************7 z! V% z! G( t: J- N& l% f: T
                // Try-Catch Statement is used to handle exceptions - such as file not found
9 l, V6 Y+ I- C6 {$ p8 t                // Reading the files will need to be placed inside a Try-Catch - just like this one!" r) h) o2 I7 a# x
                // For more information see page 534 of the textbook( k1 f$ P# B5 Q! B* {
                //********************************************************************
' o+ l3 B& P) H: C" f3 H6 O                     ' K" ~/ p& J3 E) w* q5 v  H: e* }
        }0 F: O' d# w  ]: z) X; U. h' ?# n1 L$ _
             catch (Exception ex) // Exception caught here and message displayed to the screen % J( b" p9 \! L0 b
          {, I# s7 j/ E# o, ^. K0 g! \, ^
                    ex.printStackTrace (System.err);$ x7 V' N8 E3 v( Q$ }9 Q& |
           System.out.println ("Error message goes here"); // Replace this error message with your own         
5 R- D2 J# Q' I        }# x9 K: V; {% c1 c7 n" k, t& {
                return true;
9 {. {$ ~; U' F. M6 y& w        }& A8 R1 o) n5 J$ D4 F4 z
6 s; n. e. n) ?) k8 ^
} // end of class ProgramCompare; @1 S- ^2 A9 L2 u# |, |
% V0 O3 o7 k$ [; _% Y, C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 J  b' ]- b* T
//  ProgramCompareMenu.java    Provided by: DRS
" }% x3 |; m8 x//8 M+ X( t( q  O; r' t1 u- B
//  Calls AuthorisedUsers.java and ProgramCompare.java
! X! a& @1 M% C: {% e+ C' _* i//
6 C6 b9 J/ [9 c" _4 g6 m//  Driver shell for Assignment 2.7 D# q0 [% _, X! b+ {
//********************************************************************
* r: l/ f# K/ j  N0 C+ `
4 ~2 b% S0 ]" z0 E7 O, U6 _class ProgramCompareMenu; O4 R3 T  y7 [+ @
{
0 u: @  S, Y  k. H( G) g1 J* O/ G    public static void main (String[] args)
& _/ H5 t* o. O% x1 p# o            {
5 B) {/ l# k1 R. E* w                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 i4 _, x2 r( q
                ProgramCompare reached1 = new ProgramCompare();
+ s' l  w4 u: m" }" f                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 D; z7 z; w2 i& l& _- e1 j0 n- e                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());" R; O) t% W6 \5 I
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / p8 t) [. y! P$ p
        }
! B5 G! \# c1 e; o# q}// end of class ProgramCompareMenu
9 k' K9 `5 i& y& U/ x! B" H4 [9 [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. H* a4 P. [: ^# D//          AuthorisedUsers.java          Provided by: DRS
9 Q" F- B# |% D& V1 z+ E//               
" m" C8 K1 A5 \+ D8 o//         Program shell for Assignment 2
9 v: b0 y+ a5 y, J) V9 a" l//
) o1 l. Y6 W7 \4 I7 S) E//         Represents facts about an AuthorisedUser6 P# b6 v9 t0 f; S& g; v6 r
//********************************************************************
6 p' t. q/ N9 a1 j) ?  v
) w+ [4 y; M5 i" cpublic class AuthorisedUsers
# S0 W8 F$ A$ Y/ d2 a    {
% H) V/ Y( p" |' e2 j4 i
: L. b) ^6 T8 a" y* a' [        //-----------------------------------------------------------------% Z% X  p. y! Q% T3 u; F
        // Constructor
" k9 l5 `8 v1 B5 r' f$ h* s        //-----------------------------------------------------------------
  i9 G# J% c* J) S! P6 U" p
( D- I3 C! ^0 T        public AuthorisedUsers()% |$ I1 P/ a8 D) f& A) n  Z' N
                {
5 h0 v# m0 B2 Y. u                }
6 y  q7 D- a$ ?+ }+ l
+ g+ M+ c6 D# z7 M0 U4 H/ f        //-----------------------------------------------------------------0 W' R8 Z7 y! V. }: a! i
        // Method for testing that class has been reached% H) v. `: R* L: N
        //-----------------------------------------------------------------       
5 v6 Z) S6 X$ |! t" ^7 w        public boolean AuthorisedUsersReached()/ F) @1 M% Q* e3 E8 m  g  l
                {
* c1 w) U3 _/ z' w3 a                        return true;                        ( X0 `; V+ e2 [! ?! u
                }
3 h& J( \% f! L( g  ]" V: d                6 F2 B3 O9 Q5 o+ l; E
    } // end of class AuthorisedUsers" g7 J1 n+ b% }. o) t0 b7 t# n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 D5 \+ a1 y7 ?" P7 m. U8 aShanghai - 2007
. f2 A' X; O  J0 ]/ V# XAssignment 22 @0 A$ i* I% X6 g2 P3 ]  {' U0 V
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)
- l! t/ `5 f( F% s/ d% }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.
/ i. d, j4 c7 {( Z+ K2 eThe staff must be able to:( o( Y/ D, j  }; }/ F* M3 @3 a
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, C  {8 V, }, T4 m, j% \! H& D1. 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.
1 Y! _  Z6 i7 w: R The interface should provide a menu so that the staff can:
3 E+ f$ L8 B& Ka) Enter the names of the two Java program files to be compared
1 k8 S1 m! p& Q3 W For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- @; a, [# {/ W  T, H** 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).  \% y# Y3 e9 Y; A" J0 ]$ w# X
BSA104 Business Programming – 2007: Assignment 2
% z& R2 M& L& MPage 2 of 5
  a( q& }; B2 M1 u& e1 ]) X! h* Eb) Print out to the screen all the lines of code that are the same0 O( ~5 o' m$ d/ u% ~( m. Z' b
 Include the name of the file and the line number of the code being printed for each of the two files9 i$ k0 p- c& m" H& v% @6 `
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 ~  P6 j9 k6 c
 the name, username and department of the user
. [# G% C+ ]% L: U& G  L; V the statistics of the comparison: }4 ~+ ~, B& J" k" M! |% I
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 O) w& x; T9 ~; |2 y, {: V2 \ the recommendation for further checking
8 E# F" q! [3 T9 P; ]. H/ `8 \- 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 closely3 \* I! U2 e, ^- X9 J( y" {
 the names of the two files compared
( h$ i, Q$ B9 f% cd) Leave the program (exit)5 a1 \0 y9 ~" X. K/ _
The ProgramCompare class: (Total maximum 20 marks available)8 O; J4 T& T% z% [
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)
: s4 Z2 E; h& [7 c' D, La) provide an error message if the files are not found or there is a problem opening them7 Q2 ^1 \, k; N3 a- ?. {# m( Q! D% j; ?
b) compare each line of code
! G8 R! u- j7 xc) print out the lines that are the same
' d. z, b0 I: z7 bd) count the number of lines compared / lines the same
- F3 C, Y! G8 w$ L/ kThe AuthorisedUsers class: (Total maximum 20 marks available)/ X# P3 n! b: r* \7 R
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)
- l+ ~: i7 o/ X' p  g! q* G8 U4. Provide methods to:9 S  J0 F3 f, a6 Y0 t
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 match6 O# U; W% V; J# T8 m& r
b) return the name of the authorised user
7 z; y, v' A% ]. ~. J* Ic) return the name of the department of the authorised user: u. C5 l4 `7 b0 p
Individual Data (Maximum 20 marks available)9 Y: k* |3 V  q4 r
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.+ N& U/ D5 ]8 ?" ?- D1 U
Documentation (Maximum 10 marks available), {* M* [1 B. E" `
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.  G1 z. s; ?% P
BSA104 Business Programming – 2007: Assignment 2
) |. i/ F+ ?1 H1 rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ q+ {* e/ x3 z8 k7 _- Y
不过你要翻JAVA的类库说明。你有下载没有?
# ^6 B% S) r6 G6 V% |& K' Y! a, U查询关于对比的函数。貌似关键字是contrast,还有compare
5 W# k% C6 ~: X' c% T
- R% h) |; O- I, h- V5 [1 ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 j+ {' ?/ F. U* w* [
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' U4 @. k- R8 ^. R. A2 k7 I可以下载到的 是 jdk-1_X_0-doc9 D( K3 v) H* Q8 M; l
- Y$ O4 i- Y. p9 K9 ]3 [% {  g5 @
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-21 20:12

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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