Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- //ЭТО ИЗ ЛЕКЦИИ, БУДЕТ ПЕРЕПИСОВАТЬСЯ!!!
- /*
- Fighter[] fighters = {
- new Fighter("Diego", 500, 50, 0),
- new Fighter("Milten", 250, 20, 25),
- new Fighter("Gorn", 300, 30, 10),
- new Fighter("Lester", 150, 100, 10),
- new Fighter("Saturas", 300, 30, 10)
- };
- for (int i = 0; i < fighters.Length; i++)
- {
- Console.Write($"{i + 1}.");
- fighters[i].ShowStats();
- }
- Console.Write("Выберете первого бойца: ");
- int firstFighterIndex = Convert.ToInt32(Console.ReadLine());
- Fighter firstFighter = fighters[firstFighterIndex-1];
- Console.Write("Выберете второго бойца: ");
- int secondFighterIndex = Convert.ToInt32(Console.ReadLine());
- Fighter secondFighter = fighters[secondFighterIndex-1];
- 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: {_name} || Health: {_health} || Damage: {_damage} || Armor: {_armor}");
- }
- public void TakeDamage(int damageDone)
- {
- int damage = damageDone - _armor;
- if (damage < 0)
- {
- damage = 0;
- }
- _health -= damage;
- }
- }
- class Mag : Fighter
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment