Abdula_2314124

Untitled

May 12th, 2024
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System.ComponentModel;
  2.  
  3. namespace Player
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. Player andriy = new Player(20,100,150,90,100);
  10. Player ivan = new Player(20,100,150,90,100);
  11. andriy.SetPosition(6, 6, 6);
  12. andriy.Move();
  13. andriy.AddHealth(5);
  14. andriy.RemoveHealth(5);
  15. }
  16. }
  17. class Player
  18. {
  19. private int _speed;
  20. private int _stamina;
  21. private int _health;
  22.  
  23.  
  24. private float _x;
  25. private float _y;
  26. private float _z;
  27.  
  28. public Player(int speed, int stamina, int health, int damage, int armor)
  29. {
  30. _speed = speed;
  31. _stamina = stamina;
  32. _health = health;
  33. }
  34.  
  35. public void Move()
  36. {
  37. _x++;
  38. _y++;
  39. _z++;
  40. _stamina -= 10;
  41.  
  42. Console.WriteLine($"Я на позиції {_x},{_y},{_z}," +
  43. $" рухався зі скорістю {_speed}, " +
  44. $"мій запас сил {_stamina}");
  45. }
  46.  
  47. public void SetPosition(float x, float y, float z)
  48. {
  49. _x = x;
  50. _y = y;
  51. _z = z;
  52. Console.WriteLine($"Я на позиції {_x},{_y},{_z}");
  53. }
  54.  
  55. public void AddHealth(int value)
  56. {
  57. if (value > 0)
  58. {
  59. _health += value;
  60. }
  61. else
  62. {
  63. Console.WriteLine("Ей - на - буде -");
  64. }
  65. }
  66.  
  67. public void RemoveHealth(int value)
  68. {
  69. if (value > 0)
  70. {
  71. _health -= value;
  72. }
  73. else
  74. {
  75. Console.WriteLine("Ей - на - буде -");
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment