Advertisement
LeRoY_Go

Untitled

Jul 11th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 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> { new Animal("Кот", "Мурчит", 2, "Самец"), new Animal("Лев", "Рычит", 5, "Самец"), new Animal("Депутаты", "быстро принимают законы о поправках", 119, "Дураки"), new Animal("Белка", "белка шумит", 17, "Самки") };
  11. while (true)
  12. {
  13. Console.WriteLine("1 - Лев\n2 - Панда\n3 - Депутаты\n4 - Белка");
  14. Console.Write("Введите команду: ");
  15. string userInpyt = Console.ReadLine();
  16. switch (userInpyt)
  17. {
  18. case "1":
  19. animals[0].gergr();
  20. break;
  21. case "2":
  22. animals[1].gergr();
  23. break;
  24. case "3":
  25. animals[2].gergr();
  26. break;
  27. case "4":
  28. animals[3].gergr();
  29. break;
  30. }
  31. Console.WriteLine("Нажми кнопку чтобы вернуться на тропу...");
  32. Console.ReadKey();
  33. Console.Clear();
  34. }
  35. }
  36. }
  37.  
  38. class Animal
  39. {
  40. private string _nameAnimal;
  41. private string _soundAnimal;
  42. private int _population;
  43. private string _floor;
  44.  
  45. public Animal(string nameAnimal, string soundAnimal, int population, string floor)
  46. {
  47. _nameAnimal = nameAnimal;
  48. _soundAnimal = soundAnimal;
  49. _population = population;
  50. _floor = floor;
  51. }
  52.  
  53. public void gergr()
  54. {
  55. Console.WriteLine("Название вида: " + _nameAnimal + " | Популяция: " + _population + " | Пол: " + _floor + " | Издают звуки: " + _soundAnimal);
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement