Exemple #1
0
        static void Main(string[] args)
        {
            DuckStorage duckstorage = DuckStorage.Get();        //создаем склад

            Console.WriteLine("Рождение живых уток...");
            for (int i = 0; i < 5; i++)
            {
                Duck duck = new Duck();                     //создаем уток и добавляем на склад
                duckstorage.Add(duck.Name);
            }


            Console.WriteLine("Вырезание деревянных уточек...");
            for (int i = 0; i < 8; i++)
            {
                WoodenDuck woodenduck = new WoodenDuck();
                duckstorage.Add(woodenduck.Name);
            }


            Console.WriteLine("Выплавление железных уток...");
            for (int i = 0; i < 4; i++)
            {
                IronDuck ironduck = new IronDuck();
                duckstorage.Add(ironduck.Name);
            }

            Console.WriteLine("На складе имеется:");
            foreach (KeyValuePair <string, int> keyValue in duckstorage.Storage)          //извлечение значений из словаря
            {
                Console.WriteLine(keyValue.Key + ": " + keyValue.Value + " штук");
            }

            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //создаем разных уток и заставляем их рассказывать о себе
            Duck duck = new Duck();

            Console.WriteLine(duck.Name + ":\n");
            duck.Fly();
            duck.Quack();
            duck.Swim();

            WoodenDuck woodenduck = new WoodenDuck();

            Console.WriteLine("\n" + woodenduck.Name + ":\n");
            woodenduck.Fly();
            woodenduck.Quack();
            woodenduck.Swim();

            IronDuck ironduck = new IronDuck();

            Console.WriteLine("\n" + ironduck.Name + ":\n");
            ironduck.Fly();
            ironduck.Quack();
            ironduck.Swim();
            Console.ReadLine();
        }
Exemple #3
0
        static void Main()
        {
            Duck littleDuck = new RubberDuck();
            Duck woodenDuck = new WoodenDuck();
            Duck simleDuck  = new SimpleDuck();
            Duck fakeDuck   = new FakeDuck();

            Console.WriteLine("1st duck");
            littleDuck.PerformFly();
            littleDuck.PerformQuack();
            littleDuck.Swim();

            Console.WriteLine("\n");

            Console.WriteLine("2nd duck");
            woodenDuck.PerformFly();
            woodenDuck.PerformQuack();
            woodenDuck.Swim();

            Console.WriteLine("\n");

            Console.WriteLine("3rd duck");
            simleDuck.PerformFly();
            simleDuck.PerformQuack();
            simleDuck.Swim();

            Console.WriteLine("\n");

            Console.WriteLine("4th duck");
            fakeDuck.PerformFly();
            fakeDuck.PerformQuack();
            fakeDuck.Swim();

            Console.ReadKey();
        }
        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();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            DuckRepository duckstorage = DuckRepository.Get();

            for (int i = 0; i < 4; i++)
            {
                Duck duck = new Duck();
                duckstorage.Add(duck.name);
            }

            for (int i = 0; i < 7; i++)
            {
                WoodenDuck woodenduck = new WoodenDuck();
                duckstorage.Add(woodenduck.name);
            }

            for (int i = 0; i < 10; i++)
            {
                RubberDuck rubberduck = new RubberDuck();
                duckstorage.Add(rubberduck.name);
            }

            Console.WriteLine("На складе имеется:");
            foreach (KeyValuePair <string, int> keyValue in duckstorage.Storage)
            {
                Console.WriteLine(keyValue.Key + ": " + keyValue.Value + " штук");
            }

            Console.ReadLine();
        }
Exemple #6
0
        public void CheckWoodenDuck()
        {
            var wd = new WoodenDuck();

            wd.Show();
            wd.Fly();
            wd.Quack();
            wd.Swim();
        }
Exemple #7
0
    public static void Main(string[] args)
    {
        RealDuck duck = new RealDuck();

        duck.Hello();
        duck.Swim();
        duck.SetSwim(new SwimDisability());
        duck.Swim();

        Console.WriteLine();

        WoodenDuck woodenDuck = new WoodenDuck();

        woodenDuck.Hello();
        woodenDuck.Fly();
    }
Exemple #8
0
        static void Test1()
        {
            Console.WriteLine("Тест 1(Создание уточек):");
            UsualDuck duck1 = new UsualDuck();

            Info(duck1);
            SmallDuck duck2 = new SmallDuck();

            Info(duck2);
            WoodenDuck duck3 = new WoodenDuck();

            Info(duck3);
            Info(new DecoyDuck());
            Info(new RubberDuck());
            IDuck duck4 = new RoboDuck();

            Info(duck4);
        }
Exemple #9
0
        static void Main(string[] args)
        {
            Duck exp1 = new Duck();

            Console.WriteLine("Я живая утка:\n");
            exp1.Fly();
            exp1.Swim();
            exp1.Quack();
            WoodenDuck exp2 = new WoodenDuck();

            Console.WriteLine("\nЯ деревянная утка:\n");
            exp2.Fly();
            exp2.Swim();
            exp2.Quack();
            RubberDuck exp3 = new RubberDuck();

            Console.WriteLine("\nЯ резиновая утка:\n");
            exp3.Fly();
            exp3.Swim();
            exp3.Quack();
            Console.ReadLine();
        }