An Introduction to Object-Oriented Programming
By Timothy Budd
Study Guide for Chapter 8
Learning Objectives
The Java implementation of the card game Solitaire is discussed
as an illustration of some of the most important concepts of
object-oriented programming: inheritance and overriding.
After reading this chapter, you should be able to:
-
Describe how inheritance is used in the solitaire game, and the
benefits derived from the use of this technique.
-
Explain how overriding can be used to specialize generic behavior
derived from a parent class.
-
Explain the distinction between overriding for replacement and overriding
for refinement.
Study Questions
You may wish to use the print or save as command
on your web browser to produce a copy of this study guide.
That way you can fill in the answers to the questions as part of
your assimilating the information you learn as you read the material.
-
What data values are maintained by class Card?
What behaviors can a card perform? (That is, what methods are
implemented by the class Card?)
-
Explain why the suit and rank data fields are declared
as private.
-
What is an accessor function? What is what advantage of using an
accessor function as opposed to direct access to a data member?
-
What are the 13 different card piles that are used in the solitare game?
-
Describe the five functions implemented in class CardPile
and overridden in at least one child class.
-
How does the use of inheritance reduce the amount of code that would
otherwise be necessary to implement the various types of card piles?
-
Explain the difference between overriding used for replacment and
overriding used for refinement. Find another example of each in
the methods associated with class CardPile and its various
subclasses.
-
Explain how polymorphism is exhibited in the solitare game application.
Contents copyright
Timothy Budd, 1995.