void MiniDuckSimulator(void) {
    MallardDuck mallardDuck;
    RubberDuck rubberDuck;
    DecoyDuck decoyDuck;
    ModelDuck modelDuck;

    std::cout << "-------------------------" << std::endl;
    mallardDuck.display();
    mallardDuck.performQuack();
    mallardDuck.performFly();

    std::cout << "-------------------------" << std::endl;
    rubberDuck.display();
    rubberDuck.performQuack();
    rubberDuck.performFly();

    std::cout << "-------------------------" << std::endl;
    decoyDuck.display();
    decoyDuck.performQuack();
    decoyDuck.performFly();

    std::cout << "-------------------------" << std::endl;
    modelDuck.display();
    modelDuck.performQuack();
    modelDuck.performFly();
    modelDuck.setFlyBehaviour(new FlyRocketPowered());
    modelDuck.performFly();
}
Esempio n. 2
0
void playWithDucks() {
    using Patterns::MallardDuck;
    using Patterns::ModelDuck;
    MallardDuck mallard;
    mallard.performQuack();
    mallard.performFly();

    ModelDuck model;
    model.performFly();
    model.setFlyBehaviour(Patterns::FlyRocketPowered::create());
    model.performFly();
}