找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1296|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ [/ _1 H( U2 x* K8 l# ~2 k8 V 2 `6 f4 s! C, A1 z& L: B1 ?' j, v
回复

使用道具 举报

 楼主| 发表于 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 E# P: W; l3 w( ~6 u0 H+ R//  ProgramCompare.java         Provided by: DRS2 i' f/ t4 S, U( d: O
//
, }; |" M2 N3 G% U; _* \//  Program shell for Assignment 2
& h/ v( A) k0 R% Q/// _" E; g, }9 T& {) v& {2 t
//  Compares two text files line by line
: I: G. E# }6 V- l; s3 N//*********************************************************************
4 _* m2 z2 }& j! ~8 m
# z, v1 ?: \7 qimport java.io.*;. h. P6 ]: S( A! N

: r( W2 w* W+ z8 z/ ?4 Ppublic class ProgramCompare5 ]; o7 D  Z, E2 C, j" S+ b1 M- C
{" G- ~/ i: q/ _1 D; `
        //-----------------------------------------------------------------: D9 R( J) T- q( \
        // Constructor
3 S5 ]$ k& H- H7 O% ?        //------------------------------------------------------------------ \+ `; \/ ~0 b' E" M$ Z9 _
        public ProgramCompare()
/ \0 U- k- z2 I8 k" f2 X: c        {1 c& I2 D- R& ~$ ?' B- q& O: _
        }4 p4 U0 p7 ]' R8 ?( d$ u
' J( N. b1 F6 q$ H
        //-----------------------------------------------------------------
. y7 w/ X# b7 r  ^        // Method for testing that class has been reached5 v- U+ v% J. m9 Q3 c
        //-----------------------------------------------------------------        7 E: O( ~" V: z' R5 X9 d8 l
1 m, e; g8 F2 ?1 r
        public boolean ProgramCompareReached()         $ t2 X, ~: v$ I' Z+ {
        {: e0 J) @/ A( ~; b
      try
4 C& E8 d1 ]" f- G! C   {         3 q3 `* D, U# W
                        3 S* e- {7 _9 D, o
                //********************************************************************
/ O- N4 S& Y  l6 d                // Try-Catch Statement is used to handle exceptions - such as file not found
3 x. ?/ r* D* G4 _, ]  W4 c1 k                // Reading the files will need to be placed inside a Try-Catch - just like this one!, F1 T$ ?# [5 w6 q9 Y
                // For more information see page 534 of the textbook
3 p, [* ~% F: x* `* S1 K                //********************************************************************
! p4 y, @$ g' V- p                     2 S$ z# J% a* U# ^5 A$ X
        }
1 m' p1 U1 D, y5 R* e2 c# ^3 h9 F             catch (Exception ex) // Exception caught here and message displayed to the screen
3 L( Q- Q+ y3 L5 V3 @7 |6 ^9 T4 t- k          {* h% \/ v$ U+ n
                    ex.printStackTrace (System.err);; a% {* p  a! t* a( j- b
           System.out.println ("Error message goes here"); // Replace this error message with your own          4 q, }+ @' {6 Y- q# |! j9 ]* j
        }: T' j' y; u' v
                return true;' k' |. k) Y6 j, s* f- ]  _! s
        }
3 I/ ]8 |0 N3 k1 f: o) V2 w& h: w9 I+ x
} // end of class ProgramCompare2 ?* z4 }( u9 ?

& ?  g, E5 O4 d6 g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' r3 m6 J# }& C+ @% |6 e* m
//  ProgramCompareMenu.java    Provided by: DRS
9 t% i9 T& L+ i' [& E* G8 _/ q//
! _9 G8 J. F% X# n//  Calls AuthorisedUsers.java and ProgramCompare.java* T9 f8 e9 d( c- _1 b
//8 ?! ^: w; @6 p# [$ i; d* x
//  Driver shell for Assignment 2.3 v* z: \7 h( ]3 w
//********************************************************************
7 B0 e- E% N8 j6 @3 r$ J" ]% }  m. L- K2 R  t$ `+ Q( o
class ProgramCompareMenu5 M% R! a* F6 v. s
{
4 J/ F! A3 V9 c5 y+ I1 t    public static void main (String[] args)% K9 Q, A8 y9 I8 o$ k! z3 D5 i( T
            {; H. s$ G+ X- ]1 e
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 q& s* d8 ]  V7 W$ A' d$ T6 q
                ProgramCompare reached1 = new ProgramCompare();
3 H1 M9 S' S! T! J' q                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 L: F4 ]% s: n4 k  B                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 J9 r  e' H9 F& m5 B7 ?                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ _  R4 u% Z( R
        }
: O, J+ r7 A7 ~9 `! h# _}// end of class ProgramCompareMenu/ B2 o+ m% K4 S9 u; x

9 H2 h; W4 Q% z' t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, t; {2 D' Q- C/ C//          AuthorisedUsers.java          Provided by: DRS2 h; n8 |$ D! q) H4 y+ g/ [: x$ C
//               
3 `3 E) }# O& ^+ H* b( t8 ]' v$ Q1 _//         Program shell for Assignment 2
- C3 o5 d3 e9 W//
2 h' h# o/ }6 `/ l# w: }+ B& b: T* I//         Represents facts about an AuthorisedUser0 R7 g7 U' V8 P5 p
//********************************************************************: M, H' i  ?" E; n
7 c' S, u( u7 [' {; c, W$ B/ B8 d
public class AuthorisedUsers
% `$ T/ z2 ^+ v% @4 t    {8 v. M7 c! c1 P

: @4 [9 X1 J, r" V, h* |, Y        //-----------------------------------------------------------------# l& O4 ~5 p" d7 Q$ w7 F! x
        // Constructor) A" B( A3 V' x$ h; r; X7 {
        //-----------------------------------------------------------------
, Z9 w5 q: {* c
! P- g% `$ x# @. z3 \* \        public AuthorisedUsers()
9 y" W1 E" q1 [                {0 G% F7 U5 E% }1 ~; s$ T
                }
3 r1 y2 g5 ^2 x; G) _' p% W  H" R1 l8 G* ?
        //-----------------------------------------------------------------$ j$ F! B7 _) [) ]6 }
        // Method for testing that class has been reached6 [0 r: s7 e. \, O! J1 x
        //-----------------------------------------------------------------       
