Line 79: |
Line 79: |
| # -*- coding: cp1252 -*- | | # -*- coding: cp1252 -*- |
| import random | | import random |
| + | from counting import play_Money |
| + | |
| | | |
| | | |
Line 88: |
Line 90: |
| | | |
| | | |
| + | def weather_Change( ): |
| + | global weather |
| + | weather = random.randint( -1, 1 ) |
| + | |
| + | if weather == -1: |
| + | print "It looks like its going to rain tomorrow" |
| + | elif weather == 0: |
| + | print "Its a normal day tomorrow" |
| + | elif weather == 1: |
| + | print "Tomorrow looks to be very hot" |
| + | |
| def take_input(text, default = 0): | | def take_input(text, default = 0): |
| try: | | try: |
Line 139: |
Line 152: |
| lemon_price = 1.00 | | lemon_price = 1.00 |
| sugar_price = .05 | | sugar_price = .05 |
− | | + | weather = 0 |
| product_price = 1.50 | | product_price = 1.50 |
| | | |
Line 219: |
Line 232: |
| | | |
| else: | | else: |
− | print 'You cant afford that many ' + variables[3] | + | print 'You can not afford that many ' + variables[3] |
| | | |
− | today = min(stored_cups, stored_lemons, stored_sugar)
| + | |
| | | |
| # Option 1: make maximum available | | # Option 1: make maximum available |
Line 230: |
Line 243: |
| | | |
| #default value | | #default value |
− | requested_sales = 5 | + | |
− | sales = max(min(today, requested_sales),0) | + | sales = max(min(stored_cups, stored_lemons, stored_sugar),0) |
| | | |
| # Option 2: make as many as requested | | # Option 2: make as many as requested |
Line 237: |
Line 250: |
| stored_lemons -= sales | | stored_lemons -= sales |
| stored_sugar -= sales | | stored_sugar -= sales |
| + | |
| + | if weather == 0: |
| + | sales -= 10 % sales |
| + | elif weather == -1: |
| + | sales -= 20 % sales |
| + | |
| + | |
| + | |
| print `sales`+ ' ' + variables[4]+ " made for $"+ "%.2f" % expenses | | print `sales`+ ' ' + variables[4]+ " made for $"+ "%.2f" % expenses |
| | | |
| profit = sales * product_price | | profit = sales * product_price |
| print `sales`+ " " + variables[4] +" were sold today for $"+ "%.2f" % profit | | print `sales`+ " " + variables[4] +" were sold today for $"+ "%.2f" % profit |
| + | |
| print "You made $"+ "%.2f" % (profit - expenses)+" today." | | print "You made $"+ "%.2f" % (profit - expenses)+" today." |
− | bank += profit - expenses | + | |
| + | |
| + | if (profit - expenses) <= 0: |
| + | |
| + | print "You lost money today" |
| + | |
| + | else: |
| + | |
| + | print "You go to put profits away" |
| + | |
| + | if play_Money( int(profit - expenses) ) == 1: |
| + | print "you put the money away correctly" |
| + | bank += profit - expenses |
| + | else: |
| + | print "You lost the money when putting it away" |
| + | |
| + | |
| print "Current funds: $"+ "%.2f" % bank | | print "Current funds: $"+ "%.2f" % bank |
| + | |
| + | |
| | | |
| supply_Decay() | | supply_Decay() |
| + | weather_Change() |
| + | |
| | | |
| print | | print |
| | | |
| print "Done!" | | print "Done!" |
| + | |
| + | |
| + | </pre> |
| + | |
| + | Counting code |
| + | |
| + | <pre> |
| + | |
| + | |
| + | dollar = 1 |
| + | quarter = .25 |
| + | dime = .10 |
| + | nickel = .05 |
| + | penny = .01 |
| | | |
| | | |
| | | |
| + | def take_input(text, default = 0): |
| + | try: |
| + | in_text = input(text+" ["+`default`+"]: ") |
| + | except: |
| + | return default |
| + | if in_text < 0: |
| + | in_text = 0 |
| + | |
| + | return in_text |
| + | |
| + | |
| + | def play_Money( money_Find ): |
| + | |
| + | global quarter, dime, nickel, penny |
| + | |
| + | total = 0 |
| + | |
| + | #Takes the amount of money |
| + | total += dollar*take_input( "How many dollars? ") |
| + | |
| + | |
| + | total += quarter*take_input( "How many quarters? ") |
| + | |
| + | total += dime*take_input( "How many dimes? ") |
| + | |
| + | total += nickel*take_input( "How many nickels? ") |
| + | |
| + | total += penny*take_input( "How many pennies? ") |
| + | |
| + | if total == money_Find: |
| + | return 1 |
| + | |
| + | else: |
| + | return -1 |
| + | |
| | | |
| </pre> | | </pre> |