fork download
  1. class Monopoly:
  2. def __init__(self, *players):
  3. self.board = list(self._init_board())
  4. self.players = list(self._init_players(players))
  5.  
  6. def _init_board(self):
  7. KEYS = ('name', 'color', 'list_price', 'construction_cost', 'remarks')
  8. PROPS = (('GO', 0, 0, 0, 'Starting_point', []),
  9. ('Mediterranean Street', 1, 60, 50, 'No_information', []))
  10. return map(lambda prop: dict(zip(KEYS, prop)), PROPS)
  11.  
  12. def _init_players(self, players):
  13. KEYS = ('name', 'money', 'pos')
  14. return map(lambda name: dict(zip(KEYS, (name, 1500, 0))), players)
  15.  
  16. game = Monopoly('a', 'b')
  17.  
  18. print(game.board)
  19. print(game.players)
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
[{'list_price': 0, 'construction_cost': 0, 'remarks': 'Starting_point', 'name': 'GO', 'color': 0}, {'list_price': 60, 'construction_cost': 50, 'remarks': 'No_information', 'name': 'Mediterranean Street', 'color': 1}]
[{'pos': 0, 'name': 'a', 'money': 1500}, {'pos': 0, 'name': 'b', 'money': 1500}]