Exemplo n.º 1
0
        public void Remove(string name)
        {
            Gladiator gladiatorToRemove = this.gladiators
                                          .FirstOrDefault(g => g.Name == name);

            this.gladiators.Remove(gladiatorToRemove);
        }
Exemplo n.º 2
0
        public void Add(Gladiator gladiator)
        {
            if (!gladiators.ContainsKey(gladiator.Name))
            {
                bool isValid = true;
                if (gladiators.Count > 0)
                {
                    foreach (var item in gladiators)
                    {
                        int gladiatorStatPow   = gladiator.GetStatPower();
                        int gladiatorWeaponPow = gladiator.GetWeaponPower();
                        int gladiatorTotalPow  = gladiator.GetTotalPower();

                        int oponentStatPow   = item.Value.GetStatPower();
                        int oponentWeaponPow = item.Value.GetWeaponPower();
                        int oponentTotalPow  = item.Value.GetTotalPower();

                        if (gladiatorStatPow == oponentStatPow &&
                            gladiatorWeaponPow == oponentWeaponPow &&
                            gladiatorTotalPow == oponentTotalPow)
                        {
                            isValid = false;
                        }
                    }
                }
                if (isValid)
                {
                    gladiators.Add(gladiator.Name, gladiator);
                }
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            Arena arena = new Arena("Armeec");

            Stat firstGlariatorStat  = new Stat(20, 25, 35, 14, 48);
            Stat secondGlariatorStat = new Stat(40, 40, 40, 40, 40);
            Stat thirdGlariatorStat  = new Stat(20, 25, 35, 14, 48);

            Weapon firstGlariatorWeapon  = new Weapon(5, 28, 100);
            Weapon secondGlariatorWeapon = new Weapon(5, 28, 100);
            Weapon thirdGlariatorWeapon  = new Weapon(50, 50, 50);

            Gladiator firstGladiator  = new Gladiator("Stoyan", firstGlariatorStat, firstGlariatorWeapon);
            Gladiator secondGladiator = new Gladiator("Pesho", secondGlariatorStat, secondGlariatorWeapon);
            Gladiator thirdGladiator  = new Gladiator("Gosho", thirdGlariatorStat, thirdGlariatorWeapon);

            arena.Add(firstGladiator);
            arena.Add(secondGladiator);
            arena.Add(thirdGladiator);

            Console.WriteLine(arena.Count);

            Gladiator strongestGladiator = arena.GetGladitorWithHighestTotalPower();

            Console.WriteLine(strongestGladiator);

            Gladiator bestWeaponGladiator = arena.GetGladitorWithHighestWeaponPower();

            Console.WriteLine(bestWeaponGladiator);

            Gladiator bestStatGladiator = arena.GetGladitorWithHighestStatPower();

            Console.WriteLine(bestStatGladiator);
        }
 public void Add(Gladiator gladiator)
 {
     if (!gladiators.Contains(gladiator))
     {
         gladiators.Add(gladiator);
     }
 }
Exemplo n.º 5
0
 public void Add(Gladiator gladiator)
 {
     if (this.gladiators.All(x => x.Name != gladiator.Name))
     {
         this.gladiators.Add(gladiator);
     }
 }
Exemplo n.º 6
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator gladitorWithHighestTotalPower =
                gladiators.OrderByDescending(x => x.GetTotalPower()).ToList()[0];

            return(gladitorWithHighestTotalPower);
        }
Exemplo n.º 7
0
 public void Add(Gladiator gladiator)
 {
     if (gladiators.Contains(gladiator) == false)
     {
         this.gladiators.Add(gladiator);
     }
 }
Exemplo n.º 8
0
        public void Remove(string name)
        {
            Gladiator gladiatorToRemove = gladiators
                                          .FirstOrDefault(x => x.Name == name);

            gladiators.Remove(gladiatorToRemove);
        }
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator foundGladiator = this.gladiators
                                       .OrderByDescending(g => g.GetTotalPower())
                                       .First();

            return(foundGladiator);
        }
Exemplo n.º 10
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator gladiatorToReturn = this.gladiators
                                          .OrderByDescending(x => x.GetTotalPower())
                                          .FirstOrDefault();

            return(gladiatorToReturn);
        }
