Created
August 19, 2014 22:37
-
-
Save cjmcgraw/659144a2bf599b3c4012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FantasyTeam(object): | |
def __init__(self): | |
self._roster = {'RB' : None, | |
'QB' : None, | |
... , | |
'WR': None} | |
self._points = 0.0 | |
def draft(self, player): | |
if player.position not in self._roster: | |
# update player name | |
raise RosterPositionFilledError(self._roster[player.position], player) | |
.... | |
class RosterPositionFilledError(Exception): | |
ERROR_MSG_FRMT = "Roster position of {} already filled by {}. Cannot add {}" | |
def __init__(self, roster_player, attempted_player): | |
error_msg = ERROR_MSG_FRMT.format(roster_player.position, roster_player, attempted_player) | |
super(RosterPositionFilledError, self).__init__(error_msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment