Tuesday, May 16, 2006

11 April 2006

Template Method

GoF Patterns - Template Method

Putting Patterns into Practice
For Template Method create a small hierarchy of animals with the superclass containing a skeleton method for moving from one location to another and each subclass 'filling-in' the detail of how that type of animal moves (e.g. crabs and cats will move in different ways).


Composite

GoF Patterns - Composite

Putting Patterns into Practice
Investigate the use of the Composite pattern by creating a Zebra class that creates instances of Zebra using instances of a Leg class, a Body class, a Head class and a Tail class (cf Factory Method and Abstract Factory exercise).

Visitor

GoF Patterns -
Visitor

Putting Patterns into Practice
Write a small, prototype, application that uses Visitors to draw a circle. The radius of the circle should vary depending on the size of an element. For example:
the radius of a circle for a Collection of 2 objects will be 2 units
the radius of a circle for a Point 10@3 will be 13 units (ie 10+3)
and for aNumber the radius will be aNumber units

No comments: