ballwar.model.strategy
Class Change1Strategy

java.lang.Object
  extended by ballwar.model.strategy.AUpdateStrategy
      extended by ballwar.model.strategy.Change1Strategy
All Implemented Interfaces:
IUpdateStrategy

public class Change1Strategy
extends AUpdateStrategy

A strategy that demonstrates self-modifying behavior by replacing itself with another strategy after a certain length of time. Based on AUpdateStrategy, so it randomly initializes the ball.


Field Summary
private  int i
          The counter that deternines the number of updates before this strategy replaces itself in its context.
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
Change1Strategy()
           
 
Method Summary
 void updateState(Ball context)
          If the counter is zero, sets the context's strategy to a new Change2Strategy.
 
Methods inherited from class ballwar.model.strategy.AUpdateStrategy
init, kill, updateCollision
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i

private int i
The counter that deternines the number of updates before this strategy replaces itself in its context.

Constructor Detail

Change1Strategy

public Change1Strategy()
Method Detail

updateState

public void updateState(Ball context)
If the counter is zero, sets the context's strategy to a new Change2Strategy. Otherwise, decrements the counter.

Specified by:
updateState in interface IUpdateStrategy
Specified by:
updateState in class AUpdateStrategy
Parameters:
context - The strategy's context.