Sorcerers design

From CSSEMediaWiki
Revision as of 03:59, 10 September 2009 by TobiW (Talk | contribs)
Jump to: navigation, search

An OO model of sorcerers. This question appeared in the 2005 427 exam.

Requirements Statement

Using good OO and as many design patterns and maxims (etc) as possible, produce a design for the following requirements:

  • This system models sorcerers, such as witches and warlocks, and their victims.
  • Sorcerers are practitioners of magic, and are not human.
  • Victims are human (and not magic).
  • Witches are female and ride brooms. Warlocks are male and ride pitchforks.
  • Sorcerers cast magic spells; different sorcerers know different spells. They can learn and forget spells, but when they know a spell they can cast it as much as they like.
  • Warlocks have no magic powers of their own, but can steal from witches the power to cast spells.
  • Warlocks are usually male witches, but some are wizards that turned evil.
  • Princes and princesses are common victims, and are often turned into frogs or put to sleep for 100 years.
  • Spells can be undone by counterspells, or by some event such as being kissed by a princess.
  • Some spells don’t take effect until a specific event occurs (possibly recurrently), such as a full moon or when the victim tells a lie. A regression spell, for example, is triggered by some event, and changes the victim back to what they were like at the time the spell was cast.
  • The evil eye can be cast only by females. It can cause bad luck, disease, or even death, depending on the power of the sorcerer.
  • Victims can be protected from some spells by talismans, e.g. a person might wear the hand of Fatima to ward off the evil eye.
  • Making a spell involves several phases: preparation, overture, invocation, execution, sacrifice, and closure. Some of these may be omitted in particular spells.
  • Any sorcerer becomes a necromancer when they have the power to raise dead spirits. A corpse reanimated this way can appear just like a normal human, but works differently internally.

Solutions

Here are the patterns I could find in about half an hour. Note that the design isn't complete. --TobiW

  • Decorator: Necromancer ability
  • Strategy: Spells
  • State: Curses casted on victims
  • Flyweight: Using spells more efficiently
  • Observer: Spell tells victim what happens to him/her (wait for full moon, ...)

TobiWSorcerersDesign.png

Personal tools