ballwar.model
Interface IUpdateStrategy

All Known Implementing Classes:
ANoOpStrategy, AUpdateStrategy, BreathingStrategy, Change1Strategy, Change2Strategy, ColorStrategy, CurveStrategy, DrunkenStrategy, ExplodeStrategy, HeavyStrategy, KillStrategy, LightUpStrategy, MoveStrategy, MultiStrategy, RockStrategy, ScoreStrategy, StraightStrategy, SwitcherStrategy, WanderStrategy

public interface IUpdateStrategy

Interface that represents a strategy used by a Ball when asked to perform variant operations associated with initialization, updating its state, collisions and destruction.


Field Summary
static IUpdateStrategy NullObject
          Singleton null object instance of IUpdateStrategy that does nothing.
 
Method Summary
 void init(Ball context)
          Initializes the given ball.
 void updateCollision(Ball context, Ball target)
          updates the state of the ball in response to a collision between the two balls.
 void updateKill(Ball context)
          Processes a "killing" of a ball.
 void updateState(Ball context)
          Updates the state of the given ball in response to the periodic repainting of the ball as a part of its animation..
 

Field Detail

NullObject

static final IUpdateStrategy NullObject
Singleton null object instance of IUpdateStrategy that does nothing.

Method Detail

updateState

void updateState(Ball context)
Updates the state of the given ball in response to the periodic repainting of the ball as a part of its animation.. Used to modify the position, velocity, color, etc as the ball is moving.

Parameters:
context - The ball to update.

updateCollision

void updateCollision(Ball context,
                     Ball target)
updates the state of the ball in response to a collision between the two balls. It is assumed that the context ball is the one that just moved and collided with the target ball.

Parameters:
context - The ball that just moved and collided with the target ball.
target - The ball that was not moving and was collided by the context.

init

void init(Ball context)
Initializes the given ball. Called once by the ball when the strategy is first loaded.

Parameters:
context - The ball to initialize.

updateKill

void updateKill(Ball context)
Processes a "killing" of a ball. Called when a ball's kill() method is called. A ball will only be removed from the system if its doKill() method is called, perhaps from the strategy's kill() method.

Parameters:
context - The ball who's kill method was called.