Advertisement
LeRoY_Go

Untitled

Jul 19th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp6
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. List<Animal> animals = new List<Animal>
  11. { new Animal("Лев", 5 ,"Рычит", "Самец"), new Animal("Панда", 2, "Хруст бамбука", "Самец"),
  12. new Animal("Депутаты", 99,"быстро принимают законы о поправках", "Дураки"), new Animal("", 10,"белка шумит", "Самки")};
  13. while (true)
  14. {
  15. Console.WriteLine("1 - Лев\n2 - Панда\n3 - Депутаты\n4 - Белка");
  16. Console.Write("Введите команду: ");
  17. int userInpyt = Convert.ToInt32(Console.ReadLine());
  18. if (userInpyt >= 0 && userInpyt <= animals.Count)
  19. {
  20. animals[userInpyt - 1].InfoAviary();
  21. }
  22. Console.WriteLine("Нажми кнопку чтобы вернуться на тропу...");
  23. Console.ReadKey();
  24. Console.Clear();
  25. }
  26. }
  27. }
  28.  
  29. class Animal : Aviary
  30. {
  31. public string _soundAnimal;
  32. private string _floor;
  33.  
  34. public Animal(string nameAviary, int population, string soundAnimal, string floor)
  35. {
  36. _soundAnimal = soundAnimal;
  37. _floor = floor;
  38. _nameAviary = nameAviary;
  39. _population = population;
  40. }
  41.  
  42. public void InfoAviary()
  43. {
  44. Console.WriteLine("Название вида: " + _nameAviary + " | Популяция: " + _population + " | Пол: " + _floor + " | Издают звуки: " + _soundAnimal);
  45. }
  46. }
  47.  
  48. class Aviary
  49. {
  50. protected private string _nameAviary;
  51. protected private int _population;
  52. public Aviary()
  53. {
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement