From 2cb3f1471067c9a11792dd492095bb8b9f635249 Mon Sep 17 00:00:00 2001 From: rzmk Date: Wed, 14 Jul 2021 05:37:29 -0400 Subject: [PATCH] Created a coffee machine and added pylint linter! --- .gitignore | 1 + Day 15/data.py | 31 +++++++++++++++++++++++++++++++ Day 15/main.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 .gitignore create mode 100644 Day 15/data.py create mode 100644 Day 15/main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..600d2d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/Day 15/data.py b/Day 15/data.py new file mode 100644 index 0000000..cc4c9c5 --- /dev/null +++ b/Day 15/data.py @@ -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, +} diff --git a/Day 15/main.py b/Day 15/main.py new file mode 100644 index 0000000..2716a75 --- /dev/null +++ b/Day 15/main.py @@ -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() \ No newline at end of file