
10.7 Programming Activity 2: Using Polymorphism 703
69 public void setY( int newY )
70 {
71 y = newY;
72 }
73
74 /** abstract method for Racer's move
75 */
76 public abstract void move();
77
78 /** abstract method for drawing Racer
79 * @param g Graphics context
80 */
81 public abstract void draw( Graphics g );
82 }
EXAMPLE 10.20 The abstract Racer Class
The Tortoise and Hare classes inherit from the Racer class. Thus, their only
job is to pass constructor arguments to the Racer class and implement the
draw and move methods. For this Programming Activity, we have provided
the Tortoise and Hare classes with the draw and move methods already
written.
Your job is ...