COMP 304B Object-Oriented Software Design -- Assignment 5

COMP 304B Object-Oriented Software Design - Assignment 5
  Due date: Sunday March 30th, 2008 before 23:55

 

Practical information

The assignment

In this assignment, you will implement the Command Pattern for a very simple multi-body simulation system.

Most of the simulator code is provided (MultiBodySimulator.zip). This includes a command line tool that interprets commands you type in. Consider this tool as the invoker for your system. The syntax for the commands is as follows:

 create  : add a body to the multi-body system at position (0,0).
 delete  : remove a body from the multi-body system.
 velocity   : set a body's velocity vector to (v_x,v_y).
                      unit of velocity is unit of length/timestep
 step  : Advance the simulation  of timesteps (default == 1).
 undo  : Undo the last  commands (default == 1).
 state : output the current state of the system.
 help  : Print this message.
 quit  : Quit this application.

Your task is to extend the design by means of the Command Pattern to support the undo command of the simulator. The only commands which need undo are create, delete, velocity and step. In particular, you should not undo the undo command (i.e., redo). Note also that only succesful commands can be undone. Note also that step N is a composite command and requires N undo commands to be fully undone.

This entails the following:

  1. Draw a Class Diagram of the modified design. You may "collapse" some of the classes which are already implemented: only show the attributes and methods you will need. In your modified design, you should use meaningful names taken from the Command Pattern.
  2. Draw a Sequence Diagram for the following sequence of commands (show only those messages pertinent to the Command Pattern):
     create body1
     create body2
     velocity body1 1 1
     velocity body1 10 10
     velocity c 10 10
     velocity body2 2.0 2.0
     delete body2
     undo 3
     step 4
     undo 2
    
    Next to the sequence diagram, in annotations, you should present the state of an object if it is changed due to receiving a message.
  3. Implement your design and submit the full, modified code including all files in a .zip file.
  4. In your report, provide the output generated on the screen by your application when given the above series of commands.

Hans Vangheluwe. Winter Term 2008.