Ultimate Warrior (UW) is a prototype of a computer game in which characters battle each other in tournaments for the title of Ultimate Warrior.
· A tournament consists of many contestants.
· Contestants are characters.
· Every character has name and health attributes and a method for attacking other characters.
· When an attacker attacks a victim, the health of each is decremented.
· A character is killed when his/her health reaches 0.
· We would like to implement the attack method in such a way that its behavior can be dynamically altered.
· For example, when Thor initially attacks Blackout, we might see hammer swinging behavior. On subsequent attacks we might see lightning bolt throwing behavior. In future versions of UW we might like to add new attacking behaviors.
· Following the Open-Closed Principle, we would like to add these behaviors without modifying existing code.
We explore ways to achieve our design goal though different versions of UW.
· Version 1: State-Dependent Behavior
· Version 4: The Strategy Pattern