The "BallWorld" classes Now we have a Ball class, we need a class that creates a window on screen and a ball object to display in that window. We will create an application class called BallWorld for this purpose. There are lots of technical details required to get an application class to create a window and so on. We will not worry about these details in this example, but concentrate on how Java implements the following concepts: Rather than immediately look at a complex version of class BallWorld dealing with more than one bouncing ball, we shall first look at a simple BallWorld class, and look at how it can be refined in stages into a more sophisticated version. The sequence of refinements we shall go through are as follows: Version 1: display a static Ball object Version 2: display a Ball object in one place, then a second place Version 3: display a moving Ball object Version 4: display a moving Ball object that can "bounce" off the sides of its window Version 5: display 2 bouncing Ball objects Version 6: display 2 bouncing Ball objects (but reducing code) Version 7: display many bouncing Ball objects Version 8: display a bouncing Ball, and a bouncing RandomBall
Each of these refinements illustrates either some object concept in Java, or some way in which object-oriented software systems can be refined incrementally in a structured way. Back to top 
RITSEC - Global Campus Copyright ?1999 RITSEC- Middlesex University. All rights reserved. webmaster@globalcampus.com.eg |