public Round StartRoundOrGetExisting(int userId)
        {
            GameEntity  gameEntity  = StartNewGameOrGetExisting(userId);
            RoundEntity roundEntity = _roundRepository.GetCurrentOpenRound(gameEntity.Id);

            if (null != roundEntity)
            {
                // Unfinished round
                return(RoundEntityFactory.Create(roundEntity, ROUNDS_PER_GAME, RoundsPlayedInGame(gameEntity.Id)));
            }
            roundEntity = RoundEntityFactory.Create(gameEntity.Id);

            // Determine the correct one
            var randomImages = _imageRepository.GetRandomImages(IMAGES_PER_ROUND, _userRepository.Get(userId).FullName);
            int indexOfCorrectImageInList = (new Random()).Next(IMAGES_PER_ROUND);
            var correctImage = randomImages.ElementAt(indexOfCorrectImageInList);

            Round round = RoundFactory.Create(new List <Image>(), RoundsPlayedInGame(gameEntity.Id), ROUNDS_PER_GAME, correctImage.Name);

            roundEntity.CorrectImageId = correctImage.Id;
            _roundRepository.Create(roundEntity);

            foreach (ImageEntity imageEntity in randomImages)
            {
                ImageInRoundEntity imageInRoundEntity = ImageInRoundEntityFactory.Create(imageEntity.Id, roundEntity.Id);
                _imageInRoundRepository.Create(imageInRoundEntity);
                round.Images.Add(ImageFactory.Create(imageEntity.Url, imageEntity.Id));
            }

            return(round);
        }
        public CompetitionSchedule CreateSchedule(Team team1, Team team2, Season season, MatchDateManager matchDateManager)
        {
            var competitionSchedule = new CompetitionSchedule();

            using (var competitionRepository = new RepositoryFactory().CreateCompetitionRepository())
            {
                // Create a super cup season competition and round and save it to the database.
                var superCupCompetition       = competitionRepository.GetNationalSuperCup();
                var superCupSeasonCompetition = new SeasonCompetition
                {
                    Competition = superCupCompetition,
                    Season      = season
                };
                competitionSchedule.SeasonCompetitions.Add(superCupSeasonCompetition);

                const int roundNr = 0;

                var matchDate = matchDateManager.GetNextMatchDate(CompetitionType.NationalSuperCup, roundNr);

                var superCupRound = RoundFactory.CreateRound("Final", superCupSeasonCompetition, matchDate, roundNr, superCupCompetition);
                competitionSchedule.Rounds.Add(superCupRound);

                // Create the super cup match and save it to the database.
                var teams1 = new List <Team> {
                    team1
                };
                var teams2 = new List <Team> {
                    team2
                };
                var singleRoundTournamentManager = new SingleRoundTournamentManager();
                var match = singleRoundTournamentManager.GetMatches(teams1, teams2).Single();

                match.Season        = season;
                match.Round         = superCupRound;
                match.Date          = matchDate;
                match.DrawPermitted = false;
                match.CompetitionId = superCupCompetition.Id;
                competitionSchedule.Matches.Add(match);

                // Add both teams to the super cup competition of this season.
                var seasonCompetitionTeam1 = new SeasonCompetitionTeam
                {
                    Team = team1,
                    SeasonCompetition = superCupSeasonCompetition
                };
                var seasonCompetitionTeam2 = new SeasonCompetitionTeam
                {
                    Team = team2,
                    SeasonCompetition = superCupSeasonCompetition
                };
                competitionSchedule.SeasonCompetitionTeams.Add(seasonCompetitionTeam1);
                competitionSchedule.SeasonCompetitionTeams.Add(seasonCompetitionTeam2);
            }

            return(competitionSchedule);
        }
Beispiel #3
0
    public void Awake()
    {
        if (Instance)
        {
            Destroy(this);
            return;
        }

        Instance = this;
    }
Beispiel #4
0
        public async Task StartAsync()
        {
            for (int i = 1; i <= Settings.MaxRounds; i++)
            {
                Round = RoundFactory.Create(i);
                OnRoundStarting();
                await Round.StartAsync();

                UpdateScores();
                OnRoundFinished();
                await WaitForNextRoundAsync();
            }
        }
