Lemonade Stand: Difference between revisions
| Line 116: | Line 116: | ||
print 'It starts raining cups!' | print 'It starts raining cups!' | ||
stored_cups += 10 | stored_cups += 10 | ||
print "" | |||
def supply_Decay(): | def supply_Decay(): | ||
global stored_sugar, stored_lemons, stored_cups | |||
if stored_sugar > 0: | |||
stored_sugar -= 10 % stored_sugar | |||
if stored_lemons > 0: | |||
stored_lemons -= 10 % stored_lemons | |||
if stored_cups > 0: | |||
stored_cups -= 10% stored_cups | |||
return -1 | |||
# default values | # default values | ||
| Line 140: | Line 149: | ||
for day in range(1, num_days + 1): | for day in range(1, num_days + 1): | ||
| Line 148: | Line 157: | ||
print "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯" | print "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯" | ||
print "" | print "" | ||
random_Event() | |||
print "You have "+`stored_cups`+" cups, "+`stored_lemons`+" lemons, and "+`stored_sugar`+" sugar left." | print "You have "+`stored_cups`+" cups, "+`stored_lemons`+" lemons, and "+`stored_sugar`+" sugar left." | ||
| Line 154: | Line 167: | ||
expenses = 0 | expenses = 0 | ||
cost_over = 1 | |||
while cost_over == 1: | |||
in_num = take_input("How much sugar") | potential_expense = 0 | ||
in_num = take_input("How many cups") | |||
potential_expense = expenses + (in_num * cup_price) | |||
if potential_expense < bank: | |||
cost_over = -1 | |||
expenses += in_num * cup_price | |||
stored_cups += in_num | |||
else: | |||
print 'You cant afford that many cups' | |||
cost_over = 1 | |||
while cost_over == 1: | |||
potential_expense = 0 | |||
in_num = take_input("How many lemons") | |||
potential_expense = expenses + (in_num * cup_price) | |||
if potential_expense < bank: | |||
cost_over = -1 | |||
expenses += in_num * lemon_price | |||
stored_lemons += in_num | |||
else: | |||
print 'You cant afford that many lemons' | |||
cost_over = 1 | |||
while cost_over == 1: | |||
potential_expense = 0 | |||
in_num = take_input("How much sugar") | |||
potential_expense = expenses + (in_num * cup_price) | |||
if potential_expense < bank: | |||
cost_over = -1 | |||
expenses += in_num * sugar_price | |||
stored_sugar += in_num | |||
else: | |||
print 'You cant afford that many lemons' | |||
today = min(stored_cups, stored_lemons, stored_sugar) | today = min(stored_cups, stored_lemons, stored_sugar) | ||
| Line 191: | Line 237: | ||
print "Current funds: $"+ "%.2f" % bank | print "Current funds: $"+ "%.2f" % bank | ||
supply_Decay() | |||
print | print | ||