예제 #1
0
    static void Main(string[] args)
    {
        Duck mallard = new MallardDuck();

        mallard.Quack();
        mallard.Fly();

        Duck model = new ModelDuck();

        model.Fly();
        model.Fly = FlyRocketPowered;
        model.Fly();
    }
예제 #2
0
        static void Main(string[] args)
        {
            DuckBase mallard = new MallardDuck();

            mallard.Quack();
            mallard.Fly();

            DuckBase model = new ModelDuck();

            model.Fly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.Fly();

            Console.ReadLine();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Duck        modelDuck   = new ModelDuck();
            FlyBehavior flyBehavior = new FlyNoWay();

            modelDuck.FlyBehavior = flyBehavior;
            modelDuck.Fly();
            Console.ReadKey();
        }
예제 #4
0
        static void Main(string[] args)
        {
            MallardDuck mallard = new MallardDuck();

            mallard.Quack();
            mallard.SetQuackBehavior(new Squeak());
            Console.WriteLine("-- Change Quack Behavior --");
            mallard.Quack();

            Console.WriteLine("---------------------");

            var model = new ModelDuck("Model Duck");

            model.Fly();
            model.SetFlyBehavior(new FlyRocketPowered());
            Console.WriteLine("-- Change Quack Behavior --");
            model.Fly();
        }
예제 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Simulating Mullard Duck... \r\n");
            var mallard = new MullardDuck();

            mallard.Quack();
            mallard.Fly();

            Console.WriteLine("\r\nSimulating Model Duck... \r\n");
            var model = new ModelDuck();

            model.Quack();
            model.Fly();
            Console.Read();
        }