Page 539 - Introduction to Programming with Java: A Problem Solving Approach
P. 539

                The doIt(); call is an attempt to call the superclass’s version of doIt.
a) Describe the problem that occurs when another method calls the above doIt method and the doIt method executes.
b) How should you fix the problem?
9. [after §12.8] What does it mean when you use the final modifier for a method?
10. [after §12.8] What does it mean when you use the final modifier for a class?
11. [after §12.9] Fill in the blanks:
If thing A “has a” thing B and “has a” thing C, there is a(n)   association, and A’s class definition will contain declarations for   variables. If A “is a” special form of B, there is
a(n)   association, and the right side of A’s class heading will contain the words .
12. [after §12.9] Identification of type of association:
Given the following list of word pairs, for each word pair, identify the association between the two words. More specifically, identify whether the two words are related by composition or inheritance. To get you started, we’ve provided the answers to the first two word pairs. Bicycle and front wheel are related by composition because a bicycle “has a” front wheel. Bicycle and mountain bike are related by inheritance because a mountain bike “is a” bicycle.
Exercises 505
 inheritance or composition?
composition inheritance
Apago PDF Enhancer
fixed assets salesperson tree
robin method paranoia
 bicycle
bicycle
structural member building
company employee
forest
bird
class
neurosis
front wheel
mountain bike
beam
   floor
       13. [after §12.10] Shuffling:
Suppose you are developing the Card Game program suggested by Figure 12.17 in the text. The following
partial UML class diagram shows where you are in the developmental process:
1*
 GroupOfCards
 -cards : Card[] -currentSize : int=0
 +GroupOfCards(num : int) +getCurrentSize() : int +addCard(card : Card) : void +removeCard(index : int) : Card +display() : void
   Card
 -num : int -suit : int
 +Card(num : int, suit : int) +display() : void
   DeckDriver
  +main(args : String[]) : void
  Deck
 +TOTAL_CARDS : int=52
  +Deck() +shuffle() : void
   























































   537   538   539   540   541