ballworld.model.strategy
Class SwitcherStrategy

java.lang.Object
  extended by ballworld.model.strategy.SwitcherStrategy
All Implemented Interfaces:
IUpdateStrategy

public class SwitcherStrategy
extends java.lang.Object
implements IUpdateStrategy

Decorator design pattern strategy that provides an indirection layer and encapsulation over another strategy, enabling it to be switched without disturbing the context ball.

Author:
swong

Field Summary
private  IUpdateStrategy _strategy
          The decoree strategy.
 
Constructor Summary
SwitcherStrategy()
          Constructor for the strategy.
 
Method Summary
 void setStrategy(IUpdateStrategy newStrategy)
          Set the decoree strategy to a new value
 void updateState(Ball context)
          Delegates to the decoree strategy as the context's strategy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_strategy

private IUpdateStrategy _strategy
The decoree strategy. A straight strategy by default.

Constructor Detail

SwitcherStrategy

public SwitcherStrategy()
Constructor for the strategy. Composee strategy initializations are being done here so that the composition lines will show up in a Green UML 3.5.0 diagram.

Method Detail

updateState

public void updateState(Ball context)
Delegates to the decoree strategy as the context's strategy.

Specified by:
updateState in interface IUpdateStrategy
Parameters:
context - The host ball for this strategy

setStrategy

public void setStrategy(IUpdateStrategy newStrategy)
Set the decoree strategy to a new value

Parameters:
newStrategy - The new strategy that wil set.