/* static void c_ThresholdReached(object sender, EventArgs e) * { * Console.WriteLine("The threshold was reached."); * } */ public static void dataManipulation(List <Base> characters) { Audit ad = new Audit(); double avg = ad.averagePower(characters); Console.WriteLine("Average power of characters is " + avg); string res = ad.largerThanAverage(characters); Console.WriteLine("Characters with power larger than average are: " + res); bool allHave = ad.allHaveGraterThaFourthOfAverage(characters); if (allHave) { Console.WriteLine("All characters HAVE larger defense than 1/4 of average defense value."); } else { Console.WriteLine("All characters DO NOT HAVE larger defense than 1/4 of average defense value."); } }
public static void Main(string[] args) { int round = 0; Audit ad = new Audit(); Sword sword = new Sword("NiceSword", 130); Shield shield = new Shield("NiceShield", 130); List <Base> characters = new List <Base>() { new Hero(sword, shield, "Filip", 100, 100, 100), new Hero(sword, shield, "Jana", 100, 100, 100), new Hero(sword, shield, "Jana", 100, 100, 100), new Dragon("Max", 100, 100, 100) }; double avg = ad.averagePower(characters); Console.WriteLine("Average power of characters is " + avg); var count = 0; // someAlive(count) while (RealSomeAlive(characters)) { count += 1; for (var i = 0; i < characters.Count - 1; i++) { object first = convert(characters[i]); object second = convert(characters[i + 1]); double firstAttackValue = 0; round += 1; Console.WriteLine($"=============================ROUND {round} ==========================="); if (first is Hero) { firstAttackValue = ((Hero)first).randAttack(); Console.WriteLine($"Hero attacked Dragon with {firstAttackValue}"); } if (second is Dragon) { // Console.WriteLine($"Dragon {second.GetType()}"); Dragon dra = ((Dragon)second); dra.hitBy(firstAttackValue); Console.WriteLine($"Dragon lost {firstAttackValue} health and has {dra.getHealth()} lives"); //2nd character strikes back double attack = dra.randAttack(); if (first is Hero) { Hero hra = ((Hero)first); hra.hitBy(attack); Console.WriteLine($"Dragin strikes back by {attack} and hero has {hra.getHealth()} "); } } } } }