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

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

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:

  1. 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()).

  2. Pseudocode for a Use Case in which

    1. a Spreadsheet object gets created;
    2. this also creates a SpreadsheetData object;
    3. 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;
    4. the execute() method of the Spreadsheet's first command (in its cmds list) gets called;
    5. 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;
    6. the execute() method of the Spreadsheet's first command (in its cmds list) gets called;
    7. 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;
    8. 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;
    9. the unexecute() method of the Spreadsheet's second command (in its cmds list) gets called.
    10. the execute() method of the Spreadsheet's first command (in its cmds list) gets called;
    11. the unexecute() method of the Spreadsheet's second command (in its cmds list) gets called.
    12. 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.

  3. 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.