|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectballwar.model.strategy.SwitcherStrategy
public class SwitcherStrategy
A Decorator design pattern strategy that decorates an IUpdateStrategy, enabling the strategy (the decoree) to be switched at run-time. All methods, except setStrategy() are delegated to the decoree.
| Field Summary | |
|---|---|
private IUpdateStrategy |
_strategy
|
| Fields inherited from interface ballwar.model.IUpdateStrategy |
|---|
NullObject |
| Constructor Summary | |
|---|---|
SwitcherStrategy()
|
|
| Method Summary | |
|---|---|
void |
init(Ball context)
Initializes the context using the decoree strategy. |
void |
setStrategy(IUpdateStrategy newStrategy)
Sets the decoree to reference the given strategy. |
void |
updateCollision(Ball context,
Ball target)
Processes the collision using the decoree. |
void |
updateKill(Ball context)
Process the context's kill request using the decoree. |
void |
updateState(Ball context)
Updates the state of the context using the decoree. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private IUpdateStrategy _strategy
| Constructor Detail |
|---|
public SwitcherStrategy()
| Method Detail |
|---|
public void init(Ball context)
init in interface IUpdateStrategycontext - The context for this and the decoree strategy.public void updateState(Ball context)
updateState in interface IUpdateStrategycontext - The context for this and the decoree strategy.
public void updateCollision(Ball context,
Ball target)
updateCollision in interface IUpdateStrategycontext - The context for this and the decoree strategy.target - The ball that the context with which the context has collided.public void updateKill(Ball context)
updateKill in interface IUpdateStrategycontext - The context for this and the decoree strategy.public void setStrategy(IUpdateStrategy newStrategy)
newStrategy - The new decoree.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||