static void Main(string[] args) { List <Warrior> warriors = new List <Warrior>(); for (int i = 0; i < 100; i++) { Ninja ninja = new Ninja(i + 5, "Ninja" + i.ToString()); Duck duck = new Duck(i + 3, "Ducky" + i.ToString()); warriors.Add(ninja); warriors.Add(duck); } foreach (Warrior w in warriors) { w.SayName(); } int count = warriors.Count; for (int fi = 0; count > 1; fi++) { if (fi >= count) { fi = 0; } if (fi == count - 1) { warriors[fi].Fight(warriors[0]); } if (warriors[0].health <= 0) { warriors.Remove(warriors[0]); count -= 1; } else { warriors[fi].Fight(warriors[fi + 1]); if (warriors[fi + 1].health <= 0) { warriors.Remove(warriors[fi + 1]); count -= 1; } } } Console.WriteLine(warriors[0].name + " IS VICTORIOUS "); Console.ReadLine(); }
static void Main(string[] args) { List<Warrior> warriors = new List<Warrior>(); for(int i = 0; i < 100; i++) { Ninja ninja = new Ninja(i + 5, "Ninja" + i.ToString()); Duck duck = new Duck(i + 3, "Ducky" + i.ToString()); warriors.Add(ninja); warriors.Add(duck); } foreach (Warrior w in warriors) { w.SayName(); } int count = warriors.Count; for(int fi = 0; count > 1; fi++) { if (fi >= count) { fi = 0; } if (fi == count -1) { warriors[fi].Fight(warriors[0]); } if (warriors[0].health <= 0) { warriors.Remove(warriors[0]); count -= 1; } else { warriors[fi].Fight(warriors[fi + 1]); if (warriors[fi + 1].health <= 0) { warriors.Remove(warriors[fi + 1]); count -= 1; } } } Console.WriteLine(warriors[0].name + " IS VICTORIOUS "); Console.ReadLine(); }