Example #1
0
        private static void SetTeamsValues(
            IDictionary <string, Team> teams,
            TeamMatchInputData teamMatchInputData
            )
        {
            if (!teams.ContainsKey(teamMatchInputData.FirstTeam))
            {
                teams.Add(teamMatchInputData.FirstTeam, new Team(teamMatchInputData.FirstTeam));
            }

            if (!teams.ContainsKey(teamMatchInputData.SecondTeam))
            {
                teams.Add(teamMatchInputData.SecondTeam, new Team(teamMatchInputData.SecondTeam));
            }

            if (!teams.ContainsKey(teamMatchInputData.Organiser))
            {
                teams.Add(teamMatchInputData.Organiser, new Team(teamMatchInputData.Organiser));
            }

            teams[teamMatchInputData.FirstTeam].AddRoundData(teamMatchInputData.Round, teamMatchInputData.Basket,
                                                             teamMatchInputData.SecondTeam);
            teams[teamMatchInputData.SecondTeam].AddRoundData(teamMatchInputData.Round, teamMatchInputData.Basket,
                                                              teamMatchInputData.FirstTeam);
            teams[teamMatchInputData.Organiser].AddOrganiser(teamMatchInputData.Round, teamMatchInputData.Basket);
        }
Example #2
0
        private static void Main()
        {
            var inputFiles = new List <string>
            {
                "3XE12014",
                "3XS12014",
                "3XZ12014"
            };

            foreach (var fileName in inputFiles)
            {
                var file = new StreamReader(string.Format("..\\..\\CategoryTxtData\\{0}.txt", fileName));

                string line;
                var    teams       = new Dictionary <string, Team>();
                var    tournaments = new Dictionary <RoundBasket, Tournament>();

                while ((line = file.ReadLine()) != null)
                {
                    var teamMatchInputData = new TeamMatchInputData(line);

                    var match = new Match(
                        teamMatchInputData.FirstTeam,
                        teamMatchInputData.SecondTeam,
                        teamMatchInputData.FirstTeamGoals,
                        teamMatchInputData.SecondTeamGoals,
                        teamMatchInputData.GoalsStatus,
                        teamMatchInputData.Organiser
                        );

                    var roundBasket = new RoundBasket(teamMatchInputData.Round, teamMatchInputData.Basket, teamMatchInputData.SportHall);
                    if (!tournaments.ContainsKey(roundBasket))
                    {
                        tournaments.Add(roundBasket, new Tournament());
                    }
                    tournaments[roundBasket].AddMatch(match);

                    SetTeamsValues(teams, teamMatchInputData);
                }

                // zmeny v kosich
                WriteBaskedChange(fileName, teams);

                // zmeny v kosich a poradatelstvi
                WriteBasketOrganiser(fileName, teams);

                // krizova tabulka kdo s kym kolikrat hral
                WrieCrossTable(fileName, teams);

                // vystup po kolech v prumerny rozdil - dva vystupy, jednou pro excel a podruhy pro LaTeX
                WriteAvarageDiff(fileName, tournaments);

                // vystup po kolech v maximalni rozdil rozdil
                WrieMaxDiff(fileName, tournaments);

                // vystup kolik kterych uktkani skoncilo jakym vysledkem
                WriteSumMatchDiff(fileName, tournaments);

                // poradatelstvi a jeho zmeny
                WriteOrganization(fileName, tournaments, teams);

                // haly
                using (
                    var sportHallFile = new StreamWriter(string.Format("..\\..\\CategoryTxtOuput\\{0}-SportHall.txt", fileName))
                    )
                {
                    var sportHalls = new HashSet <string>();
                    foreach (var tournament in tournaments)
                    {
                        sportHalls.Add(tournament.Key.SportHall);
                    }

                    var teamSportHalls = new Dictionary <string, Dictionary <string, int> >();                  //string - naze tymu, string - hala, int - kolikrat
                    foreach (var team in teams)
                    {
                        teamSportHalls.Add(team.Key, new Dictionary <string, int>());
                        foreach (var sportHall in sportHalls)
                        {
                            teamSportHalls[team.Key].Add(sportHall, 0);
                        }
                    }

                    foreach (var tournament in tournaments)
                    {
                        foreach (var team in tournament.Value.GetTournametTeams())
                        {
                            teamSportHalls[team][tournament.Key.SportHall]++;
                        }
                    }

                    foreach (var hall in teamSportHalls.First().Value)
                    {
                        sportHallFile.Write("\t{0}", hall.Key);
                    }
                    sportHallFile.WriteLine();

                    foreach (var teamSportHall in teamSportHalls)
                    {
                        sportHallFile.Write(teamSportHall.Key);

                        foreach (var hall in teamSportHall.Value)
                        {
                            sportHallFile.Write("\t{0}", hall.Value);
                        }
                        sportHallFile.WriteLine();
                    }
                }
            }
        }
