COMP 304B Object-Oriented Software Design -- Assignment 4\\\
Due date: Tuesday April 1, 2003 before 23:55
COMP 304B Object-Oriented Software Design - Assignment 4
Due date: Tuesday April 1, 2003 before 23:55
Practical information
- Team size == 2 (pair design) !
- Each team submits only one full solution.
Use the index.html template provided on the
assignments page. Use exactly this
format to specify names and IDs of the team members.
The other team member must submit a single
index.html file containing only the coordinates of
both team members. This will allow us to put in grades for
both team members in WebCT. Beware: after the submission deadline
there is no way of adding the other team member's
index.html file and thus no way of entering a grade !
- Your submission must be in the form of a simple HTML
file (index.html) with explicit references to
all submitted files as well as inline inclusion of
images. See the general assignments page for an
index.html template.
- The submission medium is
WebCT.
The assignment
In this assignment you will use UML Class Diagrams, Pseudocode
and UML Sequence Diagrams to describe a simple design based
on the Command Pattern.
The design uses a highly simplified version of part of the Spreadsheet
design.
A Spreadsheet has references
- named data to a single SpreadsheetData object;
- named cmds to 0 or more Command objects.
SpreadsheetData has a private attribute cells,
a 10 by 10 array of integers. It has public methods
getCellValue(row, column) which returns the value stored
at coordinate (row, column), and
setCellValue(row, column, value) which stores value
at coordinate (row, column). It also has a constructor
which initializes all the cells in a SpreadsheetData object
to 0.
Command is an abstract class. Its constructor
(used in concrete subclasses) takes a reference to Spreadsheet's
SpreadsheetData object as an argument and uses that to
provide a local reference named ref.
Command declares (and provides dummy, empty implementations)
for methods execute() and unexecute().
Command has two concrete subclasses, DisplayCommand
and SetCommand.
DisplayCommand's execute() method
uses the ref reference to loop over
all cells and print their values to the screen.
DisplayCommand does not override the default, dummy
unexecute() method in Command.
SetCommand has an askUser() method which
prompts the user for row, column, and value to set. It returns
the tuple (row, column, value).
SetCommand's execute() method calls askUser()
and subsequently uses the ref reference to set the appropriate
cell to the value given by the user.
SetCommand has a memory attribute
as it is necessary to remember the effects of execute().
Using this memory information, unexecute() will
be able to undo previous execute()s.
Note how you must support an arbitrary level of undos.
Your assignment solution should contain:
- A Class Diagram depicting all relevant classes, their attributes
and methods, as well as all relationships between the classes.
Pseudocode (in sticky notes) must be provided for all
important methods (in particular,
for execute() and unexecute()).
- Pseudocode for a Use Case in which
- a Spreadsheet object gets created;
- this also creates a SpreadsheetData object;
- two Command objects get created, one
DisplayCommand and one SetCellCommand object.
They get stored in the first and second position of
the Spreadsheet's cmds list;
- the execute() method of the Spreadsheet's first
command (in its cmds list) gets called;
- the execute() method of the Spreadsheet's second
command (in its cmds list) gets called. Assume the user
decides to set the cell at row 5 and column 5 to 5;
- the execute() method of the Spreadsheet's first
command (in its cmds list) gets called;
- the execute() method of the Spreadsheet's second
command (in its cmds list) gets called. Assume the user
decides to set the cell at row 5 and column 5 to 10;
- the execute() method of the Spreadsheet's second
command (in its cmds list) gets called. Assume the user
decides to set the cell at row 1 and column 1 to 1;
- the unexecute() method of the Spreadsheet's second
command (in its cmds list) gets called.
- the execute() method of the Spreadsheet's first
command (in its cmds list) gets called;
- the unexecute() method of the Spreadsheet's second
command (in its cmds list) gets called.
- the execute() method of the Spreadsheet's first
command (in its cmds list) gets called;
For each operation, describe the new state of the relevant objects.
- A Sequence Diagram depicting the above Use Case.
The Class Diagram, Pseudocode, and Sequence Diagram must be consistent.
Add short explanations where necessary.
File translated from
TEX
by
TTH,
version 3.05 on 26 Mar 2003, 22:44.