public void ShowScore(string tournamentName)
        {
            Tournament    tournament = tournamentRepository.GetTournament(tournamentName);
            List <int>    points     = new int[tournament.GetTeams().Count].ToList <int>();
            List <Team>   teams      = tournament.GetTeams();
            List <string> sortedList = new List <string>();

            int rounds = tournament.GetNumberOfRounds();

            for (int i = 0; i < rounds; i++)
            {
                List <Team> winners = tournament.GetRound(i).GetWinningTeams();
                foreach (Team winner in winners)
                {
                    for (int j = 0; j < tournament.GetTeams().Count; j++)
                    {
                        if (winner.Name == tournament.GetTeams()[j].Name)
                        {
                            points[j] = points[j] + 1;
                        }
                    }
                }
            }

            while (points.Count > 0)
            {
                int index = points.IndexOf(points.Max());
                sortedList.Add(teams[index].ToString() + ": " + points[index]);
                points.RemoveAt(index);
                teams.RemoveAt(index);
            }

            sortedList.ForEach(Console.WriteLine);
        }
예제 #2
0
        // The Init() method is ONLY meant as a shortcut to fill in some data.
        // Actually it should be modified (refactored) and moved to a test project so clever tests can have some data
        // and check if the functionality is as required!!

        public void Init()
        {
            Console.WriteLine("Initialiserer \"X\"...");
            TeamRepo   teamRepository   = new TeamRepo();
            PlayerRepo playerRepository = new PlayerRepo();
            string     tournamentName   = "X";
            Tournament tournament       = new Tournament(tournamentName);

            Console.WriteLine("Registrerer Liga...");
            // initialize with a default tournament
            tournamentRepository.RegisterTournament(tournament);

            Console.WriteLine("Registrerer spillere...");
            playerRepository.RegisterPlayer("Laust Ulriksen");
            playerRepository.RegisterPlayer("Matthias Therkelsen", null, "*****@*****.**", "+45 47002155");
            playerRepository.RegisterPlayer("Martin Bertelsen", "Nyborgvej 10, Odense", null, "+45 22521112");
            playerRepository.RegisterPlayer("Line Madsen", "Kochsgade 21, Odense", "*****@*****.**", "+45 00142563");
            playerRepository.RegisterPlayer(new Player("Jette Detlevsen"));

            Console.WriteLine("Registrerer teams...");
            // initialize with a default set of teams
            teamRepository.RegisterTeam("A");
            teamRepository.RegisterTeam("B");
            teamRepository.RegisterTeam("C");
            teamRepository.RegisterTeam("D");
            teamRepository.RegisterTeam("E");

            Console.WriteLine("Tilføjer spillere til teams...");
            // Add players to teams
            Team FCK = teamRepository.GetTeam("A");

            FCK.AddPlayer(playerRepository.GetPlayer("Laust Ulriksen"));
            Team OB = teamRepository.GetTeam("B");

            FCK.AddPlayer(playerRepository.GetPlayer("Matthias Therkelsen"));
            Team BiF = teamRepository.GetTeam("C");

            BiF.AddPlayer(playerRepository.GetPlayer("Martin Bertelsen"));
            Team Hobro = teamRepository.GetTeam("D");

            Hobro.AddPlayer(playerRepository.GetPlayer("Line Madsen"));
            Team AGF = teamRepository.GetTeam("E");

            AGF.AddPlayer(playerRepository.GetPlayer("Jette Detlevsen"));

            Console.WriteLine("Tilføjer teams til Liga...");
            // Add teams to tournament
            tournament = tournamentRepository.GetTournament(tournamentName);
            tournament.AddTeam(FCK);
            tournament.AddTeam(OB);
            tournament.AddTeam(BiF);
            tournament.AddTeam(Hobro);
            tournament.AddTeam(AGF);

            Console.WriteLine("Planlægger 1. runde...");
            // Initialize first round (this also initializes matches)
            ScheduleNewRound(tournamentName);
        }
예제 #3
0
        public void ShowScore(string tournamentName)
        {
            Tournament    tournament = tournamentRepository.GetTournament(tournamentName);
            List <int>    points     = new int[tournament.GetTeams().Count].ToList <int>();
            List <Team>   teams      = tournament.GetTeams();
            List <string> sortedList = new List <string>();

            int countedTeams = teams.Count;
            int rounds       = tournament.GetNumberOfRounds();

            for (int i = 0; i < rounds; i++)
            {
                List <Team> winners = tournament.GetRound(i).GetWinningTeams();
                if (winners[0] != null)
                {
                    foreach (Team winner in winners)
                    {
                        for (int j = 0; j < tournament.GetTeams().Count; j++)
                        {
                            if (winner.Name == tournament.GetTeams()[j].Name)
                            {
                                points[j] = points[j] + 1;
                            }
                        }
                    }
                }
            }



            Console.WriteLine("  #####                                        ");
            Console.WriteLine(" #     # ##### # #      #      # #    #  ####  ");
            Console.WriteLine(" #         #   # #      #      # ##   # #    # ");
            Console.WriteLine("  #####    #   # #      #      # # #  # #      ");
            Console.WriteLine("       #   #   # #      #      # #  # # #  ### ");
            Console.WriteLine(" #     #   #   # #      #      # #   ## #    # ");
            Console.WriteLine("  #####    #   # ###### ###### # #    #  ####  ");

            Console.WriteLine("0-------------------------------------------0");
            PrintLine("Turnering: " + tournamentName);
            PrintLine("Spillede runder: " + rounds);
            PrintLine("Spillede kampe: " + "Ehh??");
            Console.WriteLine("|----------------------------| VUNDNE KAMPE |");
            for (int i = 0; i < countedTeams; i++)
            {
                int index = points.IndexOf(points.Max());
                PrintLine(PaddedText(teams[index].ToString(), 27) + " - " + PaddedText(points[index].ToString(), 13));

                points.RemoveAt(index);
                teams.RemoveAt(index);
            }
            Console.WriteLine("0-------------------------------------------0");
            Console.ReadLine();
        }
