예제 #1
0
        void Simulate()
        {
            IQuackable mallardDuck = new QuackCounter(new MallardDuck());
            IQuackable redheadDuck = new QuackCounter(new RedheadDuck());
            IQuackable duckCall    = new QuackCounter(new DuckCall());
            IQuackable rubberDuck  = new QuackCounter(new RubberDuck());
            IQuackable gooseDuck   = new GooseAdapter(new Goose());

            Console.WriteLine("Duck Simulator: With Decorator");

            Simulate(mallardDuck);
            Simulate(redheadDuck);
            Simulate(duckCall);
            Simulate(rubberDuck);
            Simulate(gooseDuck);

            Console.WriteLine("The ducks quacked " +
                              QuackCounter.Quacks + " times");

            // Wait for user
            Console.ReadKey();
        }
예제 #2
0
        void Simulate()
        {
            IQuackable mallardDuck = new QuackCounter(new MallardDuck());
            IQuackable redheadDuck = new QuackCounter(new RedheadDuck());
            IQuackable duckCall    = new QuackCounter(new DuckCall());
            IQuackable rubberDuck  = new QuackCounter(new RubberDuck());
            IQuackable gooseDuck   = new GooseAdapter(new Goose());

            Console.WriteLine("Duck Simulator: With Decorator");

            Simulate(mallardDuck);
            Simulate(redheadDuck);
            Simulate(duckCall);
            Simulate(rubberDuck);
            Simulate(gooseDuck);

            Console.WriteLine("The ducks quacked " +
                QuackCounter.Quacks + " times");

            // Wait for user
            Console.ReadKey();
        }