Example #3
0
        private static void SetTeamsValues(
            IDictionary<string, Team> teams,
            TeamMatchInputData teamMatchInputData
            )
        {
            if (!teams.ContainsKey(teamMatchInputData.FirstTeam))
            {
                teams.Add(teamMatchInputData.FirstTeam, new Team(teamMatchInputData.FirstTeam));
            }

            if (!teams.ContainsKey(teamMatchInputData.SecondTeam))
            {
                teams.Add(teamMatchInputData.SecondTeam, new Team(teamMatchInputData.SecondTeam));
            }

            if (!teams.ContainsKey(teamMatchInputData.Organiser))
            {
                teams.Add(teamMatchInputData.Organiser, new Team(teamMatchInputData.Organiser));
            }

            teams[teamMatchInputData.FirstTeam].AddRoundData(teamMatchInputData.Round, teamMatchInputData.Basket,
                teamMatchInputData.SecondTeam);
            teams[teamMatchInputData.SecondTeam].AddRoundData(teamMatchInputData.Round, teamMatchInputData.Basket,
                teamMatchInputData.FirstTeam);
            teams[teamMatchInputData.Organiser].AddOrganiser(teamMatchInputData.Round, teamMatchInputData.Basket);
        }
Example #4
0
        private static void Main()
        {
            var inputFiles = new List<string>
            {
                "3XE12014",
                "3XS12014",
                "3XZ12014"
            };

            foreach (var fileName in inputFiles)
            {
                var file = new StreamReader(string.Format("..\\..\\CategoryTxtData\\{0}.txt", fileName));

                string line;
                var teams = new Dictionary<string, Team>();
                var tournaments = new Dictionary<RoundBasket, Tournament>();

                while ((line = file.ReadLine()) != null)
                {
                    var teamMatchInputData = new TeamMatchInputData(line);

                    var match = new Match(
                        teamMatchInputData.FirstTeam,
                        teamMatchInputData.SecondTeam,
                        teamMatchInputData.FirstTeamGoals,
                        teamMatchInputData.SecondTeamGoals,
                        teamMatchInputData.GoalsStatus,
                        teamMatchInputData.Organiser
                    );

                    var roundBasket = new RoundBasket(teamMatchInputData.Round, teamMatchInputData.Basket, teamMatchInputData.SportHall);
                    if (!tournaments.ContainsKey(roundBasket))
                    {
                        tournaments.Add(roundBasket, new Tournament());
                    }
                    tournaments[roundBasket].AddMatch(match);

                    SetTeamsValues(teams, teamMatchInputData);
                }

                // zmeny v kosich
                WriteBaskedChange(fileName, teams);

                // zmeny v kosich a poradatelstvi
                WriteBasketOrganiser(fileName, teams);

                // krizova tabulka kdo s kym kolikrat hral
                WrieCrossTable(fileName, teams);

                // vystup po kolech v prumerny rozdil - dva vystupy, jednou pro excel a podruhy pro LaTeX
                WriteAvarageDiff(fileName, tournaments);

                // vystup po kolech v maximalni rozdil rozdil
                WrieMaxDiff(fileName, tournaments);

                // vystup kolik kterych uktkani skoncilo jakym vysledkem
                WriteSumMatchDiff(fileName, tournaments);

                // poradatelstvi a jeho zmeny
                WriteOrganization(fileName, tournaments, teams);

                // haly
                using (
                    var sportHallFile = new StreamWriter(string.Format("..\\..\\CategoryTxtOuput\\{0}-SportHall.txt", fileName))
                )
                {
                    var sportHalls = new HashSet<string>();
                    foreach (var tournament in tournaments)
                    {
                        sportHalls.Add(tournament.Key.SportHall);
                    }

                    var teamSportHalls = new Dictionary<string, Dictionary<string, int>>();	//string - naze tymu, string - hala, int - kolikrat
                    foreach (var team in teams)
                    {
                        teamSportHalls.Add(team.Key, new Dictionary<string, int>());
                        foreach (var sportHall in sportHalls)
                        {
                            teamSportHalls[team.Key].Add(sportHall, 0);
                        }
                    }

                    foreach (var tournament in tournaments)
                    {
                        foreach (var team in tournament.Value.GetTournametTeams())
                        {
                            teamSportHalls[team][tournament.Key.SportHall]++;
                        }
                    }

                    foreach (var hall in teamSportHalls.First().Value)
                    {
                        sportHallFile.Write("\t{0}", hall.Key);
                    }
                    sportHallFile.WriteLine();

                    foreach (var teamSportHall in teamSportHalls)
                    {
                        sportHallFile.Write(teamSportHall.Key);

                        foreach (var hall in teamSportHall.Value)
                        {
                            sportHallFile.Write("\t{0}", hall.Value);
                        }
                        sportHallFile.WriteLine();
                    }

                }
            }
        }