| ss1 ss2 ss3 ss4 ssArray| ss1 := Spreadsheet type: #sum. ss1 cell: 1 put: 15. "Puts 15 into cell 1" ss1 cell: 2 put: 30. ss1 cell: 3 put: 75.2. Transcript cr; show: ss1 value printstring. "Prints the sum (120.2) to the Transcript" Transcript cr; show: (ss1 cell: 1) printstring. "Prints 15 to the Transcript" ss2 := Spreadsheet type: #average. ss2 cells: #(24 76.4 19 37 89). "Fill five cells of the spreadsheets with these values" Transcript cr; show: ss2 value printstring. "Prints the average (49.08) to the Transcript" "Create a spreadsheet that sums the values of two Spreadsheets" ssArray := Array with: ss1 with: ss2. ss3 := Spreadsheet type: #sum with: ssArray. Transcript cr; show: ss3 value printstring. "Prints the sum 120.2 + 49.08 to the Transcript" ss1 cell: 4 put: 89.9. "Add a fourth cell to ss1." Transcript cr; show: ss3 value printstring. "Prints the updated values of ss1 and ss2" "Create a fourth spreadsheet whose value is the average of ss1 cell 2 and ss2 cell 3" ss4 := Spreadsheet type: #average with: ss1 cell: 2 with: ss2 cell: 3. Transcript cr; show: ss4 value printstring. "Prints the average of 30 and 19 (24.5)"
Salman's approach to this project in 2390 W96 was to make an abstract class Spreadsheet, with concrete classes of SimpleSheet, TwoDSpreadSheet, and TwoCellSpreadSheet. Interesting, he creates a separate FormulaLibrary which knows how to sum and average.