![]() |
![]() |
![]() |
![]() |
![]() |
|
Once you have indicated that the
Vegetable, Dairy, Meat, and Grain classes are
subclasses of the Food class, you can send messages defined for the
Food class to instances of the Vegetable, Dairy,
Meat, and Grain classes.
In particular, the following setters and getters, moved from the
Vegetable class to the Food class, are accessible not only to
Food instances, but also to Vegetable, Dairy,
Food, and Grain instances as well:
Food method definition instance fCalories ^ fCalories Food method definition instance fCalories: aNumber fCalories := aNumber Food method definition instance cCalories ^ cCalories Food method definition instance cCalories: aNumber cCalories := aNumber Food method definition instance pCalories ^ pCalories Food method definition instance pCalories: aNumber pCalories := aNumber