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:

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.
  1. What data values are maintained by class Card? What behaviors can a card perform? (That is, what methods are implemented by the class Card?)

  2. Explain why the suit and rank data fields are declared as private.

  3. What is an accessor function? What is what advantage of using an accessor function as opposed to direct access to a data member?

  4. What are the 13 different card piles that are used in the solitare game?

  5. Describe the five functions implemented in class CardPile and overridden in at least one child class.

  6. How does the use of inheritance reduce the amount of code that would otherwise be necessary to implement the various types of card piles?

  7. 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.

  8. Explain how polymorphism is exhibited in the solitare game application.

Contents copyright Timothy Budd, 1995.