找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1054|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 z! Q: f; d9 L9 ~- L4 J1 T1 C' Q1 F3 v5 d
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************: F: d, `4 [  Q. G' j* L) |! ?
//  ProgramCompare.java         Provided by: DRS
+ S/ a, g2 {. `9 B; C( F# K//* X/ v% B( R& E. \9 S/ t& k" X
//  Program shell for Assignment 2
0 H, R4 Z  S% Q//$ a# ^* P0 l" T( H
//  Compares two text files line by line# T+ \* {( f; F8 i8 o8 H
//*********************************************************************
) F6 n- q- D7 T1 [' e
1 D$ R% `& T0 U$ x' b/ {7 vimport java.io.*;) Y1 O9 r6 |7 N6 W  B" ~& P

+ w% a/ s  D9 x  a0 ~( I2 V: apublic class ProgramCompare
0 \3 V4 h6 i7 B{
, p2 X& H$ R1 ~, W  y        //-----------------------------------------------------------------
1 g5 d8 [8 j) }% i& S7 _) d        // Constructor3 J( q  \  w. N' J
        //-----------------------------------------------------------------
: z/ j; f- U+ D2 e8 u; j! Q        public ProgramCompare(). `) y* @( ?3 x6 x2 _/ h
        {
2 ^0 V, G" a$ y' a8 P$ `6 Y: k6 Z0 i        }. c' V% X4 J) B1 Q

* h! H" b  X, w/ M        //-----------------------------------------------------------------
* i. P. [5 W! w3 o* {* C& I        // Method for testing that class has been reached9 J9 T7 A0 z& j  ?2 d) t
        //-----------------------------------------------------------------        % ]& M7 N* u, ^# m% b- b/ W' F. \
! b" C7 I3 C! |- z) e: C0 ?5 m
        public boolean ProgramCompareReached()         5 w3 I6 G7 G: S4 K+ }# t3 Y
        {: e- \( f7 i' t8 J& H
      try . Q& b7 n  p7 [2 y' f
   {         8 e0 }" Z% `2 U1 ]
                       
2 A6 y# w! B( p9 v+ w                //********************************************************************
- a- z4 v& u' H7 W                // Try-Catch Statement is used to handle exceptions - such as file not found + c3 L2 @7 w$ Q5 H' B: ]/ [
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
( _/ U9 b3 h' E                // For more information see page 534 of the textbook6 ?' R3 X/ B" w! E! Y* p
                //********************************************************************
  C; y& P: [" ^0 P+ u( J9 p: ?                    
$ d6 a. A$ c, \5 T( y. h        }- h3 s8 e1 I" `* h' {3 R* V
             catch (Exception ex) // Exception caught here and message displayed to the screen $ r4 h/ u4 j/ b' f  `2 S' m  }
          {
. k- @3 Q+ h( i7 G* Z( y% Y6 _- R                    ex.printStackTrace (System.err);
/ n1 _1 |$ L$ b           System.out.println ("Error message goes here"); // Replace this error message with your own          # c9 \- @3 B: i; S
        }
) C4 z9 }& s! f7 ^- d                return true;) x7 |; E( D3 C3 [$ M+ q) M( o( a+ |7 f
        }! E& z2 @, p+ P! D0 L% H
5 k  u5 G: U9 G- C
} // end of class ProgramCompare  f2 |( ?) N8 z9 o* u. h
  J, ?6 G) J0 ^2 W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ V) ]' m% D7 H5 |: ]) j//  ProgramCompareMenu.java    Provided by: DRS
- Q$ K% r! c$ R" k% J5 Z! n//
6 M% ^7 I( `1 {' t: J$ A//  Calls AuthorisedUsers.java and ProgramCompare.java& Z# ?* n" i9 W4 ^4 P3 h
//# h1 u: G5 j5 V6 N& K% N! X
//  Driver shell for Assignment 2.- a. j9 w0 ?% K& T$ `5 j
//********************************************************************0 {6 f' ]% y% u1 V4 N  m

, c/ _" Q5 N4 d. {0 N  f4 aclass ProgramCompareMenu1 p5 @0 s3 ~& s+ s$ a2 L
{$ b+ F2 K1 F1 K& i! V3 x* r
    public static void main (String[] args)
% [. d: B8 l! e7 E. ^& s' l( \            {& t# I5 x0 G5 }: I' A6 v
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
# Q( C) L: I' K! D                ProgramCompare reached1 = new ProgramCompare();
% T% Z# B- t* @4 \/ E- L& q                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 T: x: f2 n6 ]/ {                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- i1 l, p. z+ Z% l( A! p
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 p8 ?+ H+ e4 j4 u* h        }' k( u) Q) |* h
}// end of class ProgramCompareMenu
  h; a0 |' O* w$ ^7 W* D
  J6 `8 y+ M& m7 G' P! W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
8 h  O5 }0 @$ c  H. `//          AuthorisedUsers.java          Provided by: DRS
  T6 K. q+ N6 t. X+ h( C//                ' |1 ?8 {" D& y2 ?6 x7 E; A$ _
//         Program shell for Assignment 20 [6 Z6 d) k0 _) L9 r1 }) j
//
, I0 P; H' J% |9 E* L8 `1 j//         Represents facts about an AuthorisedUser
' `4 k* L2 P- k9 b6 ]; f% I//********************************************************************
' {6 a7 b% N2 R+ \9 s8 m+ d4 T
4 }2 Y6 Q8 y1 Q( A( R" o5 Cpublic class AuthorisedUsers
. n$ p- I4 ~9 K- x' t+ `: J  F    {
8 |; I! O% K% _# `. j
( s0 f  c( M! i/ g; i( U        //-----------------------------------------------------------------
* R+ P: ]- Q# y6 o) W        // Constructor1 o& \0 M4 i+ f8 t1 ?
        //-----------------------------------------------------------------, b0 j/ w. p( I; z. o3 c$ x, D8 z

$ E) }0 k% J3 `- T: g6 Q$ m        public AuthorisedUsers()* `4 @3 n2 k/ @
                {0 U; q  z* Q/ O) ~7 |) |
                }! X7 F! i& e! u' h

& o5 v" l$ z: y* `        //-----------------------------------------------------------------
- V0 M/ m3 I, [% ^9 T6 e% v' b/ M: ?& b" B        // Method for testing that class has been reached: ~/ @% ~/ U7 u& o( u
        //-----------------------------------------------------------------       
# S% ^2 {1 C  n+ \        public boolean AuthorisedUsersReached()3 E8 ?. m, x0 o8 O. a1 s
                {
7 w; f# Y1 v1 _5 @1 T4 R                        return true;                       
( M0 O- _1 u% t                }" E" M1 m/ j" @0 b8 U
                ' X6 I* }! F5 I/ V" u2 C! M
    } // end of class AuthorisedUsers
8 j" Z7 W. ~' t, X: Q5 T& h! n* `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  i8 Q( N( n4 _( e! I
Shanghai - 2007+ ^- F/ e6 T" u7 N1 @
Assignment 2
' R& Z: z# o1 k# B% VDeadline 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)
, r% |# ^9 ~* a  i! X/ G$ K5 ^! r1. 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 `$ }0 r) C6 }  O
The staff must be able to:
( r( N  I8 ^6 [+ k Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
8 G: v+ m; d) A8 U; D5 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.) N- B$ R' J: T2 z
 The interface should provide a menu so that the staff can:
* q+ y1 s8 i/ m% a' Da) Enter the names of the two Java program files to be compared6 H4 V; Z* Z6 c/ R, I; }& ]
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.2 G) J0 }+ 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).
# b! `7 g. y% J+ s# ^. }BSA104 Business Programming – 2007: Assignment 2$ W( g8 {* h9 L7 ?- i8 g& L
Page 2 of 5* b- e2 h4 o5 e6 {, _: K2 D' {9 P% ^
b) Print out to the screen all the lines of code that are the same
' l+ \  x6 t$ R. t/ u9 S Include the name of the file and the line number of the code being printed for each of the two files
# ^- C# l2 e/ Z8 ~6 fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 x8 W- q: [" J! O. B7 C$ N
 the name, username and department of the user1 N( ]2 o: U- f2 a' i6 T
 the statistics of the comparison% P/ ^- d8 f7 P/ [4 ]& S  w
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different1 \# ?% g  A3 {$ ?! R
 the recommendation for further checking" C; g* W1 C1 N8 ?' ~
- 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% n1 R9 y+ b" G. `8 j
 the names of the two files compared* V# Y5 A0 G- K
d) Leave the program (exit)) x* u9 C2 m6 Q8 k: ^' a( `! t  W, U
The ProgramCompare class: (Total maximum 20 marks available)
, R8 r& o1 F( v" ]' H2. 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)
! u0 h" J3 g1 I) U+ a4 Sa) provide an error message if the files are not found or there is a problem opening them4 P* [" q8 ~$ \% g. {5 ]
b) compare each line of code
+ l* T- e  t* w: J+ ]/ Z; i7 o* t# |c) print out the lines that are the same+ c* w3 l. u$ W) c0 {4 f: D: Z
d) count the number of lines compared / lines the same
! m4 Q, v; I4 c1 x. a) uThe AuthorisedUsers class: (Total maximum 20 marks available)
4 z, l/ C: O$ N* Z) F0 u3. 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)4 e# q- ?$ p! P9 u2 e
4. Provide methods to:; M+ C6 E$ L: D0 B7 T. R0 q0 y
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 match
0 J! l$ }. i8 a! eb) return the name of the authorised user
% v% q. c# h5 E4 ~( xc) return the name of the department of the authorised user
  c# |5 M0 O# k, hIndividual Data (Maximum 20 marks available)
8 b; M5 u1 l$ M$ o5. 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.
- @% K# h  a' P& L; vDocumentation (Maximum 10 marks available)
+ d9 l* ?  w: p6. 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.0 g4 B' L6 i+ ]
BSA104 Business Programming – 2007: Assignment 2
) h" P0 P8 C9 s- P; J9 O4 sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
" p/ ~! D' o2 i& F) Z8 M9 {0 x# s0 j不过你要翻JAVA的类库说明。你有下载没有?
- o5 j- M- X( @# @5 [8 X查询关于对比的函数。貌似关键字是contrast,还有compare, Y  w! S5 [" W) [/ z

( [3 U  v; M1 o[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 I; y8 d, A* b' V痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, n, u! p) Z9 @1 I; e7 h可以下载到的 是 jdk-1_X_0-doc
+ d7 }5 @/ @$ }$ \6 Y
  k( V  S7 W' a: h/ g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-15 18:48

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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