Package | Description |
---|---|
ballworld.model | |
ballworld.model.strategy |
Modifier and Type | Field and Description |
---|---|
private IUpdateStrategy |
Ball._updateStrategy
The strategy used to update the state of the ball
|
Modifier and Type | Method and Description |
---|---|
IUpdateStrategy |
Ball.getUpdateStrategy()
Returns the current strategy of this Ball
|
IUpdateStrategy |
BallModel.loadUpdateStrategy(java.lang.String className)
Uses dynamic class loading to load and instantiate an IUpdateStrategy implementation,
given its class name.
|
IUpdateStrategy |
IUpdateStrategyFac.make()
Instantiate the specific IUpdateStrategy for which this factory is
defined.
|
Modifier and Type | Method and Description |
---|---|
void |
BallModel.loadBall(IUpdateStrategy updateStrategy,
IPaintStrategy paintStrategy)
Load a ball into the system, where the ball uses the given update strategy instance.
|
void |
Ball.setUpdateStrategy(IUpdateStrategy strategy)
Sets the current strategy of this Ball to the given strategy
|
void |
BallModel.switchSwitcherStrategy(IUpdateStrategy strat)
Change the switcher strategy's decoree to the supplied strategy
|
Constructor and Description |
---|
Ball(java.awt.Point p,
int r,
java.awt.Point v,
java.awt.Color c,
java.awt.Component container,
IUpdateStrategy updateStrategy,
IPaintStrategy paintStrategy)
Initializes this Ball to a given center, radius, color, containing walls,
and the NullStrategy to move in a straight line.
|
Modifier and Type | Class and Description |
---|---|
class |
BreathingStrategy
Strategy to change the context ball's radius in a random sinusoidal manner
|
class |
Change1Strategy
A composite strategy that switches the context's strategy to a Change2Strategy
after a certain number of updates.
|
class |
Change2Strategy
This strategy does nothing (i.e.
|
class |
ColorStrategy
Strategy to randomly change the context ball's color.
|
class |
CurveStrategy
Strategy to make the ball curve in a circle
|
class |
DrunkenStrategy
A strategy that, at every update, randomly selects from a set of 4 strategies
to be run.
|
class |
MultiStrategy
A composite strategy of two strategies.
|
class |
StraightStrategy
Simple no-op strategy, which, alone, will make the ball go in a straight
line.
|
class |
SwitcherStrategy
Decorator design pattern strategy that provides an indirection layer and
encapsulation over another strategy, enabling it to be switched without
disturbing the context ball.
|
class |
WanderStrategy
Strategy that randomly changes the velocity of the context ball by adding random values to it.
|
Modifier and Type | Field and Description |
---|---|
private IUpdateStrategy |
MultiStrategy._s1
One of the composee strategies
|
private IUpdateStrategy |
MultiStrategy._s2
Another one of the composee strategies
|
private IUpdateStrategy |
SwitcherStrategy._strategy
The decoree strategy.
|
private IUpdateStrategy |
DrunkenStrategy.s1
One of the strategies to choose from
|
private IUpdateStrategy |
Change1Strategy.s1
One of the composee strategies
|
private IUpdateStrategy |
DrunkenStrategy.s2
One of the strategies to choose from
|
private IUpdateStrategy |
Change1Strategy.s2
One of the composee strategies
|
private IUpdateStrategy |
DrunkenStrategy.s3
One of the strategies to choose from
|
private IUpdateStrategy |
Change1Strategy.s3
One of the composee strategies
|
private IUpdateStrategy |
DrunkenStrategy.s4
One of the strategies to choose from
|
Modifier and Type | Method and Description |
---|---|
void |
SwitcherStrategy.setStrategy(IUpdateStrategy newStrategy)
Set the decoree strategy to a new value
|
Constructor and Description |
---|
MultiStrategy(IUpdateStrategy s1,
IUpdateStrategy s2)
Constructor for the class
|