Java Reference
In-Depth Information
(a) (b) (c)
F IGURE 16.30 Clicking the or button increases or decreases the number of sides of
a regular polygon in Exercise 16.31. Exercise 16.32 allows the user to create/remove points
dynamically.
+
1
-
1
F IGURE 16.31
Exercise 16.33 animates a pendulum swinging.
**16.34
( Game: hangman ) Write a program that animates a hangman game swinging,
as shown in Figure 16.32. Press the UP arrow key to increase the speed and
the DOWN arrow key to decrease it. Press the S key to stop animation and the
R key to resume it.
F IGURE 16.32
The program animates a hangman game swinging.
***16.35
( Animation: ball on curve ) Write a program that animates a ball moving along
a sine curve, as shown in Figure 16.33. When the ball gets to the right border,
it starts over from the left. Enable the user to resume/pause the animation with
a click on the left/right mouse button.
*16.36
( Flip coins ) Write a program that displays heads ( H ) or tails ( T ) for each of
nine coins, as shown in Figure 16.34a-b. When a cell is clicked, the coin is
flipped. A cell is a JLabel . Write a custom cell class that extends JLabel
 
 
Search WWH ::




Custom Search