public IList<Team> CreateRandomTeams(IList<Player> players)
        {
            if (players.Count % 2 == 1)
            {
                throw new InvalidNumberOfPlayersException("The number of Players available is not even.");
            }

            List<Team> teams = new List<Team>();
            int teamSize = 0;
            Team team = new Team();
            foreach (Player player in players)
            {
                team.addPlayer(player);
                if (++teamSize % 2 == 0)
                {
                    teams.Add(team);
                    team = new Team();
                }
            }

            return teams;
        }
Exemplo n.º 2
0
 public void AddTeam(Team newTeam)
 {
     teams.Add(newTeam);
     RaisePropertyChanged("Teams");
 }