Beispiel #5
0
        public CompetitionSchedule CreateDuringSeasonFriendlyRounds(SeasonCompetition seasonCompetition, List <DateTime> matchDates, int startIndex)
        {
            // The during season friendly schedule only consists of rounds. The matches in the rounds are determined during the season.
            var competitionSchedule = new CompetitionSchedule();

            foreach (var matchDate in matchDates)
            {
                var friendlyRound = RoundFactory.CreateRound(null, seasonCompetition, matchDate, startIndex, _competition);

                competitionSchedule.Rounds.Add(friendlyRound);
                startIndex++;
            }

            return(competitionSchedule);
        }
Beispiel #6
0
        public void TestEdgeCase()
        {
            var lClass = GetClass;

            for (int i = 4; i < 25; i++)
            {
                for (int j = 8; j < 20; j++)
                {
                    Console.WriteLine($"Generating for {j} Users. Min {i} games for one player.");
                    var lRound = RoundFactory.CreateRound2(
                        lClass.UserBase.Take(j).Select(a => a.ID).ToList(),
                        lClass, DateTime.Now, j / 4, "", "",
                        i);
                    Console.WriteLine($"Generated! {lRound.Games.Count} games. ");
                }
            }
        }
Beispiel #7
0
        public CompetitionSchedule CreatePreSeasonSchedule(List <Team> teams, Season season, MatchDateManager matchDateManager)
        {
            var competitionSchedule = new CompetitionSchedule();

            // Create a friendly season competition for all friendlies in the season.
            SeasonCompetition friendlySeasonCompetition = new SeasonCompetition
            {
                Competition = _competition,
                Season      = season
            };

            competitionSchedule.SeasonCompetitions.Add(friendlySeasonCompetition);

            var roundsAndMatches = CreatePreSeasonRoundsAndMatches(teams);

            foreach (var round in roundsAndMatches)
            {
                var matchDate = matchDateManager.GetNextMatchDate(CompetitionType.Friendly, round.Key);

                var friendlyRound = RoundFactory.CreateRound(null, friendlySeasonCompetition, matchDate, round.Key, _competition);
                competitionSchedule.Rounds.Add(friendlyRound);

                foreach (var match in round.Value)
                {
                    match.Season        = season;
                    match.Round         = friendlyRound;
                    match.Date          = matchDate;
                    match.CompetitionId = _competition.Id;
                    competitionSchedule.Matches.Add(match);
                }
            }

            // Add the teams to the pre-season friendly competition of this season.
            foreach (var team in teams)
            {
                var seasonCompetitionTeam = new SeasonCompetitionTeam
                {
                    SeasonCompetition = friendlySeasonCompetition,
                    Team = team
                };
                competitionSchedule.SeasonCompetitionTeams.Add(seasonCompetitionTeam);
            }

            return(competitionSchedule);
        }
        public void CreateRound_ZeroRoundIndex()
        {
            // Arrange
            IEnumerable <IRoundPlayerState> players = new[] {
                new PlayerState(Guid.Parse("b0049b58-73a3-49a8-8ba1-f5d3fd9701a9"), null, null),
                new PlayerState(Guid.Parse("a7b9794d-a3f0-46ac-b69b-a2dbc3e12f18"), null, null)
            };

            IEnumerable <IShufflableCardState> shufflalbeDeck = new[] { new CardState(0, 1) };
            const int expected = 0;

            _deckFactory
            .Setup(df => df.Create())
            .Returns(shufflalbeDeck);

            // Act
            RoundFactory factory = this.CreateFactory();
            var          round   = factory.CreateRound(players);
            var          actual  = round.RoundIndex;

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void CreateRound_SetsTwoPlayers()
        {
            // Arrange
            IEnumerable <IRoundPlayerState> players = new[] {
                new PlayerState(Guid.Parse("b0049b58-73a3-49a8-8ba1-f5d3fd9701a9"), null, null),
                new PlayerState(Guid.Parse("a7b9794d-a3f0-46ac-b69b-a2dbc3e12f18"), null, null)
            };
            var expected = players;

            IEnumerable <IShufflableCardState> shufflalbeDeck = new[] { new CardState(0, 1) };

            _deckFactory
            .Setup(df => df.Create())
            .Returns(shufflalbeDeck);

            // Act
            RoundFactory factory = this.CreateFactory();
            var          round   = factory.CreateRound(players);
            var          actual  = round.Players;

            // Assert
            Assert.IsTrue(expected.SequenceEqual(actual));
        }
        public CompetitionSchedule CreateSchedule(List <Team> teams, Season season, MatchDateManager matchDateManager)
        {
            var competitionSchedule = new CompetitionSchedule();

            // Create a cup season competition.
            SeasonCompetition cupSeasonCompetition = new SeasonCompetition
            {
                Competition = _competition,
                Season      = season
            };

            competitionSchedule.SeasonCompetitions.Add(cupSeasonCompetition);

            var cupSchedule = new KnockoutTournamentManager().GetSchedule(teams);

            int numberOfRounds = DetermineNumberOfRounds(teams.Count);

            var firstScheduleItem = cupSchedule.First();
            var matchDate         = matchDateManager.GetNextMatchDate(CompetitionType.NationalCup, firstScheduleItem.Key);

            // Create the first round and its matches.
            int roundIndex = 0;
            var firstRound = RoundFactory.CreateRound(GetCupRoundName(numberOfRounds, roundIndex), cupSeasonCompetition, matchDate, roundIndex, _competition);

            foreach (var match in firstScheduleItem.Value)
            {
                match.Season        = season;
                match.Round         = firstRound;
                match.Date          = matchDate;
                match.DrawPermitted = false;
                match.CompetitionId = _competition.Id;
                competitionSchedule.Matches.Add(match);
            }

            competitionSchedule.Rounds.Add(firstRound);

            // Create remaining rounds for the tournament, these rounds do not have matches yet.
            // The date on which the matches on these rounds will be played are stored in the round.
            int numberOfRoundsLeft = numberOfRounds - 1;

            if (numberOfRoundsLeft > 0)
            {
                for (int i = 0; i < numberOfRoundsLeft; i++)
                {
                    roundIndex++;

                    matchDate = matchDateManager.GetNextMatchDate(CompetitionType.NationalCup, roundIndex);
                    var round = RoundFactory.CreateRound(GetCupRoundName(numberOfRounds, roundIndex), cupSeasonCompetition, matchDate, roundIndex, _competition);
                    competitionSchedule.Rounds.Add(round);
                }
            }

            // Add the teams to the cup of this season.
            foreach (var team in teams)
            {
                var seasonCompetitionTeam = new SeasonCompetitionTeam
                {
                    SeasonCompetition = cupSeasonCompetition,
                    Team = team
                };
                competitionSchedule.SeasonCompetitionTeams.Add(seasonCompetitionTeam);
            }

            return(competitionSchedule);
        }
Beispiel #11
0
        private void TestGenerating(int aCycles, int aCourts, int aPlayers)
        {
            var lClass = new Class
            {
                UserBase = new List <User>
                {
                    new User {
                        ID = 0, Name = "A"
                    },
                    new User {
                        ID = 1, Name = "B"
                    },
                    new User {
                        ID = 2, Name = "C"
                    },
                    new User {
                        ID = 3, Name = "D"
                    },
                    new User {
                        ID = 4, Name = "E"
                    },
                    new User {
                        ID = 5, Name = "F"
                    },
                    new User {
                        ID = 6, Name = "G"
                    },
                    new User {
                        ID = 7, Name = "H"
                    },
                    new User {
                        ID = 8, Name = "I"
                    },
                    new User {
                        ID = 9, Name = "J"
                    },
                    new User {
                        ID = 10, Name = "K"
                    },
                    new User {
                        ID = 11, Name = "L"
                    },
                    new User {
                        ID = 12, Name = "M"
                    },
                    new User {
                        ID = 13, Name = "N"
                    },
                    new User {
                        ID = 14, Name = "O"
                    },
                    new User {
                        ID = 15, Name = "P"
                    },
                    new User {
                        ID = 16, Name = "Q"
                    },
                    new User {
                        ID = 17, Name = "R"
                    },
                    new User {
                        ID = 18, Name = "S"
                    },
                    new User {
                        ID = 19, Name = "T"
                    },
                    new User {
                        ID = 20, Name = "U"
                    },
                }
            };
            var  lMax  = 0.0;
            bool lEven = true;

            for (int i = 0; i < aCycles; i++)
            {
                var lRound = RoundFactory.CreateRound(lClass.UserBase.Take(aPlayers).Select(a => a.ID).ToList(), lClass, DateTime.Now, aCourts, "", "", true);

                var lGames = lRound.Games;

                foreach (var iGame in lGames)
                {
                    var lIDs = iGame.SideA.Select(a => a.ID).ToList();
                    lIDs.AddRange(iGame.SideB.Select(a => a.ID));
                    Assert.IsFalse(lIDs.GroupBy(a => a).Any(a => a.Count() > 1));
                }

                var lIds = lGames.SelectMany(a => a.SideA.Select(b => b.ID)).ToList();
                lIds.AddRange(lGames.SelectMany(a => a.SideB.Select(b => b.ID)).ToList());
                var lGrouping = lIds.GroupBy(a => a).Select(a => new { a.Key, Count = a.Count() }).ToList();
                //Assert.IsTrue(lGrouping.Select(a => a.Count).Max() == lGrouping.Select(a => a.Count).Min());
                if (lEven)
                {
                    lEven = lGrouping.Select(a => a.Count).Max() == lGrouping.Select(a => a.Count).Min();
                }
                if (lMax == 0)
                {
                    lMax = lGrouping.Select(a => a.Count).Max();
                }
                else
                {
                    lMax = lGrouping.Select(a => a.Count).Max() * 0.01 + lMax * 0.99;
                }
            }
            Console.Write(lEven ? "" : " nerovne ");
            Console.WriteLine($" - g {lMax}");
        }
Beispiel #12
0
 public override void SetUp()
 {
     base.SetUp();
     Round = RoundFactory.Create(1);
 }
Beispiel #13
0
        private void CreateLeague(CompetitionSchedule competitionSchedule, Competition leagueCompetition, List <Team> teams, Season season, MatchDateManager matchDateManager)
        {
            // Create a competition for the League and save it to the database.
            var leagueSeasonCompetition = new SeasonCompetition
            {
                Competition = leagueCompetition,
                Season      = season
            };

            competitionSchedule.SeasonCompetitions.Add(leagueSeasonCompetition);

            // Add the teams to the league.
            foreach (var team in teams)
            {
                var seasonCompetitionTeam = new SeasonCompetitionTeam
                {
                    SeasonCompetition = leagueSeasonCompetition,
                    Team = team
                };
                competitionSchedule.SeasonCompetitionTeams.Add(seasonCompetitionTeam);

                // Update current league for the team.
                team.CurrentLeagueCompetition = leagueCompetition;
            }

            // Create a match schedule.
            var roundRobinTournamentManager = new RoundRobinTournamentManager();
            var matchSchedule = roundRobinTournamentManager.GetSchedule(teams);

            foreach (var round in matchSchedule)
            {
                var matchDate   = matchDateManager.GetNextMatchDate(CompetitionType.League, round.Key);
                var leagueRound = RoundFactory.CreateRound($"Round {round.Key + 1}", leagueSeasonCompetition, matchDate, round.Key, leagueCompetition);
                competitionSchedule.Rounds.Add(leagueRound);

                foreach (var match in round.Value)
                {
                    match.Season        = season;
                    match.Round         = leagueRound;
                    match.Date          = matchDate;
                    match.CompetitionId = leagueCompetition.Id;
                    competitionSchedule.Matches.Add(match);
                }
            }

            // Create a league table.
            var leagueTable = new LeagueTable
            {
                CompetitionName   = leagueCompetition.Name,
                SeasonCompetition = leagueSeasonCompetition,
                SeasonId          = leagueSeasonCompetition.SeasonId
            };

            leagueTable.LeagueTablePositions = new List <LeagueTablePosition>();
            int position = 1;

            foreach (var team in teams)
            {
                team.CurrentLeaguePosition = position;
                leagueTable.LeagueTablePositions.Add(new LeagueTablePosition {
                    Team = team, LeagueTable = leagueTable, Position = position
                });
                position++;
            }

            competitionSchedule.LeagueTables.Add(leagueTable);
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            var lCount      = 15;
            var lRoundCount = 50;

            GenerujMore(lCount, lRoundCount);

            /**
             * lSelectedPlayers = lArrList.GetListExceptCountFromList(lSitting, lDict.GetMaxOrEqualRandom(lSitting));
             *
             * // vygeneruj nove kombinace po tuto partu lidi.
             * lCombinations = GetKCombs(lSelectedPlayers, 2).ToList();
             *
             * //for (int i = 0; i < 80; i++)
             * do
             * {
             *  var lGameList = new List<IEnumerable<int>>();
             *  lCombinations = GetKCombs(lSelectedPlayers, 2).ToList();
             *  do
             *  {
             *      mLog.Info("Continue by key....\n\n\n");
             *      //Console.ReadKey();
             *      List<int> lUnique = new List<int>();
             *      /**
             *      if (lDict.Values.Any())
             *      {
             *          mLog.Info("DictValues");
             *          if (lDict.Values.Min() != lDict.Values.Max())
             *          {
             *              mLog.Info("Values diff");
             *              var lMax = lDict.Values.Max();
             *              var lInts = new List<int>();
             *              foreach (var iKey in lDict.Keys)
             *              {
             *                  if (lDict[iKey] == lMax)
             *                  {
             *                      lInts.Add(iKey);
             *                  }
             *              }
             *
             *              lUnique = lRoundList.GetLIstOfItemsUnique();
             *              lUnique.AddRange(lInts);
             *              lUnique.AddRange(lGameList.GetLIstOfItemsUnique());
             *          }
             *          else
             *          {
             *              mLog.Info("Values consist");
             *              lUnique = lRoundList.GetLIstOfItemsUnique();
             *              lUnique.AddRange(lGameList.GetLIstOfItemsUnique());
             *          }
             *      }
             *      else
             *      {//
             *      mLog.Info("Default selection");
             *      lUnique = lRoundList.GetLIstOfItemsUnique();
             *      lUnique.AddRange(lGameList.GetLIstOfItemsUnique());
             *      //}
             *
             *      lUnique = lUnique.OrderBy(a => a).Distinct().ToList();
             *      var lFreeCombinations = lCombinations.RemoveItemsWithSubitemList(lUnique);
             *
             *      if (lFreeCombinations.Count == 0)
             *      {
             *
             *          mLog.Info("Clearing due 0 free conbinations");
             *          lRoundList.Clear();
             *          lGameList.Clear();
             *          lDict.Clear();
             *          continue;
             *      }
             *
             *      var lGamePair = lFreeCombinations.GetRandomItem();
             *      if (lGamePair.Any(a => lGameList.ItemContainsTypeItem(a)) ||
             *          lGamePair.Any(a => lRoundList.ItemContainsTypeItem(a)))
             *      {
             *          mLog.Error($"Selected pair {lGamePair.Select(a => $"{a}").Aggregate((a, b) => $"{a}|{b}")}");
             *      }
             *      else
             *      {
             *          mLog.Info("Adding");
             *          lGameList.Add(lGamePair);
             *      }
             *
             *  } while (lGameList.Count < 2);
             *
             *  lGameList.ForEach(a => lRoundList.Add(a));
             *  lGameList.ForEach(a => lGlobalRoundList.Add(a));
             *
             *
             *  lDict.Clear();
             *  lGameList.Clear();
             *  lArrList.ForEach(a=> lDict.Add(a,0));
             *  lGlobalRoundList.ToList().ForEach(a=>a.ToList().ForEach(b => lDict[b]++));
             *  //dodej lsit lidi kteri si maji jit sednout;
             *
             *  lSelectedPlayers = lArrList.GetListExceptCountFromList(lSitting, lDict.GetMaxOrEqualRandom(lSitting));
             *
             *  //// vygeneruj nove kombinace po tuto partu lidi.
             *  //lCombinations = GetKCombs(lSelectedPlayers, 2).ToList();
             * } while (lDict.Values.Min() != lDict.Values.Max() || lDict.Values.Min() < lRoundCount);
             *
             * //ChopAndSuey(lGlobalRoundList);
             *
             * lDict.Clear();
             * lArrList.ForEach(a=> lDict.Add(a,0));
             * lGlobalRoundList.ToList().ForEach(a=>a.ToList().ForEach(b => lDict[b]++));
             * mLog.Info("\n" + lDict.Keys.ToList().Select(a=> $"{a}: {lDict[a]}").Aggregate((a,b)=> $"{a}\n{b}"));//*/

            Console.ReadKey();
            return;

            #region Bordel
            //var lArr = lArrList.ToArray(); //new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            //while (lList.Count < Combinatorics.Combinations(lCount, 2))
            //{
            //    var lPair = lArr.SelectCombination(2, lRandom).ToArray();

            //    if (lPair[0] > lPair[1])
            //    {
            //        var lPom = lPair[0];
            //        lPair[0] = lPair[1];
            //        lPair[1] = lPom;
            //    }

            //    if (!lList.Any(a => a.Item1 == lPair[0] && a.Item2 == lPair[1]))
            //    {
            //        lList.Add(new Tuple<int, int>(lPair[0], lPair[1]));
            //    }
            //}

            //mLog.Info(lList.OrderBy(a => a.Item1).ThenBy(a => a.Item2).Select(a => $"{a.Item1}|{a.Item2}").Aggregate((a, b) => $"{a}\n{b}"));

            while (true)
            {
                var lClass = new Class
                {
                    UserBase = new List <User>
                    {
                        new User {
                            ID = 0, Name = "A"
                        },
                        new User {
                            ID = 1, Name = "B"
                        },
                        new User {
                            ID = 2, Name = "C"
                        },
                        new User {
                            ID = 3, Name = "D"
                        },
                        new User {
                            ID = 4, Name = "E"
                        },
                        new User {
                            ID = 5, Name = "F"
                        },
                        new User {
                            ID = 6, Name = "G"
                        },
                        new User {
                            ID = 7, Name = "H"
                        },
                        new User {
                            ID = 8, Name = "I"
                        },
                        new User {
                            ID = 9, Name = "J"
                        },
                        new User {
                            ID = 10, Name = "K"
                        },
                        new User {
                            ID = 11, Name = "L"
                        },
                        new User {
                            ID = 12, Name = "M"
                        },
                        new User {
                            ID = 13, Name = "N"
                        },
                        new User {
                            ID = 14, Name = "O"
                        },
                        new User {
                            ID = 15, Name = "P"
                        },
                        new User {
                            ID = 16, Name = "Q"
                        },
                        new User {
                            ID = 17, Name = "R"
                        },
                        new User {
                            ID = 18, Name = "S"
                        },
                        new User {
                            ID = 19, Name = "T"
                        },
                        new User {
                            ID = 20, Name = "U"
                        },
                    }
                };
                var lPla   = 16;
                var lRound = RoundFactory.CreateRound2(lClass.UserBase.Take(lPla).Select(a => a.ID).ToList(), lClass, DateTime.Now, CourtCountCalc(lPla), "", "", 5);


                var lSelected = lRound.Games.Select(a => a.SideA.Select(b => b.ID.ToString()).Aggregate((c, b) => c + ":" + b)).ToList();
                lSelected.AddRange(lRound.Games.Select(a => a.SideB.Select(b => b.ID.ToString()).Aggregate((c, b) => c + ":" + b)));

                var lDictionary = new Dictionary <string, int>();
                var lGrouped    = lSelected.GroupBy(a => a);
                foreach (var iGroup in lGrouped)
                {
                    if (lDictionary.ContainsKey(iGroup.Key))
                    {
                        lDictionary[iGroup.Key] += iGroup.Count();
                    }
                    else
                    {
                        lDictionary.Add(iGroup.Key, iGroup.Count());
                    }
                }

                foreach (var iKey in lDictionary.Keys.OrderBy(a => a))
                {
                    if (lDictionary[iKey] > 1)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                    }
                    else
                    {
                        Console.ResetColor();
                    }
                    Console.WriteLine($"{iKey} - {lDictionary[iKey]}");
                }

                Console.ReadKey();
                Console.Clear();
                #endregion
            }
        }
