Beispiel #1
0
        private void GenerateSwimmers(SwimmerAdditionalConfigurator swimmerConfig)
        {
            try
            {
                checkIfSetupisOK();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                CountOfSwimmers  = 5;
                _arrayOfSwimmers = new Swimmer[CountOfSwimmers];
            }

            for (var index = 0; index < CountOfSwimmers; index++)
            {
                var random    = new Random();
                var randomAge = random.Next(16, 35);
                //inserting a negative values to check property works good.
                var randomSalary    = random.Next(-1000, 3000);
                var randomNameIndex = random.Next(0, ArrayOfRandomNamesForGenerate.Count);
                var swimmer         = new Swimmer(ArrayOfRandomNamesForGenerate[randomNameIndex], randomAge, randomSalary);
                swimmerConfig(swimmer);
                _arrayOfSwimmers[index] = swimmer;
            }
        }
Beispiel #2
0
        private void testBeforeSwimming()
        {
            List <Swimmer> swimmersForDelete = new List <Swimmer>();
            Wada           wada = new Wada();

            for (int index = 0; index < _arrayOfSwimmers.Length; index++)
            {
                try
                {
                    wada.checkForDoping(_arrayOfSwimmers[index]);
                }
                catch (Exception E)
                {
                    Console.WriteLine($"{E.Message} For {_arrayOfSwimmers[index].Name}");
                    swimmersForDelete.Add(_arrayOfSwimmers[index]);
                }
            }

            for (int jindex = 0; jindex < swimmersForDelete.Count; jindex++)
            {
                Swimmer temp = swimmersForDelete[jindex];
                _arrayOfSwimmers = _arrayOfSwimmers.Where((source, index) => source != temp).ToArray();
                CountOfSwimmers--;
            }
        }
Beispiel #3
0
        private void additionalConfig(Swimmer swimmer)
        {
            var random          = new Random();
            var randomButterfly = random.NextDouble();
            var randomFreestyle = random.NextDouble();

            swimmer.SwimmerAnthropology = generateRandomAntropology();
            if (PerformInterface(swimmer))
            {
                swimmer[Swimmer.SwimmingStyle.Freestyle] = Math.Round(randomFreestyle + 8, 2);
                swimmer[Swimmer.SwimmingStyle.Butterfly] = Math.Round(randomButterfly + 9, 2);
            }
            else
            {
                swimmer[Swimmer.SwimmingStyle.Freestyle] = Math.Round(randomFreestyle + 3, 2);
                swimmer[Swimmer.SwimmingStyle.Butterfly] = Math.Round(randomButterfly + 4, 2);
            }
        }