Programming Assignment #1


Discuss at PA1 Collaboration Space. Due in class on July 24.

The user needs to create a spreadsheet that can compute the sum of a row or column, the average of a row or column, and, as a special case, the sum or average of two or more specific cells of a spreadsheet. Cells are specified by strings of the form "A1" -- a letter and a digit. There will be no more than 26 columns (A-Z) and 9 rows (1-9). You may assume that all cell specifications will be correct. The user would like to use these spreadsheets with Workspace code that looks like this:

| ss1 |
ss1 := Spreadsheet new.
ss1 cell: 'A1' put: 15.     "Puts 15 into cell A1"
ss1 cell: 'A2' put: 30.
ss1 cell: 'A3' put: 75.2.
Transcript cr; show: (ss1 sum: 'A') printstring.  "Prints the sum (120.2) to the Transcript"
Transcript cr; show: (ss1 cell: 'A1') printstring. "Prints 15 to the Transcript"

ss1 cells: #(24 76.4 19 37 89) putIn: 'B'. "Fill five cells B1..B5 of the spreadsheets with these values" Transcript cr; show: (ss1 average: 'B') printstring. "Prints the average (49.08) to the Transcript"

"Create a cell that sums the values of two Spreadsheets" ss1 cell: 'C1' sum: 'A'. Transcript cr; show: (ss1 cell: 'C1') printstring. "Prints the sum 120.2 to the Transcript" ss1 cell: 'A4' put: 89.9. "Add a fourth cell to ss1 column A." Transcript cr; show: (ss1 cell: 'C1') value printstring. "Prints the updated value 210.1"

In summary, methods that spreadsheets should understand include: