day 15

MENU = {

"espresso": {

"ingredients": {

"water": 50,

"coffee": 18,

},

"cost": 1.5,

},

"latte": {

"ingredients": {

"water": 200,

"milk": 150,

"coffee": 24,

},

"cost": 2.5,

},

"cappuccino": {

"ingredients": {

"water": 250,

"milk": 100,

"coffee": 24,

},

"cost": 3.0,

}

}


resources = {

"water": 400,

"milk": 200,

"coffee": 100,

"Money": 0,

}


#TODO: 1. Print report of all coffee machine resource


def errorinput():

print('Wrong input')


def report():

for i, j in resources.items():

print(i + ':' + str(j))


def ask_money():

print('Please insert coins')

quarters = int(input('How many quarters? '))

dimes = int(input('How many dimes? :'))

nickels = int(input('How many nickles? :'))

pennies = int(input('How many pennies? :'))

return (pennies + dimes * 10 + nickels * 5 + quarters * 25) / 100


def makecoffee(menu: dict, coffee: str):

mu = menu[coffee]

ingredients = mu['ingredients']

cost = mu['cost']

return ingredients, cost


def checkingredients(resources: dict, ingredients:dict):

for i in ingredients:

if ingredients[i] > resources[i]:

print('Sorry, there is not enough {}.'.format(i))

return

else:

resources[i] -= ingredients[i]


return ask_money()


def checkmoney(name, cost, numb, addmoney: dict):

if float(cost) < numb:

change = numb - float(cost)

print('Here is ${} in change.'.format(round(change, 2)))

print('Here is your {}, enjoy it.'.format(name))

addmoney['Money'] += cost





flag = True


while flag:

command = input('What would you like? (espresso/latte/cappuccino) \n>> ')


if command.lower() in MENU:

ingredients, cost = makecoffee(MENU, command)

name = command

checkmoney(name, cost, checkingredients(resources, ingredients), resources)


elif command.lower() == 'report':

report()

elif command.lower() == 'off':

flag = False

else:

errorinput()