Object Oriented Programming 2E
Timothy A. Budd
Case Study: A Billiards Game
Purpose of Chapter
The purpose of this chapter is to once again illustrate the design of a program as a universe of interacting agents working together to produce the desired outcome.
Picture of Billiards Table
Graphical Object Class
Every graphical object has a link field and a region of space.
Objects must be initialized
Graphical Objects can Draw themselves
Objects can be Hit
Balls move when updated
Reaction to Mouse Down Events
The program can be greatly simplfied by making all graphical objects inherit from a common base class.
We will have much more to say about inheritance, and the power that comes from the use of inheritance, in subsequent chapters.