Advertisement
dmitryEfremov

Untitled

Jun 7th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1.  
  2. using System;
  3.  
  4. namespace ConsoleApp11
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Player player = new Player("Dmitry");
  11. player.Damage = 101;
  12. player.Armor = 102;
  13. player.Health = 100;
  14. player.Show();
  15. }
  16. }
  17.  
  18. class Player
  19. {
  20. Name name = null;
  21. Armor armor = null;
  22. Damage damage = null;
  23. Health health = null;
  24.  
  25. void InitializePlayer()
  26. {
  27. this.name = new Name();
  28. this.health = new Health();
  29. this.damage = new Damage();
  30. this.armor = new Armor();
  31. }
  32.  
  33. public Player(string name)
  34. {
  35. InitializePlayer();
  36. this.name.Content = name;
  37. }
  38.  
  39. public void Show()
  40. {
  41. this.name.Show();
  42. this.damage.Show();
  43. this.armor.Show();
  44. this.health.Show();
  45. }
  46.  
  47. public int Damage
  48. {
  49. set
  50. {
  51. this.damage.Content = value;
  52. }
  53. }
  54.  
  55. public int Health
  56. {
  57. set
  58. {
  59. this.health.Content = value;
  60. }
  61. }
  62.  
  63. public int Armor
  64. {
  65. set
  66. {
  67. this.armor.Content = value;
  68. }
  69. }
  70. }
  71.  
  72. class Name
  73. {
  74. private string content;
  75.  
  76. public string Content
  77. {
  78. private get
  79. {
  80. if (content != null)
  81. return content;
  82. else
  83. return "Имя отсутствует";
  84. }
  85. set
  86. {
  87. content = value;
  88. }
  89. }
  90.  
  91. public void Show()
  92. {
  93. Console.ForegroundColor = ConsoleColor.Yellow;
  94. Console.WriteLine(Content);
  95. Console.ForegroundColor = ConsoleColor.Gray;
  96. }
  97. }
  98.  
  99. class Armor
  100. {
  101. private int content;
  102.  
  103. public int Content
  104. {
  105. private get
  106. {
  107. return content;
  108. }
  109. set
  110. {
  111. content = value;
  112. }
  113. }
  114.  
  115. public void Show()
  116. {
  117. Console.ForegroundColor = ConsoleColor.Cyan;
  118. Console.WriteLine($"Бронь={Content}");
  119. Console.ForegroundColor = ConsoleColor.Gray;
  120. }
  121. }
  122.  
  123. class Damage
  124. {
  125. private int content;
  126.  
  127. public int Content
  128. {
  129. private get
  130. {
  131. return content;
  132. }
  133. set
  134. {
  135. content = value;
  136. }
  137. }
  138.  
  139. public void Show()
  140. {
  141. Console.ForegroundColor = ConsoleColor.Red;
  142. Console.WriteLine($"Урон={Content}");
  143. Console.ForegroundColor = ConsoleColor.Gray;
  144. }
  145. }
  146.  
  147. class Health
  148. {
  149. private int content;
  150.  
  151. public int Content
  152. {
  153. private get
  154. {
  155. return content;
  156. }
  157. set
  158. {
  159. content = value;
  160. }
  161. }
  162.  
  163. public void Show()
  164. {
  165. Console.ForegroundColor = ConsoleColor.Green;
  166. Console.WriteLine($"Здоровье={Content}");
  167. Console.ForegroundColor = ConsoleColor.Gray;
  168. }
  169. }
  170.  
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement