Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Policy;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Linq;
- namespace Гладиаторские_бои
- {
- class Program
- {
- static void Main(string[] args)
- {
- Fighters[] fighters = new Fighters[] {new Healthy("Фёдр", 111, 11), new Strong("Саша", 62, 36), new Fast("Никита", 61, 30), new Dexterous("Роман", 100, 25), new Wimp("Алекс", 41, 47) };
- for (int i = 0; i < fighters.Length; i++)
- {
- Console.Write($"{i}.");
- fighters[i].ShowStatistics();
- }
- Console.Write("\nВыберите номер 1-ого бойца:");
- var firstFighter = fighters[Convert.ToInt32(Console.ReadLine())];
- Console.Write("Выберите номер 2-ого бойца:");
- var secondFighter = fighters[Convert.ToInt32(Console.ReadLine())];
- Console.Clear();
- firstFighter.ShowStatistics();
- secondFighter.ShowStatistics();
- while (firstFighter.Health > 0 && secondFighter.Health > 0)
- {
- Console.WriteLine();
- firstFighter.TakeDamage(secondFighter.Damage);
- firstFighter.Ability();
- secondFighter.TakeDamage(firstFighter.Damage);
- secondFighter.Ability();
- firstFighter.ShowStatistics();
- secondFighter.ShowStatistics();
- Console.ReadKey();
- }
- if (firstFighter.Health > 0)
- {
- Console.Write($"\nПроиграл:");
- secondFighter.ShowStatistics();
- Console.Write($"Победил:");
- firstFighter.ShowStatistics();
- }
- else if(secondFighter.Health > 0)
- {
- Console.WriteLine($"\nПроиграл:");
- firstFighter.ShowStatistics();
- Console.WriteLine($"Победил:");
- secondFighter.ShowStatistics();
- }
- else if(firstFighter.Health < 0 && secondFighter.Health < 0)
- {
- Console.WriteLine("Оба бойца погибли!");
- }
- Console.ReadKey();
- }
- }
- abstract class Fighters
- {
- protected string Name;
- public int Health {get; protected set;}
- public int Damage {get; protected set;}
- public Fighters(string name, int health, int damage)
- {
- Name = name;
- Health = health;
- Damage = damage;
- }
- public void ShowStatistics()
- {
- Console.WriteLine($"имя:{Name}, Жизни - {Health}, урон - {Damage}");
- }
- public virtual void TakeDamage(int damage)
- {
- Health -= damage;
- }
- public abstract void Ability();
- }
- class Healthy : Fighters
- {
- public Healthy(string name, int health, int damage) : base(name, health, damage){}
- public override void Ability()
- {
- Health += 8;
- }
- }
- class Strong : Fighters
- {
- public Strong(string name, int health, int damage) : base(name, health, damage){}
- public override void Ability()
- {
- Damage += 8;
- }
- }
- class Fast : Fighters
- {
- public Fast(string name, int health, int damage) : base(name, health, damage){}
- public override void Ability()
- {
- Damage *= 2;
- }
- }
- class Dexterous : Fighters
- {
- public Dexterous(string name, int health, int damage) : base(name, health, damage){}
- public override void Ability()
- {
- Health *= 2;
- }
- }
- class Wimp : Fighters
- {
- public Wimp(string name, int health, int damage) : base(name, health, damage){}
- public override void Ability()
- {
- Random rand = new Random();
- for(int i = 0; i < rand.Next(0,12); i++)
- {
- Health++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement