ballwar.model.strategy
Class MultiStrategy

java.lang.Object
  extended by ballwar.model.strategy.ANoOpStrategy
      extended by ballwar.model.strategy.MultiStrategy
All Implemented Interfaces:
IUpdateStrategy

public class MultiStrategy
extends ANoOpStrategy

An ANoOpStrategy-based strategy that is the composition of two IUpdateStrategies. All behaviors are delegated sequentially to each of the composees.


Field Summary
private  IUpdateStrategy _s1
          First IUpdateStrategy composee
private  IUpdateStrategy _s2
          Second IUpdateStrategy composee
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
MultiStrategy(IUpdateStrategy s1, IUpdateStrategy s2)
          Constructor for the class.
 
Method Summary
 void init(Ball context)
          Initializes the context with the first then the second composee.
 void kill(Ball context)
          Delegates the kill request to the first then the second composee.
 void updateCollision(Ball context, Ball target)
          Delegates first to the first composee and then to the second composee.
 void updateState(Ball context)
          Updates the state of the context with the first composee and then the second composee.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_s1

private IUpdateStrategy _s1
First IUpdateStrategy composee


_s2

private IUpdateStrategy _s2
Second IUpdateStrategy composee

Constructor Detail

MultiStrategy

public MultiStrategy(IUpdateStrategy s1,
                     IUpdateStrategy s2)
Constructor for the class.

Parameters:
s1 - The first IUpdateStrategy composee
s2 - The second IUpdateStrategy composee
Method Detail

updateState

public void updateState(Ball context)
Updates the state of the context with the first composee and then the second composee.

Specified by:
updateState in interface IUpdateStrategy
Overrides:
updateState in class ANoOpStrategy
Parameters:
context - This strategy's context.

init

public void init(Ball context)
Initializes the context with the first then the second composee.

Specified by:
init in interface IUpdateStrategy
Overrides:
init in class ANoOpStrategy
Parameters:
context - This strategy's context.

updateCollision

public void updateCollision(Ball context,
                            Ball target)
Delegates first to the first composee and then to the second composee.

Specified by:
updateCollision in interface IUpdateStrategy
Overrides:
updateCollision in class ANoOpStrategy
Parameters:
context - This strategy's context.
target - The ball the context collided with.

kill

public void kill(Ball context)
Delegates the kill request to the first then the second composee. Note that the first composee may call the context's doKill() method, removing it from the system. The context is not yet garbage collected, so the second composee can execute normally, though perhaps without effect.

Specified by:
kill in interface IUpdateStrategy
Overrides:
kill in class ANoOpStrategy
Parameters:
context - This strategy's context.