![]() |
![]() |
![]() |
![]() |
![]() |
|
Once you have created a Vegetable instance,
you will want to assign and refer to that instance's fCalories,
cCalories, and pCalories instance variables.
To assign an instance variable in a Vegetable instance, you must use
a method that is known to instances of the Vegetable class, because
only such methods have access to a Vegetable instance's instance
variables. You can, for example, define a keyword method,
fCalories:, for instances of Vegetable:
Vegetable method definition instance fCalories: aNumber fCalories := aNumber
Because fCalories: is defined for instances of Vegetable,
fCalories: is free to assign an instance variable, fCalories,
in a Vegetable instance.