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("Лев", 5 ,"Рычит", "Самец"), new Animal("Панда", 2, "Хруст бамбука", "Самец"),
- new Animal("Депутаты", 99,"быстро принимают законы о поправках", "Дураки"), new Animal("", 10,"белка шумит", "Самки")};
- while (true)
- {
- Console.WriteLine("1 - Лев\n2 - Панда\n3 - Депутаты\n4 - Белка");
- Console.Write("Введите команду: ");
- int userInpyt = Convert.ToInt32(Console.ReadLine());
- if (userInpyt >= 0 && userInpyt <= animals.Count)
- {
- animals[userInpyt - 1].InfoAviary();
- }
- Console.WriteLine("Нажми кнопку чтобы вернуться на тропу...");
- Console.ReadKey();
- Console.Clear();
- }
- }
- }
- class Animal : Aviary
- {
- public string _soundAnimal;
- private string _floor;
- public Animal(string nameAviary, int population, string soundAnimal, string floor)
- {
- _soundAnimal = soundAnimal;
- _floor = floor;
- _nameAviary = nameAviary;
- _population = population;
- }
- public void InfoAviary()
- {
- Console.WriteLine("Название вида: " + _nameAviary + " | Популяция: " + _population + " | Пол: " + _floor + " | Издают звуки: " + _soundAnimal);
- }
- }
- class Aviary
- {
- protected private string _nameAviary;
- protected private int _population;
- public Aviary()
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement