Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- class Prizebox:
- def __init__(self, kind, label, contents, big_prize=False, open=False):
- self.kind = kind
- self.label = label
- self.contents = contents
- self.big_prize = big_prize
- self.open = open
- class Stage:
- def __init__(self, name, *args): #args will be Prizebox objects
- self.name = name
- self.spots = list(args)
- def kinds(self):
- k = [self.spots[i].kind for i in range(0, len(self.spots))]
- return k
- def show_goat(self, prize):
- #make list of just 'goats'
- g = []
- if prize.big_prize:
- g = [item for item in self.spots if item.label != prize.label]
- random.shuffle(g)
- else:
- g = [item for item in self.spots if item.label != prize.label and not item.big_prize]
- return g
- def get_choice(options):
- if options == None: return False
- print(', '.join(options))
- c = input('\n')
- if c not in (options):
- return False
- else:
- return c
- def get_choice2(options):
- return ''
- """
- Set up the prizes and the stage
- """
- door1 = Prizebox('door', 'Door #1', 'golf cart', True)
- door2 = Prizebox('door', 'Door #2', 'box of diapers')
- chest = Prizebox('treasure chest', 'the treasure chest', '$5 bill')
- box_list = [door1, door2, chest]
- random.shuffle(box_list)
- stage = Stage('Let\'s Make a Deal!', *box_list)
- """
- Get the contestant's initial choice
- """
- print('The \"' + stage.name + '\" stage has on it these %d items:' % (len(stage.spots)))
- print(', '.join(stage.kinds()))
- print('\nWhich item would you like to choose?')
- print('-'*35)
- choices = [stage.spots[i].label for i in range(0, len(stage.spots))]
- while not get_choice(None):
- first_choice = get_choice(choices)
- if first_choice: break
- print('\nAwesome, you chose ' + first_choice + '.')
- """
- Show a door with a 'goat' level prize
- """
- for item in stage.spots:
- if item.label == first_choice:
- goat_list = stage.show_goat(item)
- print('\nBefore we see what\'s there, let me show you %s...\n' % (goat_list[0].label) )
- print(goat_list[0].contents)
- """
- Get the contestant's decision to stay with their choice or switch
- """
- print('\nWould you like to stay with %s or switch to %s?' % (first_choice, 'placeholder'))
- #what's the other door? maybe based on .closed property
- get_choice2()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement