Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7.  
  8.  
  9. Avatar[] Avatars = new Avatar[2] { new Avatar(), new Avatar()};
  10.  
  11.  
  12. Console.WriteLine("Введите имя Хомяка №1 :");
  13. Avatars[0].Name = Console.ReadLine();
  14.  
  15. Console.WriteLine("Введите имя Хомяка №2 :");
  16. Avatars[1].Name = Console.ReadLine();
  17.  
  18. //Avatars[1].Feed(20);
  19. //Avatars[0].Feed(10);
  20.  
  21.  
  22.  
  23. Console.WriteLine("Кому подкинуть хавки? :");
  24.  
  25. switch (Console.ReadLine())
  26. {
  27.  
  28. case "Avatars[0].Name":
  29.  
  30. Avatars[0].Feed(-10);
  31. break;
  32.  
  33. case "Avatars[1].Name":
  34.  
  35. Avatars[1].Feed(-20);
  36. break;
  37.  
  38. default:
  39.  
  40. break;
  41.  
  42.  
  43. }
  44.  
  45. Console.WriteLine(Avatars[1].Hunger);
  46. Console.WriteLine(Avatars[0].Hunger);
  47.  
  48. }
  49.  
  50.  
  51. }
  52.  
  53. class Avatar
  54. {
  55. public int Money, Fatigue, Hunger;
  56. public string Name;
  57.  
  58. public void Feed(int foodCount)
  59. {
  60.  
  61.  
  62. this.Hunger -= foodCount;
  63. this.Fatigue += foodCount / 4;
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement