public void AddPlayer(Player player) { if (CheckIfPlayerExists(player)) throw new InvalidOperationException("Player already exists for that team."); this.players.Add(player); }
public void AddPlayer(Player player) { if (PlayerExists(player)) { throw new InvalidOperationException("This player is already in that team"); } this.players.Add(player); }
public void AddPlayer(Player player) { if (CheckIfPlayerExists(player)) { throw new InvalidOperationException( $"{player.FirstName} {player.LastName} already exists in {player.Team}"); } players.Add(player); }
private bool CheckIfPlayerExists(Player player) { return this.players.Any(p => p.FirstName == player.FirstName && p.LastName == player.LastName); }
public void AddPlayer(Player player) { if (this.CheckIfPlayerExist(player)) { throw new InvalidOperationException(MsgConstants.PlayerExistsInTeam); } this.players.Add(player); }