Exemplo n.º 11
0
        public void Remove(string name)
        {
            if (this.gladiators.Any(x => x.Name == name))
            {
                Gladiator gladiator = this.gladiators.FirstOrDefault(x => x.Name == name);

                this.gladiators.Remove(gladiator);
            }
        }
Exemplo n.º 12
0
        public void Remove(string name)
        {
            Gladiator gladiator = this.gladiators.FirstOrDefault(x => x.Name == name);

            if (gladiator != null)
            {
                this.gladiators.Remove(gladiator);
            }
        }
Exemplo n.º 13
0
        public void Remove(string name)
        {
            if (gladiators.Any(x => x.Name == name))
            {
                Gladiator gladiatorToRemove = gladiators.Find(x => x.Name == name);

                gladiators.Remove(gladiatorToRemove);
            }
        }
Exemplo n.º 14
0
        public void Remove(string name)
        {
            Gladiator target = gladiators.Where(x => x.Name == name).FirstOrDefault();

            if (target != null)
            {
                gladiators.Remove(target);
            }
        }
Exemplo n.º 15
0
        public void Remove(string name)
        {
            Gladiator currentGladiator = this.gladiators.FirstOrDefault(g => g.Name == name);
            int       index            = this.gladiators.IndexOf(currentGladiator);

            if (currentGladiator != null)
            {
                this.gladiators.RemoveAt(index);
            }
        }
Exemplo n.º 16
0
        public static void Main()
        {
            //Creates arena
            Arena arena = new Arena("Armeec");

            //Creates stats
            Stat firstGlariatorStat  = new Stat(20, 25, 35, 14, 48);
            Stat secondGlariatorStat = new Stat(40, 40, 40, 40, 40);
            Stat thirdGlariatorStat  = new Stat(20, 25, 35, 14, 48);

            //Creates weapons
            Weapon firstGlariatorWeapon  = new Weapon(5, 28, 100);
            Weapon secondGlariatorWeapon = new Weapon(5, 28, 100);
            Weapon thirdGlariatorWeapon  = new Weapon(50, 50, 50);

            //Creates gladiators
            Gladiator firstGladiator  = new Gladiator("Stoyan", firstGlariatorStat, firstGlariatorWeapon);
            Gladiator secondGladiator = new Gladiator("Pesho", secondGlariatorStat, secondGlariatorWeapon);
            Gladiator thirdGladiator  = new Gladiator("Gosho", thirdGlariatorStat, thirdGlariatorWeapon);

            //Adds gladiators to arena
            arena.Add(firstGladiator);
            arena.Add(secondGladiator);
            arena.Add(thirdGladiator);


            //Prints gladiators count at the arena
            Console.WriteLine(arena.Count);

            //Gets strongest gladiator and print him
            Gladiator strongestGladiator = arena.GetGladitorWithHighestTotalPower();

            Console.WriteLine(strongestGladiator);


            //Gets gladiator with the strongest weapon and print him
            Gladiator bestWeaponGladiator = arena.GetGladitorWithHighestWeaponPower();

            Console.WriteLine(bestWeaponGladiator);


            //Gets gladiator with the strongest stat and print him
            Gladiator bestStatGladiator = arena.GetGladitorWithHighestStatPower();

            Console.WriteLine(bestStatGladiator);

            //Removes gladiator
            arena.Remove("Gosho");

            //Prints gladiators count at the arena
            Console.WriteLine(arena.Count);

            //Prints the arena
            Console.WriteLine(arena);
        }
Exemplo n.º 17
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator gladiator = this.gladiators
                                  .OrderByDescending(x => x.GetTotalPower())
                                  .FirstOrDefault();

            if (gladiator != null)
            {
                return(gladiator);
            }
            return(null);
        }
Exemplo n.º 18
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator bestGladiator = gladiators[0];

            foreach (var item in gladiators)
            {
                if (bestGladiator.GetTotalPower() < item.GetTotalPower())
                {
                    bestGladiator = item;
                }
            }
            return(bestGladiator);
        }
