public void main()
 {
     Duck mallard = new MallardDuck();
     mallard.display();
     mallard.performQuack();
     mallard.performFly();
 }
示例#2
0
        public void main()
        {
            Duck mallard = new MallardDuck();
            mallard.display();
            mallard.performQuack();
            mallard.performFly();

            // otro pato

            Duck model = new ModelDuck();
            model.display();
            model.performQuack();
            model.performFly();
            //cambio de vuelo
            model.setFlyBehavior(new FlyRocketPowered());
            model.performFly();
        }