Guest User

Arena

a guest
Jun 21st, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace FightingArena
  7. {
  8.     public class Arena
  9.     {
  10.         List<Gladiator> Gladiators { get; set; }
  11.         public int Count { get; private set; }
  12.         public string Name { get; private set; }
  13.  
  14.         public Arena(string Name)
  15.         {
  16.             this.Name = Name;
  17.             Gladiators = new List<Gladiator>();
  18.         }
  19.  
  20.         public void Add(Gladiator gladiator)
  21.         {
  22.             Gladiators.Add(gladiator);
  23.             Count = Gladiators.Count;
  24.         }
  25.         public void Remove(string name)
  26.         {
  27.             for (int i = 0; i < Gladiators.Count; i++)
  28.             {
  29.                 if (Gladiators[i].Name == name)
  30.                 {
  31.                     Gladiators.RemoveAt(i);
  32.                     Count = Gladiators.Count;
  33.                 }
  34.             }
  35.         }
  36.         public Gladiator GetGladitorWithHighestTotalPower()
  37.         {
  38.             Gladiator highestTotal = Gladiators[0];
  39.  
  40.             foreach (var glad in Gladiators)
  41.             {
  42.                 if (glad.GetTotalPower() > highestTotal.GetTotalPower())
  43.                 {
  44.                     highestTotal = glad;
  45.                 }
  46.             }
  47.             return highestTotal;
  48.         }
  49.         public Gladiator GetGladitorWithHighestWeaponPower()
  50.         {
  51.             Gladiator highestWeapon = Gladiators[0];
  52.  
  53.             foreach (var glad in Gladiators)
  54.             {
  55.                 if (glad.GetWeaponPower() > highestWeapon.GetWeaponPower())
  56.                 {
  57.                     highestWeapon = glad;
  58.                 }
  59.             }
  60.             return highestWeapon;
  61.         }
  62.         public Gladiator GetGladitorWithHighestStatPower()
  63.         {
  64.             Gladiator highestStat = Gladiators[0];
  65.  
  66.             foreach (var glad in Gladiators)
  67.             {
  68.                 if (glad.GetStatPower() > highestStat.GetStatPower())
  69.                 {
  70.                     highestStat = glad;
  71.                 }
  72.             }
  73.             return highestStat;
  74.         }
  75.         public override string ToString()  
  76.         {
  77.             return $"{this.Name} - {Gladiators.Count} gladiators are participating.";
  78.         }
  79.     }
  80. }
Add Comment
Please, Sign In to add comment