def add_player(tennis_league: League, player: str, level=1.0, initial_points=0.0): player = Player(player, level, initial_points) try: tennis_league.add_playing_entity(player) except PlayingEntityAlreadyExistsError: pass return player
def add_doubles_team(tennis_league: League, name1: str, name2: str, level=1.0, initial_points=0.0): p1 = add_player(tennis_league, name1) p2 = add_player(tennis_league, name2) team = DoublesTeam(p1, p2, level, initial_points) try: tennis_league.add_playing_entity(team) except PlayingEntityAlreadyExistsError: pass return team