예제 #1
0
파일: Team.cs 프로젝트: nadiahristova/OOP
        public void AddPlayer(Player player)
        {
            if (CheckIfPlayerExists(player))
                throw new InvalidOperationException("Player already exists for that team.");

            this.players.Add(player);
        }
예제 #2
0
 public void AddPlayer(Player player)
 {
     if (PlayerExists(player))
     {
         throw new InvalidOperationException("This player is already in that team");
     }
     this.players.Add(player);
 }
예제 #3
0
        public void AddPlayer(Player player)
        {
            if (CheckIfPlayerExists(player))
            {
                throw new InvalidOperationException(
                    $"{player.FirstName} {player.LastName} already exists in {player.Team}");
            }

            players.Add(player);
        }
예제 #4
0
 private bool CheckIfPlayerExists(Player player)
 {
     return this.players.Any(p => p.FirstName == player.FirstName &&
                                  p.LastName == player.LastName);
 }
예제 #5
0
        public void AddPlayer(Player player)
        {
            if (this.CheckIfPlayerExist(player))
            {
                throw new InvalidOperationException(MsgConstants.PlayerExistsInTeam);
            }

            this.players.Add(player);
        }