Exemplo n.º 19
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator highestTotal = gladiators[0];

            foreach (var glad in gladiators)
            {
                if (glad.GetTotalPower() > highestTotal.GetTotalPower())
                {
                    highestTotal = glad;
                }
            }
            return(highestTotal);
        }
Exemplo n.º 20
0
        public Gladiator GetGladitorWithHighestWeaponPower()
        {
            Gladiator highestWeapon = gladiators[0];

            foreach (var glad in gladiators)
            {
                if (glad.GetWeaponPower() > highestWeapon.GetWeaponPower())
                {
                    highestWeapon = glad;
                }
            }
            return(highestWeapon);
        }
Exemplo n.º 21
0
        public Gladiator GetGladitorWithHighestStatPower()
        {
            Gladiator highestStat = gladiators[0];

            foreach (var glad in gladiators)
            {
                if (glad.GetStatPower() > highestStat.GetStatPower())
                {
                    highestStat = glad;
                }
            }
            return(highestStat);
        }
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator best = gladiators[0];

            foreach (var gladiator in gladiators)
            {
                if (gladiator.GetTotalPower() > best.GetTotalPower())
                {
                    best = gladiator;
                }
            }
            return(best);
        }
Exemplo n.º 23
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator highest = gladiators[0];

            for (int i = 0; i < gladiators.Count; i++)
            {
                if (gladiators[i].GetTotalPower() > highest.GetTotalPower())
                {
                    highest = gladiators[i];
                }
            }

            return(highest);
        }
        public void Remove(string name)
        {
            Gladiator gladiatorToRemove = gladiators[0];

            foreach (var gladiator in gladiators)
            {
                if (gladiator.Name == name)
                {
                    gladiatorToRemove = gladiator;
                }
            }

            gladiators.Remove(gladiatorToRemove);
        }
Exemplo n.º 25
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator highestTotalPowerGladiator = new Gladiator();
            int       highestTotalPower          = 0;

            foreach (var gladiator in arena.Values)
            {
                if (gladiator.GetTotalPower() > highestTotalPower)
                {
                    highestTotalPowerGladiator = gladiator;
                }
            }
            return(highestTotalPowerGladiator);
        }
Exemplo n.º 26
0
        public Gladiator GetGladitorWithHighestStatPower()
        {
            Gladiator gladiatorWithHighestStats = new Gladiator();
            int       highestStat = 0;

            foreach (var gladiator in arena.Values)
            {
                if (gladiator.GetStatPower() > highestStat)
                {
                    gladiatorWithHighestStats = gladiator;
                }
            }
            return(gladiatorWithHighestStats);
        }
Exemplo n.º 27
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator biggestGlad = gladiators.FirstOrDefault();

            for (int i = 0; i < gladiators.Count; i++)
            {
                if (gladiators[i].GetTotalPower() > biggestGlad.GetTotalPower())
                {
                    biggestGlad = gladiators[i];
                }
            }

            return(biggestGlad);
        }
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            int       max = 0;
            Gladiator gladiatorMaxPower = null;

            foreach (var gladiator in gladiators)
            {
                if (gladiator.GetTotalPower() > max)
                {
                    max = gladiator.GetTotalPower();
                    gladiatorMaxPower = gladiator;
                }
            }

            return(gladiatorMaxPower);
        }
        public Gladiator GetGladitorWithHighestWeaponPower()
        {
            int       max = 0;
            Gladiator gladiatorMaxWeapon = null;

            foreach (var gladiator in gladiators)
            {
                if (gladiator.GetWeaponPower() > max)
                {
                    max = gladiator.GetWeaponPower();
                    gladiatorMaxWeapon = gladiator;
                }
            }

            return(gladiatorMaxWeapon);
        }
Exemplo n.º 30
0
        public Gladiator GetGladitorWithHighestTotalPower()
        {
            Gladiator resultGladiator = new Gladiator();
            int       maxTotal        = 0;

            foreach (var gladiator in gladiators)
            {
                int currentTotal = gladiator.Value.GetTotalPower(gladiator.Value.Stat, gladiator.Value.Weapon);
                if (maxTotal < currentTotal)
                {
                    maxTotal        = currentTotal;
                    resultGladiator = gladiator.Value;
                }
            }
            return(resultGladiator);
        }