ballworld.model.strategy
Class DrunkenStrategy

java.lang.Object
  extended by ballworld.model.strategy.DrunkenStrategy
All Implemented Interfaces:
IUpdateStrategy

public class DrunkenStrategy
extends java.lang.Object
implements IUpdateStrategy

A strategy that, at every update, randomly selects from a set of 4 strategies to be run.

Author:
swong

Field Summary
private  IRandomizer rand
          Randomizer utility used to randomly select one of the possible strategies.
private  IUpdateStrategy s1
          One of the strategies to choose from
private  IUpdateStrategy s2
          One of the strategies to choose from
private  IUpdateStrategy s3
          One of the strategies to choose from
private  IUpdateStrategy s4
          One of the strategies to choose from
 
Constructor Summary
DrunkenStrategy()
          Constructor for the strategy.
 
Method Summary
 void updateState(Ball context)
          Randomly select one of the possible strategies and run it as the strategy for the context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s1

private IUpdateStrategy s1
One of the strategies to choose from


s2

private IUpdateStrategy s2
One of the strategies to choose from


s3

private IUpdateStrategy s3
One of the strategies to choose from


s4

private IUpdateStrategy s4
One of the strategies to choose from


rand

private IRandomizer rand
Randomizer utility used to randomly select one of the possible strategies.

Constructor Detail

DrunkenStrategy

public DrunkenStrategy()
Constructor for the strategy. Composee strategy initializations are being done here so that the composition lines will show up in a Green UML 3.5.0 diagram.

Method Detail

updateState

public void updateState(Ball context)
Randomly select one of the possible strategies and run it as the strategy for the context.

Specified by:
updateState in interface IUpdateStrategy
Parameters:
context - The host ball for this strategy.