Beispiel #1
0
        public decimal GetPlayerSalary(long playerId)
        {
            SoccerPlayer player = null;

            if (!listSoccerPlayer.TryGetValue(playerId, out player))
            {
                throw new PlayerNotFoundException();
            }

            return(player.salary);
        }
Beispiel #2
0
        public string GetPlayerName(long playerId)
        {
            SoccerPlayer player = null;

            listSoccerPlayer.TryGetValue(playerId, out player);

            if (player == null)
            {
                throw new PlayerNotFoundException();
            }

            return(player.name);
        }
Beispiel #3
0
        public void SetCaptain(long playerId)
        {
            SoccerPlayer soccerPlayer = null;

            listSoccerPlayer.TryGetValue(playerId, out soccerPlayer);

            if (soccerPlayer == null)
            {
                throw new PlayerNotFoundException();
            }

            SoccerTeam soccerTeam = null;

            listSoccerTeam.TryGetValue(soccerPlayer.teamId, out soccerTeam);
            soccerTeam.captainPlayerId = playerId;
        }
Beispiel #4
0
        public void AddPlayer(long id, long teamId, string name, DateTime birthDate, int skillLevel, decimal salary)
        {
            foreach (var teamItem in _soccerTeams.Values)
            {
                if (teamItem.ContainsPlayerId(id))
                {
                    throw new UniqueIdentifierException($"Já existe um jogador com o ID '{id}'.");
                }
            }

            SoccerTeam team;

            if (!_soccerTeams.TryGetValue(teamId, out team))
            {
                throw new TeamNotFoundException($"Não foi encontrado o time: {teamId}");
            }
            else
            {
                var newPlayer = new SoccerPlayer(id, teamId, name, birthDate, skillLevel, salary);
                team.AddPlayer(newPlayer);
            }
        }
Beispiel #5
0
        public string GetPlayerName(long playerId)
        {
            SoccerPlayer player = GetPlayer(playerId);

            return(player.Name);
        }
Beispiel #6
0
        public void SetCaptain(long playerId)
        {
            SoccerPlayer newCaptain = GetPlayer(playerId);

            _soccerTeams[newCaptain.TeamId].SetCaptain(playerId);
        }
Beispiel #7
0
        public decimal GetPlayerSalary(long playerId)
        {
            SoccerPlayer player = GetPlayer(playerId);

            return(player.Salary);
        }