Home Segments Index Top Previous Next

220: Mainline

You can, of course, include additional computation in your setters and getters. For example, if you are interested in how often your program accesses the value of the fCalories instance variable, you can have fCalories display informative text in the transcript each time that fCalories is sent to a Vegetable instance:

Vegetable method definition • instance 
fCalories: aNumber  
  fCalories := aNumber. 
  Transcript show: 'The calorie content of a food changed to ';  
             show: self fCalories printString; 
             cr. 
  ^ fCalories