Beispiel #15
0
        public static void Demo()
        {
            List <Figure> figures = new List <Figure>();

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Console graphical editor.");
                Console.WriteLine("Select option.");
                Console.WriteLine("1. Add Line.");
                Console.WriteLine("2. Add Circle.");
                Console.WriteLine("3. Add Rectangle.");
                Console.WriteLine("4. Add Round.");
                Console.WriteLine("5. Add Ring.");
                Console.WriteLine("6. Add Ring (aggregation).");
                Console.WriteLine("7. Show figures.");
                Console.WriteLine("0. Exit.");

                int select;
                while (!int.TryParse(Console.ReadLine(), out select))
                {
                    Console.WriteLine("Wrong input. Try again.");
                }

                switch (select)
                {
                case 1:
                    figures.Add(LineFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Line added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 2:
                    figures.Add(CircleFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Circle added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 3:
                    figures.Add(RectangleFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Rectangle added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 4:
                    figures.Add(RoundFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Round added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 5:
                    figures.Add(RingFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Ring added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 6:
                    figures.Add(RingAggregationFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Ring (aggregation) added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 7:
                    Console.Clear();
                    foreach (Figure figure in figures)
                    {
                        figure.ShowInfo();
                        Console.WriteLine();
                    }
                    Console.ReadLine();
                    break;

                case 0:
                    Console.WriteLine("Good luck!");
                    Console.ReadLine();
                    return;

                default:
                    Console.WriteLine("Wrong option. Try again.");
                    break;
                }
            }
        }