![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Using what you have learned in this chapter, you
can amend the program shown in Segment 460 by redefining
printFoodLine:
to produce aligned output:
Food method definition • instance printFoodLine: aStream aStream nextPutAll: (name formatWithWidth: 10) , ' ' , (fCalories formatWithWidth: 5) , ' ' , (cCalories formatWithWidth: 5) , ' ' , (pCalories formatWithWidth: 5); cr Workspace Food outputFoods: ((Food collectFrom: 'c:\test\vtbls.dta') asSortedCollection: [:x :y | x fCalories <= y fCalories]) to: 'c:\test\foods.tab'
The result, in the file \test\foods.tab
, is as follows:
Broccoli 3 16 9 Cabbage 2 14 3 Carrots 1 33 4 Corn 1 23 6