ballwar.model.strategy
Class Change2Strategy

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

public class Change2Strategy
extends AUpdateStrategy

Similar self-modifying behavior to Change1Strategy. After a period of time, replaces itself with a new Change1Strategy. Randomly changes its color when updateState is called. Based on AUpdateStrategy, so it randomly initializes the ball.


Field Summary
private  int i
          Counter that determines the number of updates before this strategy replaces itself.
private  IRandomizer rand
          Randomizer to generate random colors
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
Change2Strategy()
           
 
Method Summary
 void updateState(Ball context)
          Sets the context's color to a random color.
 
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

rand

private IRandomizer rand
Randomizer to generate random colors


i

private int i
Counter that determines the number of updates before this strategy replaces itself.

Constructor Detail

Change2Strategy

public Change2Strategy()
Method Detail

updateState

public void updateState(Ball context)
Sets the context's color to a random color. If the count is zero, sets the context's strategy to a new Change1Strategy. otherwise, decrements the counter.

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