$ u- X  a( W2 [4 C0 ]  i        public boolean AuthorisedUsersReached()
& ]1 j- E: V4 y9 c+ S' I                {
1 g9 _) F* T3 {6 |                        return true;                       
. U4 a/ r+ ^/ p# c                }, k' K* |0 N4 \2 y
               
7 `* i/ p7 L/ q    } // end of class AuthorisedUsers
# h( a  L! \0 ?. }2 J3 H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
3 ~) |1 p; }$ C% n3 ~Shanghai - 2007/ Q) n& D: W' u* F* I) e# L
Assignment 2
+ C, W: A7 N( J! U" D& l* H2 MDeadline 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)2 c( u/ U) N( j6 |* ?6 }
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.
! o/ z6 p4 I3 r/ i7 nThe staff must be able to:! C5 i$ T9 \" C# c& L, E7 o. z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ w; q" i) Y) a2 z9 ^# H% N1. 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.
+ x' O' e" }& |, R; ], y The interface should provide a menu so that the staff can:
* B' A, \. ?) i  j: _) C* k6 ia) Enter the names of the two Java program files to be compared
- p( V1 U+ Z$ K9 Q For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
" U' }6 p4 l0 _** 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).
9 U( p6 g1 e5 U8 c) qBSA104 Business Programming – 2007: Assignment 2
6 f( S& J# \$ B0 f/ _Page 2 of 5
3 Y( D$ N' \; G: _# Y+ \7 }7 y7 }b) Print out to the screen all the lines of code that are the same
1 a- v( r# G( B  K! q Include the name of the file and the line number of the code being printed for each of the two files9 k2 X' {. g( K' \6 J5 Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 M8 _+ _. R# M" Z the name, username and department of the user: `* M  @; ?' B4 P) Q- X; V7 }
 the statistics of the comparison
2 {& Z" D- S2 `6 H. R+ F! O- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ B0 W- V9 r* T9 V- ~ the recommendation for further checking1 O( n4 j1 w, ^. n; v
- 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
7 k5 C7 j! i, ], r the names of the two files compared
$ K3 q, T  z8 o& Md) Leave the program (exit)) I7 p/ Z! y4 g
The ProgramCompare class: (Total maximum 20 marks available)
, ~: q& z; P; p' ]  J6 l# H) C2. 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)
" E( l! ]2 |" A) ]) G+ K* Na) provide an error message if the files are not found or there is a problem opening them0 z& E7 m$ a( w2 I
b) compare each line of code0 {  O" A9 t) Q& A# H% u) A$ E
c) print out the lines that are the same) |, h2 o2 ^; Z! w# e. o
d) count the number of lines compared / lines the same
* @/ V* m4 r6 a/ BThe AuthorisedUsers class: (Total maximum 20 marks available)
; X0 i' Z* Z& L" u5 t% O( j3. 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)
$ ~; S* S4 {( `% U4. Provide methods to:
! [$ P. K" f: W3 Ha) 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
7 ~! H; Q# _) Y- tb) return the name of the authorised user; M3 E4 h$ _- Y$ ?
c) return the name of the department of the authorised user
3 B. Y# n% b9 n) r: CIndividual Data (Maximum 20 marks available)
; a9 x% w+ V- x$ _2 k/ _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.
7 {; r# L9 O0 r" V+ b3 _4 wDocumentation (Maximum 10 marks available)
- H# @/ ?2 I2 G6. 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.
/ F, `5 ~/ N, G% BBSA104 Business Programming – 2007: Assignment 2! j( t' n$ R2 V; |, f9 n
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了% @" e% T* W$ k0 l* c2 [4 z
不过你要翻JAVA的类库说明。你有下载没有?9 H: \1 N  v! l# h) N% T6 G5 G
查询关于对比的函数。貌似关键字是contrast,还有compare
( Q& u- A* \8 D9 l  d/ N$ O  w4 Y
* R  `3 x0 J1 G  ^- j  ]( [8 V[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: G+ o% y- h0 ?; V( C( `! Z痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ q# _) t# E% X& b, ], j# N可以下载到的 是 jdk-1_X_0-doc
1 o) m  _1 B4 r+ u8 z' H1 r+ [% X* B/ O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-19 02:30

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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