找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1818|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - ?7 Q: P4 E w 9 K/ D; W' {. s( e4 r
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* v: @# V6 A/ s& p//  ProgramCompare.java         Provided by: DRS0 ]& ?% V' y! A) }  |8 O  J: ~4 C4 _: ~
/// y4 X  J3 m1 }) \; _
//  Program shell for Assignment 2' G, a& }# j2 V- a. ~
//- @9 }6 j# W# m' R
//  Compares two text files line by line( \! n$ S, _* k& }8 E
//*********************************************************************# m  _( ?4 O+ z, k

: H- O$ m8 u% U* B9 {import java.io.*;' T+ |3 L; G$ `/ P( \

, c4 ?4 F- z& Z$ @8 dpublic class ProgramCompare
# d. J+ v* d& X, w9 f( D6 ?1 P5 v8 W' j{
1 ~' i$ n6 Z, H- p& C; N5 y4 Z        //-----------------------------------------------------------------
# }- d& N3 i& _* U2 \4 K& I9 `        // Constructor+ {+ ^- }) v& ^/ P2 a1 q
        //-----------------------------------------------------------------# s8 Z. N3 I/ `! r- G; R
        public ProgramCompare()8 z- N& {* ?  u( m; ^- W6 F! C
        {. q. r' n0 o* g* s1 A2 \. d/ C+ M. e
        }
3 ?4 r; Y7 k, l' B( Z0 n9 ^
% S8 s5 b" G  J        //-----------------------------------------------------------------! Y; I, Y6 y( R8 i! r2 T" T! b+ W
        // Method for testing that class has been reached
* c* |4 h8 j; o1 f5 H        //-----------------------------------------------------------------       
7 w/ e* L" C- d/ l
$ p2 g* g( F6 P  z        public boolean ProgramCompareReached()        
9 l- c4 ?6 m- M+ o. q/ |/ J        {
% c* k+ b4 j) P      try
: v3 z2 _, o2 l$ _! A: x   {        
' G5 X: i- d0 ^) k+ E- G$ R7 K                        8 G) N9 Z/ w6 a. E% M" M3 n' r9 A
                //********************************************************************
* q/ M8 b: H0 i1 Z( q1 k                // Try-Catch Statement is used to handle exceptions - such as file not found ; u! N1 |  U. Q0 f$ s! @
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
: d! @" F! i5 B4 F5 G; j                // For more information see page 534 of the textbook
$ _. ^) ?# n1 X$ c8 s9 M                //********************************************************************- z9 B7 ~$ V" I9 D0 U2 T
                     7 v! ~0 @$ x8 x* b+ A  |
        }
3 N: i5 b; {# A             catch (Exception ex) // Exception caught here and message displayed to the screen
+ l  h7 p, h3 e. S; Y& B          {) N- T/ I: n+ U/ W
                    ex.printStackTrace (System.err);, d& Z; P. }- a' G& w; _9 g
           System.out.println ("Error message goes here"); // Replace this error message with your own          ( F" S2 G( ~3 s
        }4 N# L3 J7 ^9 S
                return true;) v/ b$ A5 r9 N
        }
. [) ^' O$ d+ ^" U* k
6 Z1 M5 C1 S( I( V& \/ O} // end of class ProgramCompare
7 w$ ^& b( [) u' Y! N
& z  j- H+ Z# Y) X' j6 w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 y. s* Y6 Z$ e9 C. k) w
//  ProgramCompareMenu.java    Provided by: DRS
, P8 p. p% M& s0 g+ m9 m//
( i: k! o1 i9 g5 n; N* b9 c2 j( d//  Calls AuthorisedUsers.java and ProgramCompare.java; D! U/ g. |" K/ ~) I
//8 S+ u, t+ u3 T4 u" g# t0 [5 X6 @
//  Driver shell for Assignment 2.8 X9 q0 W) ?- W
//********************************************************************
' j4 A3 ]. d& j2 |  C% T9 _' u9 y' D7 N2 M; D0 Z7 V
class ProgramCompareMenu8 r5 E) a8 K! `) K, u
{
0 @5 H) \/ m# v  [' \    public static void main (String[] args)" H# }. S& Y* {/ `, d
            {
7 N3 ]3 B, x" c+ n8 P                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" n- A1 a! u- ]; P                ProgramCompare reached1 = new ProgramCompare();
, a2 m4 M6 ]) M. E; Y                AuthorisedUsers reached2 = new AuthorisedUsers();        & e* ~- Z) F5 Q7 Y% l
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
* G# c( Z* \' D9 ], ~$ A  m: V                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        6 A3 Z. X1 Y+ s- R9 J
        }, J/ K7 {" F* N/ c0 L" D0 P
}// end of class ProgramCompareMenu
! x6 y$ J% i7 Q6 u( V% _' w1 c1 Q) M8 d% L, U% I! ^, @7 w0 W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 i& q( W* p) X) Q4 i! J$ C  r
//          AuthorisedUsers.java          Provided by: DRS
' J( C+ p" p/ ?/ ]//               
8 o* n; [; \3 g4 x' y+ j//         Program shell for Assignment 2
  M- ?8 V" `/ }//
* Y) |' w, ^) V+ H# b//         Represents facts about an AuthorisedUser! r" _; T3 A- E* |6 v- I
//********************************************************************
' {+ {, Q3 [" g9 i+ O. o  R) e8 @
( v* T6 V1 _0 n( c( ~* P- [public class AuthorisedUsers! L* Y3 z& I1 }5 {+ j5 y
    {/ x4 B* H9 p4 D1 \
) m4 G" ?+ |) t' K5 `/ s
        //-----------------------------------------------------------------
7 z. W5 C+ @: A3 w* ~' Y: c        // Constructor0 L: N  u8 m' g) |8 T; P& G* l
        //-----------------------------------------------------------------% N- T3 [8 Z# w  ~7 [
# j$ g" X! T; w  `0 c+ y
        public AuthorisedUsers()* X% F& ^# b' v& i. A/ |6 K& }4 _
                {
! v0 y% x( V* J9 P% |                }
& `1 U- Z. W/ m3 l+ |. \
0 u0 R% j, D2 a0 B- o9 _( Y: A+ T        //-----------------------------------------------------------------0 _7 z' n, b% u3 J- E
        // Method for testing that class has been reached
* \9 p, `! Z5 t" I/ x5 B/ }' j  w2 f        //-----------------------------------------------------------------        % i# a+ M, `) k% `0 v
        public boolean AuthorisedUsersReached()% K; Z2 u+ A  }" S# M, @! ^$ n
                {
- g; }( W4 q+ T! w: L9 L" o6 B                        return true;                       
6 z; k, n8 P3 @9 D. S                }6 \  z( s. b8 }6 k' o% ^
                & z* K: s2 U' F  Q# s
    } // end of class AuthorisedUsers
( g2 T$ G/ B* }, `2 c& R//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 S: a/ ]$ V2 b0 M, Y  pShanghai - 20079 N3 ?' P0 \8 S8 P
Assignment 2
- N6 u. C" z" Z. i# wDeadline 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)
  `1 x: h5 m& e6 y1. 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 N9 e! L4 n& d/ o$ O/ R9 M/ AThe staff must be able to:
5 X* m, N: _9 N: C1 i% Y Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.( l4 C6 E  L4 v, {0 O" R  b* N( d
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.
: i8 j" ~/ c  b The interface should provide a menu so that the staff can:/ X3 d5 Z4 F3 W- T$ B
a) Enter the names of the two Java program files to be compared' A: ~! D1 ~# `: L
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 Q; l4 a: M7 \; X+ m% a- 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)./ ]+ q/ j+ E  \- b$ Y6 t6 y
BSA104 Business Programming – 2007: Assignment 2" b8 |; Y1 ]7 }9 t$ ?: k: H6 [/ V5 F
Page 2 of 5
( n' g* z; S7 }4 @, u* ?6 mb) Print out to the screen all the lines of code that are the same
' q  `* I* _' k  V; v0 F' t: O Include the name of the file and the line number of the code being printed for each of the two files
) F: _0 S8 K+ x) @c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& f: C- C" p  O( V9 c8 Y the name, username and department of the user
/ w  z3 r7 X+ @. R' I$ U the statistics of the comparison& p, Q# A, @, o+ P
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% }0 ], Q! O4 o6 g. X) |' w$ F
 the recommendation for further checking
% J2 R2 G9 C- ^/ D: L" 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 closely
+ y) m/ N. A/ Z the names of the two files compared
7 H6 Z1 ~' x$ Y4 T) f  [2 md) Leave the program (exit)1 Q. x% u2 l3 [* U1 Z
The ProgramCompare class: (Total maximum 20 marks available)" W2 ^& I/ Y0 F* H/ h! E
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)/ {8 t3 s, D6 h
a) provide an error message if the files are not found or there is a problem opening them) h! {3 R9 b5 ]1 Q* k9 ~
b) compare each line of code
7 s5 K# h4 }( r) Z" J! l, z1 D  Yc) print out the lines that are the same
: j" g% B* A; Wd) count the number of lines compared / lines the same
2 {* w5 A  F( X) y3 MThe AuthorisedUsers class: (Total maximum 20 marks available)
5 H& A0 U- s  b6 p) R* U" G- i3. 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). p; Z( u7 l  Q; N
4. Provide methods to:& M9 T$ q2 V; s: m: D6 H- v4 X7 |
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
/ o( \' i* F# @5 Gb) return the name of the authorised user
& |' L# }' M9 c7 q( f6 D7 rc) return the name of the department of the authorised user
! r/ t+ j2 g# ^4 _* r; Q5 NIndividual Data (Maximum 20 marks available)# c* j: z" L' C! ]4 M
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.' l/ G2 Q0 E( K- Y
Documentation (Maximum 10 marks available)
) }( y1 c! Y" h0 h* M2 M! }" X8 F6. 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.
3 j& n: Z! A" J% ]+ ]1 V, QBSA104 Business Programming – 2007: Assignment 2
$ Y4 m: p" f/ N% D8 mPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 f( R, E+ X: X: |0 Z& O5 {不过你要翻JAVA的类库说明。你有下载没有?0 B$ ]$ @$ X( F
查询关于对比的函数。貌似关键字是contrast,还有compare! \# |1 _% i! G+ V+ R8 K  i$ H

& r& X. `3 \1 }: w  [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -! t9 h# i9 M' h% l+ K3 H# n+ b
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 d" V% J9 C+ a/ ~( P4 p
可以下载到的 是 jdk-1_X_0-doc& s/ j, D: j/ `3 y
: C' X9 M5 U& l9 C  P( k
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-12 19:56

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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