public void StartBattle() { try { if (TanksT34.Count() != TanksPantera.Count()) { throw new Exception("The number of tanks on one side is not equal to the opposite."); } } catch (Exception ex) { Console.WriteLine($"Error occured: {ex.Message}"); } for (int i = 0; i < TanksT34.Count(); i++) // The number of tanks of one of the teams is the number of rounds { bool res = TanksT34[i] * TanksPantera[i]; Console.WriteLine($"{TanksT34[i]} \nVERSUS \n{TanksPantera[i]}"); if (res) { Console.WriteLine($"{TankNames.T34} WIN!\n"); } else { Console.WriteLine($"{TankNames.Pantera} WIN!\n"); } } }
public void ShowResultsBattle() { try { for (int i = 0; i < TanksT34.Count(); i++) { if (TanksT34[i].IsWin == null) { throw new Exception("For some reason, some tanks did not participate in the battle."); } } for (int i = 0; i < TanksPantera.Count(); i++) { if (TanksPantera[i].IsWin == null) { throw new Exception("For some reason, some tanks did not participate in the battle."); } } } catch (Exception ex) { Console.WriteLine($"Error occured: {ex.Message}"); } Console.WriteLine($"The number of victories of the {TankNames.T34} tanks: {TanksT34.Count(s=>s.IsWin == true)}"); Console.WriteLine($"The number of victories of the {TankNames.Pantera} tanks: {TanksPantera.Count(s => s.IsWin == true)}"); }
public void Add(Tank tank) { if (tank.TankName == TankNames.T34) { TanksT34.Add(tank); } else { TanksPantera.Add(tank); } }