Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ООП
- {
- class Program
- {
- static void Main(string[] args)
- {
- Fighter[] fighters = { new Fighter("F0", 60, 6, 2), new Fighter("F1", 90, 5, 0), new Fighter("F2", 40, 8, 4) };
- int fighterIndex;
- for (int i = 0; i < fighters.Length; i++)
- {
- fighters[i].ShowStats();
- }
- Console.Write("Первый боец: ");
- fighterIndex = Convert.ToInt32(Console.ReadLine());
- Fighter firstFighter = fighters[fighterIndex];
- Console.Write("Второй боец: ");
- fighterIndex = Convert.ToInt32(Console.ReadLine());
- Fighter secondFighter = fighters[fighterIndex];
- while(firstFighter.Health > 0 && secondFighter.Health > 0)
- {
- Console.WriteLine();
- firstFighter.TakeDamage(secondFighter.Damage);
- secondFighter.TakeDamage(firstFighter.Damage);
- firstFighter.ShowStats();
- secondFighter.ShowStats();
- }
- }
- }
- class Fighter
- {
- private string _name;
- private int _health;
- private int _damage;
- private int _armor;
- public int Health
- {
- get
- {
- return _health;
- }
- }
- public int Damage
- {
- get
- {
- return _damage;
- }
- }
- public Fighter(string name, int health, int damage, int armor)
- {
- _name = name;
- _health = health;
- _damage = damage;
- _armor = armor;
- }
- public void ShowStats()
- {
- Console.WriteLine(_name + " HP:" + _health + " DMG:" + _damage + " ARM:" + _armor);
- }
- public void TakeDamage(int damage)
- {
- _health -= damage - _armor;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement