// 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); }
public void AddTeamToTournament(string teamName, string tournamentName) { Tournament tournament = tournamentRepository.GetTournament(tournamentName); if (tournament != null) { Team team = new Team(teamName); tournament.AddTeam(team); Console.WriteLine(team.Name + " er blevet tilføjet til turneringen, " + tournament.Name); } else { Console.WriteLine("Turneringen du prøver at tilføje et hold til findes ikke."); } Console.ReadLine(); }