Exemple #1
0
        static void Main(string[] args)
        {
            Eagle orzelPrawdziwy = new Eagle();
            //orzelPrawdziwy.Hello();
            var orzełJednakPtak = (Bird)orzelPrawdziwy;
            //orzełJednakPtak.Hello();

            IFlyable orzel = new Eagle();

            //orzel.Fly();

            IFlyable[] ptaki = new IFlyable[2];
            ptaki[0] = new Eagle();
            ptaki[1] = new Duck();
            ptaki[1].Fly();
            ptaki[0].Fly();

            var pingwinPingwin = new Penguin();

            pingwinPingwin.Swim();

            var pingwinPtak = (ISwimmable) new Penguin();

            pingwinPtak.Swim();
        }
        static void Main(String[] args)
        {
            Eagle   eagle   = new Eagle();
            Penguin penguin = new Penguin();
            Fowl    fowl    = new Fowl();

            Animal[] animalList = { eagle, penguin, fowl };

            foreach (Animal eachAnimal in animalList)
            {
                if (eachAnimal.IsBird())
                {
                    Console.WriteLine("{0} is bird \n", eachAnimal);
                }
                else
                {
                    Console.WriteLine("{0} is not bird \n", eachAnimal);
                }
            }
            Console.ReadKey();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            try
            {
                Kiwi kiwi_1 = new Kiwi(13, 13, 25);
                Console.WriteLine(kiwi_1);

                Duck duck_1 = new Duck(13, 13, 3);
                Console.WriteLine(duck_1);
                CheckFlySwim(duck_1);

                Penguin penguin_1 = new Penguin(13, 13, false);
                Console.WriteLine(penguin_1);
                penguin_1.swim();

                Parrot parrot_1 = new Parrot(13, 13, Parrot.Colours.Red);
                Console.WriteLine(parrot_1);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Duck dk = new Duck("Желтоносая кряква", "Водоёмы", 200000);

            dk.GetInfo();
            dk.Swims();
            try
            {
                dk.Weight = 34;
            }
            catch (Exception)
            {
                Console.WriteLine("Утки столько не весят!");
            }
            Kiwi kw = new Kiwi("Южный киви", "тропики", 70000);

            kw.Food = "зерна";
            kw.Eat();
            Penguin pg = new Penguin("Императорский пингвин", "Антарктика", 150000);

            try
            {
                pg.Lifespan = 300;
            }
            catch (Exception)
            {
                Console.WriteLine("Пингвины столько не живут!");
            }
            pg.Sit_on_eggs(5);
            pg.Swims();
            Budgerigar br = new Budgerigar("Волнистый попугайчик", "Австралия", 45000);

            br.Body_length = 10;
            Console.WriteLine("Длины тела волнистого попугайчика - {0}", br.Body_length);
            br.Speak("Дарова, отец!");
            Console.ReadKey();
        }