Created a coffee machine and added pylint linter!
This commit is contained in:
parent
e601cd3562
commit
2cb3f14710
3 changed files with 81 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
.vscode
|
||||||
31
Day 15/data.py
Normal file
31
Day 15/data.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
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": 300,
|
||||||
|
"milk": 200,
|
||||||
|
"coffee": 100,
|
||||||
|
}
|
||||||
49
Day 15/main.py
Normal file
49
Day 15/main.py
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# imports
|
||||||
|
from data import menu, resources
|
||||||
|
|
||||||
|
# coffee machine logic
|
||||||
|
def coffee_machine():
|
||||||
|
response = ""
|
||||||
|
profit = 0.00
|
||||||
|
water_left = resources['water']
|
||||||
|
milk_left = resources['milk']
|
||||||
|
coffee_left = resources['coffee']
|
||||||
|
while response != "off":
|
||||||
|
money = 0.00
|
||||||
|
response = input("What would you like? (espresso/latte/cappuccino): ")
|
||||||
|
if response == "report":
|
||||||
|
print(f"Water: {water_left}ml")
|
||||||
|
print(f"Milk: {milk_left}ml")
|
||||||
|
print(f"Coffee: {coffee_left}g")
|
||||||
|
print(f"Profit: ${profit}")
|
||||||
|
elif response == "espresso" or response == "latte" or response == "cappuccino":
|
||||||
|
cost = menu[response]['cost']
|
||||||
|
for ingredient in menu[response]['ingredients']:
|
||||||
|
if resources[ingredient] < menu[response]['ingredients'][ingredient]:
|
||||||
|
print(f"Sorry there is not enough {ingredient}.")
|
||||||
|
continue
|
||||||
|
print("Please insert coins.")
|
||||||
|
quarters = float(input("How many quarters?: "))
|
||||||
|
dimes = float(input("How many dimes?: "))
|
||||||
|
nickles = float(input("How many nickles?: "))
|
||||||
|
pennies = float(input("How many pennies?: "))
|
||||||
|
money += 0.25*quarters + 0.10*dimes + 0.05*nickles + 0.01*pennies
|
||||||
|
if money < cost:
|
||||||
|
print("Sorry that's not enough money. Money refunded.")
|
||||||
|
continue
|
||||||
|
profit += cost
|
||||||
|
water_left -= menu[response]['ingredients']['water']
|
||||||
|
coffee_left -= menu[response]['ingredients']['coffee']
|
||||||
|
if 'milk' in menu[response]['ingredients']:
|
||||||
|
milk_left -= menu[response]['ingredients']['milk']
|
||||||
|
money -= cost
|
||||||
|
print(f"Here is ${money} in change.")
|
||||||
|
print(f"Here is your {response} ☕. Enjoy!")
|
||||||
|
elif response == "off":
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print("Please select a valid item.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
# start coffee machine
|
||||||
|
coffee_machine()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue