ballwar.model.strategy
Class AUpdateStrategy

java.lang.Object
  extended by ballwar.model.strategy.AUpdateStrategy
All Implemented Interfaces:
IUpdateStrategy
Direct Known Subclasses:
Change1Strategy, Change2Strategy, DrunkenStrategy, StraightStrategy

public abstract class AUpdateStrategy
extends Object
implements IUpdateStrategy

Abstract strategy that provides random initialization of a ball.


Field Summary
private static int _MaxRadius
          The maximum radius that a ball can have.
private static int _MaxSpeed
          The maximum speed a ball may have.
private  Rectangle _MaxVel
          The minimum and maximum values of a ball's velocityl.
private static int _MinRadius
          The minimum radius that a ball can have.
private static IRandomizer _Rand
          Randomizer to generate desired random value.
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
AUpdateStrategy()
           
 
Method Summary
 void init(Ball context)
          Initializes the ball with a random radius, velocity, location (within the bounds of the ball's environment) and color.
 void kill(Ball context)
          Calls the context's doKill() method to remove it from the system.
 void updateCollision(Ball context, Ball target)
          No-op.
abstract  void updateState(Ball context)
          Abstract behavior relegated to concrete subclass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_Rand

private static final IRandomizer _Rand
Randomizer to generate desired random value.


_MaxRadius

private static final int _MaxRadius
The maximum radius that a ball can have.

See Also:
Constant Field Values

_MinRadius

private static final int _MinRadius
The minimum radius that a ball can have.

See Also:
Constant Field Values

_MaxSpeed

private static final int _MaxSpeed
The maximum speed a ball may have.

See Also:
Constant Field Values

_MaxVel

private Rectangle _MaxVel
The minimum and maximum values of a ball's velocityl.

Constructor Detail

AUpdateStrategy

public AUpdateStrategy()
Method Detail

updateState

public abstract void updateState(Ball context)
Abstract behavior relegated to concrete subclass.

Specified by:
updateState in interface IUpdateStrategy
Parameters:
context - The ball to update.

init

public void init(Ball context)
Initializes the ball with a random radius, velocity, location (within the bounds of the ball's environment) and color. The ball's mass is set to be equal to its area.

Specified by:
init in interface IUpdateStrategy
Parameters:
context - The ball to initialize.

updateCollision

public void updateCollision(Ball context,
                            Ball target)
No-op.

Specified by:
updateCollision in interface IUpdateStrategy
Parameters:
context - not used
target - not used

kill

public void kill(Ball context)
Calls the context's doKill() method to remove it from the system.

Specified by:
kill in interface IUpdateStrategy
Parameters:
context - The ball to kill.