예제 #4
0
        public void ShowScore(string tournamentName)
        {
            Round      R = new Round();
            Tournament t = tournamentRepository.GetTournament(tournamentName);

            Console.WriteLine(" #####                                        ");
            Console.WriteLine("#     # ##### # #      #      # #    #  ####  ");
            Console.WriteLine("#         #   # #      #      # ##   # #    #");
            Console.WriteLine(" #####    #   # #      #      # # #  # #      ");
            Console.WriteLine("      #   #   # #      #      # #  # # #  ### ");
            Console.WriteLine("#     #   #   # #      #      # #   ## #    # ");
            Console.WriteLine(" #####    #   # ###### ###### # #    #  ####  ");
            Console.WriteLine("0------------------------------------------------0");
            Console.WriteLine("|    Turnering: " + tournamentName + "		 |");
            Console.WriteLine("|    Spillede runder: " + t.GetNumberOfRounds() + "				 |");
            Console.WriteLine("|    Spillede kampe:  " + R.GetMatchesCount() + "				 |");
            t.TeamReturner();
        }
예제 #5
0
        public void ShowScore(string tournamentName)
        {
            using (StreamWriter writer = new StreamWriter("C:/Users/woopi/Desktop/kode/Dragons-Lair-master/DragonsLair/TurneringResultat.txt"))
            {
                Tournament  tournament = tournamentRepository.GetTournament(tournamentName);  // Instancere et objekt kaldet tournament som referere til  metode i repo
                List <int>  points     = new int[tournament.GetTeams().Count].ToList <int>(); // Opretter en liste ud fra et tomt array som har længden af teams.
                List <Team> teams      = tournament.GetTeams();                               // Opretter en liste ved at kalde på metoden GetTeams fra tournament classen.

                int countedTeams = teams.Count;                                               // countedTeams tæller hvor mange teams der er i vores liste "teams"
                int rounds       = tournament.GetNumberOfRounds();                            // Tæller runder ved at kalde på metoden GetNumberOfRounds.

                for (int i = 0; i < rounds; i++)
                {
                    List <Team> winners = tournament.GetRound(i).GetWinningTeams(); // Liste med alle vinderne
                    if (winners[0] != null)                                         // hvis den første plads er null, betyder det at der ikke er nogle teams.
                    {
                        foreach (Team winner in winners)
                        {
                            for (int j = 0; j < tournament.GetTeams().Count; j++) // køre igennem så mange gange som der er hold.
                            {
                                if (winner.Name == tournament.GetTeams()[j].Name) // hvis holdet er vinderen, får de et point.
                                {
                                    points[j] = points[j] + 1;
                                }
                            }
                        }
                    }
                }

                Console.WriteLine("  #####                                        ");
                Console.WriteLine(" #     # ##### # #      #      # #    #  ####  ");
                Console.WriteLine(" #         #   # #      #      # ##   # #    # ");
                Console.WriteLine("  #####    #   # #      #      # # #  # #      ");
                Console.WriteLine("       #   #   # #      #      # #  # # #  ### ");
                Console.WriteLine(" #     #   #   # #      #      # #   ## #    # ");
                Console.WriteLine("  #####    #   # ###### ###### # #    #  ####  ");

                writer.WriteLine("  #####                                        ");
                writer.WriteLine(" #     # ##### # #      #      # #    #  ####  ");
                writer.WriteLine(" #         #   # #      #      # ##   # #    # ");
                writer.WriteLine("  #####    #   # #      #      # # #  # #      ");
                writer.WriteLine("       #   #   # #      #      # #  # # #  ### ");
                writer.WriteLine(" #     #   #   # #      #      # #   ## #    # ");
                writer.WriteLine("  #####    #   # ###### ###### # #    #  ####  ");

                Console.WriteLine("0-------------------------------------------0");
                writer.WriteLine("0-------------------------------------------0");
                Console.WriteLine("Turnering: " + tournamentName);
                writer.WriteLine("Turnering: " + tournamentName);
                Console.WriteLine("Spillede runder: " + rounds);
                writer.WriteLine("Spillede runder: " + rounds);
                writer.WriteLine("Vinder af turnering: ");
                Console.WriteLine("|----------------------------| VUNDNE KAMPE |");
                writer.WriteLine("|----------------------------| VUNDNE KAMPE |");
                for (int i = 0; i < countedTeams; i++)
                {
                    int index = points.IndexOf(points.Max());
                    Console.WriteLine(PaddedText(teams[index].ToString(), 27) + " - " + PaddedText(points[index].ToString(), 13));
                    writer.WriteLine(PaddedText(teams[index].ToString(), 27) + " - " + PaddedText(points[index].ToString(), 13));

                    points.RemoveAt(index);
                    teams.RemoveAt(index);
                }
                Console.WriteLine("0-------------------------------------------0");
                writer.WriteLine("0-------------------------------------------0");
                Console.ReadLine();
            }
        }