private static void BattleOfCurskCurve(T_34 russianMainBattleTank, Tiger germanHeavyBattleTank) { bool magazineFull = true; CheckTheMagazine(magazineFull, russianMainBattleTank, germanHeavyBattleTank); while (magazineFull) { //Can be applyed second for cycle for the russian tank for (int i = 0; i < GAMETURNS; i++) { AttackOnTheGermanTank(russianMainBattleTank,germanHeavyBattleTank); if (russianMainBattleTank.Armory == 0) { Console.WriteLine("T-34 Was destroyed"); } else if (germanHeavyBattleTank.Armory == 0) { Console.WriteLine("Tiger was destroyed"); } } Console.WriteLine(russianMainBattleTank.ToString()); Console.WriteLine(germanHeavyBattleTank.ToString()); } }
static void Main(string[] args) { try { /* var germanTank = new Tank(300); var russianTank = new Tank(400); ExecuteAttack(germanTank, russianTank); */ T_34 russianMainBattleTank = new T_34(); Tiger germanHeavyBattleTank = new Tiger(); BattleOfCurskCurve(russianMainBattleTank,germanHeavyBattleTank); } catch (TankException theExc) { Console.WriteLine(theExc.Message); } }
private static void CheckTheMagazine(bool magazineFull, T_34 russianMainBattleTank, Tiger germanHeavyBattleTank) { if (germanHeavyBattleTank.antiTankShells == 0) { magazineFull = false; Console.WriteLine("Empty magazine"); } else if (russianMainBattleTank.antiTankShellsRussian == 0) { magazineFull = false; Console.WriteLine("Empty magazine"); } magazineFull = true; }
public void Fire(Tiger germanHeavyBattleTank) { if (this.antiTankShellsRussian == 0) { throw new ArgumentException("empty Magazine"); } // it should be the armory tank to decrise germanHeavyBattleTank.Armory = Armory - ShellDamage; // one shell was fired this.antiTankShellsRussian--; }
private static void AttackOnTheGermanTank(T_34 russianMainBattleTank, Tiger germanHeavyBattleTank) { while (germanHeavyBattleTank.Armory > 0) { russianMainBattleTank.Fire(germanHeavyBattleTank); } }