예제 #1
0
 public void Battle(uint numOfBattle = 20, int speedOfBattle = 50, bool IsShowBattle = true)
 {
     for (uint i = 0; i < numOfBattle; i++)
     {
         try
         {
             Tank tmp = (first * second);        // реалізовуєм битву через оператор множення
             if (tmp.Name == first.Name)
             {
                 winFirstTank++;
             }
             else
             {
                 winSecondTank++;
             }
             if (IsShowBattle)
             {
                 Console.WriteLine(tmp + "Winner");
             }
         }
         catch (Exception ex)
         {
             if (IsShowBattle)
             {
                 Console.ForegroundColor = ConsoleColor.Red;
                 Console.WriteLine("\t\t" + ex.Message);
                 Console.ResetColor();
             }
             draw++;
         }
         first.BornAgain();
         second.BornAgain();
         Thread.Sleep(speedOfBattle);
     }
 }