Skip to content

Instantly share code, notes, and snippets.

@cjmcgraw
Created August 19, 2014 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjmcgraw/659144a2bf599b3c4012 to your computer and use it in GitHub Desktop.
Save cjmcgraw/659144a2bf599b3c4012 to your computer and use it in GitHub Desktop.
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