Play the Game Pong, Part I
The PongTimerTask class is used as the timer class for another class that plays the simple video game known as Pong.
The timer class extends the built-in class TimerTask. The base class has an abstract method run() that must be implemented by the class. In turn, the implementation of this method calls the updatePosition() method as long as the applet has focus. The updatePosition() method moves the ball as appropriate after one timer tick.
In the game, a ball moves down the screen toward a paddle that the player controls (“down the screen” means from lower to higher y coordinates). If the player can move the paddle sideways ...