![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Now suppose that you want to set or get the fat
ratios elsewhere in your program, in methods that are not defined for the
Food
class and subclassess of the Food
class.
Under these circumstances, you can define class setter and getter methods for the class variables. Then, you can set and get the values for the class variables using those setters and getters:
Food method definition • class fatRatio ^ FatRatio Food method definition • class fatRatio: aNumber FatRatio := aNumber Food method definition • class carbohydrateRatio ^ CarbohydrateRatio Food method definition • class carbohydrateRatio: aNumber CarbohydrateRatio := aNumber Food method definition • class proteinRatio ^ ProteinRatio Food method definition • class proteinRatio: aNumber ProteinRatio := aNumber