The strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
see SimUDuck app. for reference.
below you'll find a mess of classes and interface for an action adventure game.You'll find classes for game characters along with classes for weapon behaviors the characters can use int the game. Each character can make use of one weapon at a time, but can change weapons at any time during the game. Your job is to sort it all out...
Your task:
1 arrange the classes
2 Identify one abstract class, one interface and eight classes
3 Draw arrows between classes
a Draw this kind of arrow for inheritance ("extends"). ------|>
b Draw this kind of arrow for interface ("implements"). - - - - -|>
c Draw this kind of arrow for "HAS-A" --------->
4 put method setWeapon() into right class.
[IMG]http://i46.tinypic.com/2vug8ea.jpg[/IMG]
see SimUDuck app. for reference.
below you'll find a mess of classes and interface for an action adventure game.You'll find classes for game characters along with classes for weapon behaviors the characters can use int the game. Each character can make use of one weapon at a time, but can change weapons at any time during the game. Your job is to sort it all out...
Your task:
1 arrange the classes
2 Identify one abstract class, one interface and eight classes
3 Draw arrows between classes
a Draw this kind of arrow for inheritance ("extends"). ------|>
b Draw this kind of arrow for interface ("implements"). - - - - -|>
c Draw this kind of arrow for "HAS-A" --------->
4 put method setWeapon() into right class.
[IMG]http://i46.tinypic.com/2vug8ea.jpg[/IMG]