示例#1
0
        static void Main(string[] args)
        {
            const int    tanksNumber    = 5;
            const string firstTankName  = "Т-34";
            const string secondTankName = "Pantera";

            Tank[] firstGroup  = new Tank[tanksNumber];
            Tank[] secondGroup = new Tank[tanksNumber];

            try
            {
                ////Вызов исключения - Раскоменитуйте для проверки
                //firstGroup = null;

                ActionsClass.CreateTanks(ref firstGroup, tanksNumber, firstTankName);
                ActionsClass.CreateTanks(ref secondGroup, tanksNumber, secondTankName);
            }
            catch (ArgumentNullException exception)
            {
                Console.WriteLine(exception.Message);
            }

            ActionsClass.Advantage winner = ActionsClass.Battle(firstGroup, secondGroup, tanksNumber);

            ActionsClass.BattleResults(winner, firstTankName, secondTankName);
        }
        public static ActionsClass.Advantage operator *(Tank firstTank, Tank secondTank)
        {
            int firstCount = new int(), secondCount = new int();

            ActionsClass.Advantage Ammunition = ActionsClass.Comparison(firstTank.AmmunitionLevel, secondTank.AmmunitionLevel);
            ActionsClass.Advantage Armor = ActionsClass.Comparison(firstTank.ArmorLevel, secondTank.ArmorLevel);
            ActionsClass.Advantage Agility = ActionsClass.Comparison(firstTank.AgilityLevel, secondTank.AgilityLevel);

            ActionsClass.ScoringPoints(Ammunition, ref firstCount, ref secondCount);
            ActionsClass.ScoringPoints(Armor, ref firstCount, ref secondCount);
            ActionsClass.ScoringPoints(Agility, ref firstCount, ref secondCount);

            return(ActionsClass.WinnerСalculation(firstCount, secondCount));
        }