Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp6
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Animal> animals = new List<Animal> { new Animal("Кот", "Мурчит", 2, "Самец"), new Animal("Лев", "Рычит", 5, "Самец"), new Animal("Депутаты", "быстро принимают законы о поправках", 119, "Дураки"), new Animal("Белка", "белка шумит", 17, "Самки") };
- while (true)
- {
- Console.WriteLine("1 - Лев\n2 - Панда\n3 - Депутаты\n4 - Белка");
- Console.Write("Введите команду: ");
- string userInpyt = Console.ReadLine();
- switch (userInpyt)
- {
- case "1":
- animals[0].gergr();
- break;
- case "2":
- animals[1].gergr();
- break;
- case "3":
- animals[2].gergr();
- break;
- case "4":
- animals[3].gergr();
- break;
- }
- Console.WriteLine("Нажми кнопку чтобы вернуться на тропу...");
- Console.ReadKey();
- Console.Clear();
- }
- }
- }
- class Animal
- {
- private string _nameAnimal;
- private string _soundAnimal;
- private int _population;
- private string _floor;
- public Animal(string nameAnimal, string soundAnimal, int population, string floor)
- {
- _nameAnimal = nameAnimal;
- _soundAnimal = soundAnimal;
- _population = population;
- _floor = floor;
- }
- public void gergr()
- {
- Console.WriteLine("Название вида: " + _nameAnimal + " | Популяция: " + _population + " | Пол: " + _floor + " | Издают звуки: " + _soundAnimal);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement