コード例 #1
0
        static void Main(string[] args)
        {
            //creating object of white duck
            Duck d = new WhiteDuck();

            d.Fly();
            d.Fb = new FlySlow();

            d.Quack();
            d.Fly();

            //creating object of red duck
            d = new RedDuck();
            d.Fly();
            d.Quack();

            //creating object of rubber duck
            d = new RubberDuck();
            d.Fly();
            d.Quack();

            //creating object of wooden duck
            d = new WoodenDuck();
            d.Fly();
            d.Quack();



            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Duck jungleDuck = new WildDuck(new DisplayingGraphically(), new HighFlying(), new LoudQuacking());

            jungleDuck.Fly();
            jungleDuck.Display();
            jungleDuck.Quack();

            Duck cityDuck = new RubberDuck(new DisplayingText(), new GroundFlying(), new NoQuacking());

            cityDuck.Fly();
            cityDuck.Display();
            cityDuck.Quack();
            Console.ReadLine();
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            WildDuck wildDuck = new WildDuck();

            wildDuck.Quack();
            wildDuck.Fly();

            RubberDuck rubberDuck = new RubberDuck();

            rubberDuck.Quack();
            rubberDuck.Fly();
            rubberDuck.Flying = new Flying();
            rubberDuck.Fly();


            Console.ReadLine();
        }