change the flight in strategy
This commit is contained in:
parent
8284e0f476
commit
e9712fdf28
|
@ -1,6 +1,7 @@
|
|||
module strategy.app;
|
||||
|
||||
import strategy.duck;
|
||||
import strategy.flybehavior;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -11,4 +12,6 @@ void main()
|
|||
Duck model = new ModelDuck;
|
||||
model.performQuack();
|
||||
model.performFly();
|
||||
model.setFlyBehavior(new FlyRocketPowered);
|
||||
model.performFly();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,16 @@ abstract class Duck
|
|||
{
|
||||
writeln("All ducks float, even decoys!");
|
||||
}
|
||||
|
||||
void setFlyBehavior(FlyBehavior fb)
|
||||
{
|
||||
flyBehavior = fb;
|
||||
}
|
||||
|
||||
void setQuackBehavior(QuackBehavior qb)
|
||||
{
|
||||
quackBehavior = qb;
|
||||
}
|
||||
}
|
||||
|
||||
class MallardDuck : Duck
|
||||
|
|
Reference in New Issue