Skip to content

Instantly share code, notes, and snippets.

@AndrewS097
Created March 10, 2019 07:26
Show Gist options
  • Save AndrewS097/1e936b7ff39e36a7961909560346c400 to your computer and use it in GitHub Desktop.
Save AndrewS097/1e936b7ff39e36a7961909560346c400 to your computer and use it in GitHub Desktop.
Lemonade Stand Game
#Constants
Sunny = 100
Hazy = 90
Overcast = 80
Cloudy = 70
Rain = 60
multWea = .40
multTemp = .30
multPrc = .20
multPop = .10
char1 = 85
char2 = 74
char3 = 65
char4 = 56.7
char5 = 45.6
#Variables
Temp = int
Prc = float
dayPop = int
Pop = int
Cost = float
Sug = int
Lem = int
Ice = int
Cup = int
dayWeather = str
gameTime = int
#Selling Module
import random
print("Welcome to the Lemonade Stand Game")
print("\nInstructions:\n\
In the lemonade stand game, you will join the world as a small business owner.\n\
As you become an entrepreneur, you will buy inventory, create a recipe, and sell\n\
cups of lemonade. Game elements will affect if customers choose to buy your\n\
product. These known elements will be weather, temperature, price, popularity\n\
and recipe. You will be able to continue playing until two conditions are met:\n\
gametime ends or bankruptcy. Good luck on your quest of entrepreneurship.\n\
Oh yeah! Here is your $20 to get you started.\n")
gameTimePlay = int(input("Enter the number of days to play: "))
gameTimeSet = 0
money = 20
countLem = 0
countSug = 0
countIce = 0
countCup = 0
#Setup Gametime and Weather
while gameTimeSet < gameTimePlay:
gameTimeSet += 1
print("\nDay %d: " % gameTimeSet)
dayWeather = random.choice([Sunny, Hazy, Overcast, Cloudy, Rain])
if dayWeather == Sunny:
wea = 'Sunny'
elif dayWeather == Hazy:
wea = 'Hazy'
elif dayWeather == Overcast:
wea = 'Overcast'
elif dayWeather == Cloudy:
wea = 'Cloudy'
else:
if dayWeather == Rain:
wea = 'Rain'
print ("Weather: %s" % wea)
dayTemp = random.randint(50,100)
print ("Temperature: %d" % dayTemp)
#Setup Inventory
inventory = str(input("\nDo you want to buy inventory? 'Yes' or 'No': "))
while inventory == "Yes":
if inventory == "Yes":
print("Enter 'L' for Lemons, 'S' for Sugar, 'I' for Ice, 'C' for Cups")
selection = str(input(" Selection: "))
if selection == "L":
print("\nLemons cost $.10 each")
lemSel = int(input("Quanity: "))
lemCal = lemSel * .10
print("Total Lemon Cost: $%.2f" % lemCal)
if money >= lemCal:
money = money - lemCal
countLem = lemSel + countLem
print(" Money: $%.2f" % money)
else:
print("Not enough funds. ")
elif selection == "S":
print("\nSugar cost $.10 a cup")
sugSel = int(input("Quanity: "))
sugCal = sugSel * .10
print("Total Sugar Cost: $%.2f" % sugCal)
if money >= sugCal:
money = money - sugCal
countSug = sugSel + countSug
print(" Money: $%.2f" % money)
else:
print("Not enough funds. ")
elif selection == "I":
print("\nIce cost $.01 each")
iceSel = int(input("Quanity: "))
iceCal = iceSel * .01
print("Total Ice Cost: $%.2f" % iceCal)
if money >= iceCal:
money = money - iceCal
countIce = iceSel + countIce
print(" Money: $%.2f" % money)
else:
print("Not enough funds. ")
else:
if selection == "C":
print("\nCups cost $.05 a cup")
cupSel = int(input("Quanity: "))
cupCal = cupSel * .05
print("Total Cups Cost: $%.2f" % cupCal)
if money >= cupCal:
money = money - cupCal
countCup = cupSel + countCup
print(" Money: $%.2f" % money)
else:
print("Not enough funds. ")
inventory = str(input("\nDo you want to buy inventory? 'Yes' or 'No': "))
if inventory == "No":
break
print("\nTotal Inventory:\n\
Lemons: %d\n\
Sugar: %d Cups\n\
Ice: %d Cubes\n\
Cups: %d " % (countLem, countSug, countIce, countCup))
print("Money: $%.2f " % money)
#Setup Recipe
print("\nCreate a recipe by adding lemons, sugar, and ice. Max for each item is 10. ")
recipe = str(input("Do you want to setup a lemonade recipe? 'Yes' or 'No': "))
while recipe == "Yes":
if recipe == "Yes":
print("Enter item you want to add: 'L' for Lemons, 'S' for Sugar, 'I' for Ice")
recipeSel = str(input(" Selection: "))
if recipeSel == "L":
print("\nTotal Lemons: %d" % countLem)
lemRec = int(input("Enter Quanity: "))
if lemRec > 10:
print("Quanity must be between 1 and 10. ")
if countLem > lemRec:
lemRemain = countLem - lemRec
print("New Total Lemons: %d" % lemRemain)
else:
if countLem < lemRec:
print("Not enough lemons." )
elif recipeSel == "S":
print("\nTotal Sugar: %d Cups" % countSug)
sugRec = int(input("Enter Quanity: "))
if sugRec > 10:
print("Quanity must be between 1 and 10. ")
if countSug > sugRec:
sugRemain = countSug - sugRec
print("New Total Sugar: %d Cups" % sugRemain)
else:
if countSug < sugRec:
print("Not enough sugar." )
else:
if recipeSel == "I":
print("\nTotal Ice: %d Cubes" % countIce)
iceRec = int(input("Enter Quanity: "))
if iceRec > 10:
print("Quanity must be between 1 and 10. ")
if countIce > iceRec:
iceRemain = countIce - iceRec
print("New Total Ice: %d Cubes" % iceRemain)
else:
if countIce < iceRec:
print("Not enough ice." )
recipe = str(input("Do you want to continue creating a lemonade recipe? 'Yes' or 'No' "))
print("Lemonade Recipe Per Cup: %d lemons, %d cups of sugar, %d ice cubes" % (lemRec, sugRec, iceRec))
print("Remaining Inventory:\n\
Lemons: %d\n\
Sugar: %d Cups\n\
Ice: %d Cubes" % (lemRemain, sugRemain, iceRemain))
#Selling Lemonade
dayPrc = float(input("\nEnter the lemonade selling price: $"))
if dayPrc > .50:
print("Lemonade price can't exceed $.50. ")
dayPrc = float(input("Enter the lemonade selling price: "))
if gameTimeSet == 1:
dayPop = 0
else:
if gameTimeSet >= 2:
dayPop = Pop
print("Popularity: %d" % dayPop)
weaPercent = dayWeather * multWea
tempPercent = dayTemp * multTemp
prcPercent = (1 / dayPrc) * multPrc
popPercent = dayPop * multPop
totalPercent = weaPercent + tempPercent + prcPercent + popPercent
print ("Sell Setting: %.2f" % totalPercent)
if lemRec in (1, 2, 3):
lemRecTotal = 1
if lemRec in (4, 5, 6, 7):
lemRecTotal = 2
if lemRec > 7:
lemRecTotal = 3
if sugRec in (1, 2, 3):
sugRecTotal = 1
if sugRec in (4, 5, 6, 7):
sugRecTotal = 2
if sugRec > 7:
sugRecTotal = 3
if iceRec in (1, 2, 3):
iceRecTotal = 1
if iceRec in (4, 5, 6, 7):
iceRecTotal = 2
if iceRec > 7:
iceRecTotal = 3
finaleTotalPercent = totalPercent + lemRecTotal + sugRecTotal + iceRecTotal
print ("Combined Sell Setting: %.2f" % finaleTotalPercent)
totalCustomers = (dayWeather * 2) + (dayTemp * 2)
print ("Total Number of Potential Customers: %d" % totalCustomers)
custSold = 0
custTime = 0
while custTime < totalCustomers:
if serving <1:
totalLemons -= receipeLemons
totalSugar -= receipeSugar
serving =18
custTime += 1
if finaleTotalPercent > random.choice([char1, char2, char3, char4, char5]):
serving -=1
totalIce -= receipeIce
totalCup -= 1
custSold += 1
print ("Total Number of Lemonade Cups Sold: %d" % custSold)
totalMoneyEarned = custSold * dayPrc
print ("Total Money Earned: $%.2f" % totalMoneyEarned)
Pop = (custSold / totalCustomers) * 100
print ("Next Day Popularity: %d" % Pop)
money = money + totalMoneyEarned
print("\nNew Money $%.2f " % money)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment