Beispiel #1
0
        static void Main(string[] args)
        {
            int  athletesQuantity          = 0;
            bool isAthletesQuantityEntered = false;

            Gymnast[] gymnasts;
            Judge[]   judges = JudgeFactory.CreateJudges();

            Console.WriteLine("Enter the number of athletes from 3 to 10, please");

            do
            {
                CompetitionService.GetCompetitorsNumber(ref athletesQuantity, ref isAthletesQuantityEntered);
            }while (!isAthletesQuantityEntered);

            gymnasts = new Gymnast[athletesQuantity];

            for (int i = 0; i < athletesQuantity; i++)
            {
                Console.WriteLine($"Enter the lastname of the gymnast number {i + 1}");
                gymnasts[i] = GymnastFactory.CreateAthlete();
                CompetitionService.Simulation(gymnasts[i]);
                CompetitionService.RateGymnast(judges, gymnasts[i]);
                Console.WriteLine();
                Console.WriteLine($"Average - {gymnasts[i].Average} pts \n");
                Console.WriteLine(new string('-', 40));
            }

            CompetitionService.ShowTopThreeResult(gymnasts);
            CompetitionService.ShowTotalResult(gymnasts);

            Console.ReadKey();
        }
        public static Judge[] CreateJudges()
        {
            Judge[] judges = new Judge[5];


            int counter = 0;

            for (int i = 0; i != judges.Length;)
            {
                Nationality nationality = CompetitionService.RandomizeNationality();
                for (int j = 0; j < i; j++)
                {
                    if (nationality == judges[j].Nationality)
                    {
                        counter++;
                        break;
                    }
                }
                if (counter == 0)
                {
                    judges[i] = new Judge(nationality);
                    i++;
                }
                counter = 0;
            }
            return(judges);
        }
Beispiel #3
0
 public static void ShowTotalResult(Gymnast[] gymnasts)
 {
     Console.WriteLine("Total results: \n");
     CompetitionService.SortResult(gymnasts);
     for (int i = 0; i < gymnasts.Length; i++)
     {
         Console.WriteLine($"{gymnasts[gymnasts.Length - 1 - i].Lastname} has {gymnasts[gymnasts.Length - 1 - i].Average} pts");
     }
     Console.WriteLine(new string('-', 40));
 }
Beispiel #4
0
        public static Gymnast CreateAthlete()
        {
            string gymnastName = Console.ReadLine();

            if (gymnastName == "")
            {
                gymnastName = "Unknown";
            }
            return(new Gymnast(gymnastName, CompetitionService.RandomizeNationality()));
        }