![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
You may wish to use getters to provide access to derived attributes
that exist only in the sense that their values can be computed from
instance variables that do exist. For example, you can create
fGrams
, which seems to refer to the contents of an fGrams
instance variable, but which actually refers to the contents of the
fCalories
instance variable:
Vegetable method definition instance fGrams ^ fCalories / 9
From the behavior perspective, fGrams
provides the answers
you want, and you do not need to concern yourself with how those answers
are produced.