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:
Special notes to consider:
#sum and #average. (And these would be good topics to address in the Reuse section of your report!)
The user is pretty comfortable entering Smalltalk code, so it's okay to always use cell:put: and cells: messages for entering values into cells. However, the user does want to see:
This can be done fancy (e.g., with scrolling lists) or simply (e.g., a big display box with formatted text in it.) For the above, a window that contained the following would do:
A1: 15 - B1: 24 - C1: 210.1 (sum 'A')
A2: 30 - B2: 76.4 - C2: 0
A3: 75.2 - B3: 19 - C3: 0
A4: 89.9 - B4: 37 - C4: 0
A5: 0 - B5: 89 - C5: 0
Notes:
'a1' at 1 returns the character $a. See Chapter 15 of Hopkins and Horan.
News Page | CS2390 Sum'97 Home Page | MMC-CaMILE | STABLE
Questions/comments/concerns to guzdial@cc.gatech.edu
Page last updated 7/9/97; 4:07:08 PM