In the exercises from Chap. 6, you’ve updated the FlyingSprites example such that balloon bounces off the edge of the screen. Let’s improve this program by using classes and objects.
a. Move the behavior of the balloon to a separate Balloon class. Give the overall game class an instance of your Balloon class, and check that the game still behaves as expected. b. Modify the constructor of Balloon to include a starting position and a starting velocity. c. Add multiple instances of Balloon to the game, with different starting positions and velocities. Do you notice how the Balloon class avoids a lot of copying and pasting of code?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here