示例#1
0
        static void Main(string[] args)
        {
            Horse Horsey = new Horse();

            Horsey.Speak("Horsey");
            Horsey.Eat();
            Horsey.Move();
            Horsey.Produce();
            Horsey.Food();

            Chicken Chickie = new Chicken();

            Chickie.Speak("Chickie");
            Chickie.Eat();
            Chickie.Move();
            Chickie.Produce();
            Chickie.Food();

            Cow Cowie = new Cow();

            Cowie.Speak("Cowie");
            Cowie.Eat();
            Cowie.Move();
            Cowie.Produce();
            Cowie.Food();

            Pig Piggie = new Pig();

            Piggie.Speak("Piggie");
            Piggie.Eat();
            Piggie.Move();
            Piggie.Produce();
            Piggie.Food();
        }
示例#2
0
        static void Main(string[] args)
        {
            Farm   farm   = new Farm("Айыл Чарба", "г.Бишкек ул.Чуй №182");
            Animal cow    = new Cow("Уй", 2, "Ж", 740);
            Animal cow1   = new Cow("Бука", 2, "М", 760);
            Sheep  sheep  = new Sheep("Кой", 5, "Ж", 48);
            Sheep  sheep1 = new Sheep("Кочкор", 3, "М", 60);
            Animal horse  = new Horse("Ат", 7, "М", 650);
            Animal horse1 = new Horse("Бээ", 7, "Ж", 650);

            cow.Eat();
            sheep.Eat();
            horse.Eat();

            while (true)
            {
                farm.FullInfo();
                Console.Write("Для добавление животных в ферму выберите из списка " +
                              "\ncow-->уй\tcow1-->бука\nsheep-->кой\tsheep1-->кочкор\nhorse-->ат\thorse1-->бээ\n>");

                var input = Console.ReadLine().ToLower();

                switch (input)
                {
                case "cow":
                    farm.AddCow(cow); break;

                case "cow1":
                    farm.AddCow(cow1); break;

                case "sheep":
                    farm.AddSheep(sheep); break;

                case "sheep1":
                    farm.AddSheep(sheep1); break;

                case "horse":
                    farm.AddHorse(horse); break;

                case "horse1":
                    farm.AddHorse(horse1); break;

                default:
                    break;
                }
            }
        }
示例#3
0
        private static void Menu2(int menu)
        {
            int menu2 = Convert.ToInt32(Console.ReadLine());

            if (menu2 == 1)
            {
                Horse horse1 = new Horse();
                horse1.Speak();
                Animal1();
                Menu2(menu);
            }
            else if (menu2 == 2)
            {
                Horse horse1 = new Horse();
                horse1.Eat();
                Animal1();
                Menu2(menu);
            }
            else if (menu2 == 3)
            {
                Horse horse1 = new Horse();
                horse1.Run();
                Animal1();
                Menu2(menu);
            }
            else if (menu2 == 4)
            {
                Horse horse1 = new Horse();
                horse1.Attack();
                Animal1();
                Menu2(menu);
            }
            else
            {
                Menu();
            }
        }