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 updateCollision(Ball context, Ball target)
          No-op.
 void updateKill(Ball context)
          Calls the context's doKill() method to remove it from the system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ballwar.model.IUpdateStrategy
updateState
 

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

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

updateKill

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

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