Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.ComponentModel;
- namespace Player
- {
- class Program
- {
- static void Main(string[] args)
- {
- Player andriy = new Player(20,100,150,90,100);
- Player ivan = new Player(20,100,150,90,100);
- andriy.SetPosition(6, 6, 6);
- andriy.Move();
- andriy.AddHealth(5);
- andriy.RemoveHealth(5);
- }
- }
- class Player
- {
- private int _speed;
- private int _stamina;
- private int _health;
- private float _x;
- private float _y;
- private float _z;
- public Player(int speed, int stamina, int health, int damage, int armor)
- {
- _speed = speed;
- _stamina = stamina;
- _health = health;
- }
- public void Move()
- {
- _x++;
- _y++;
- _z++;
- _stamina -= 10;
- Console.WriteLine($"Я на позиції {_x},{_y},{_z}," +
- $" рухався зі скорістю {_speed}, " +
- $"мій запас сил {_stamina}");
- }
- public void SetPosition(float x, float y, float z)
- {
- _x = x;
- _y = y;
- _z = z;
- Console.WriteLine($"Я на позиції {_x},{_y},{_z}");
- }
- public void AddHealth(int value)
- {
- if (value > 0)
- {
- _health += value;
- }
- else
- {
- Console.WriteLine("Ей - на - буде -");
- }
- }
- public void RemoveHealth(int value)
- {
- if (value > 0)
- {
- _health -= value;
- }
- else
- {
- Console.WriteLine("Ей - на - буде -");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment