-
Notifications
You must be signed in to change notification settings - Fork 0
/
coffee_maker.py
27 lines (23 loc) · 915 Bytes
/
coffee_maker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class CoffeeMaker:
def __init__(self):
self.resources = {
'water': 1000,
'milk': 700,
'coffee': 500,
}
def report(self):
print(f"Water: {self.resources['water']}ml")
print(f"Milk: {self.resources['milk']}ml")
print(f"Coffee: {self.resources['coffee']}g")
def resource_sufficient(self, drink):
"""Check if there are sufficient ingredients to make the drink"""
for item in drink.ingredients:
if drink.ingredients[item] > self.resources[item]:
print(f"Sorry there is not enough {item}.")
return False
return True
def make_drink(self, order):
"""Deducts used resources from available resources"""
for item in order.ingredients:
self.resources[item] -= order.ingredients[item]
print(f"Here is your {order.name}. Enjoy")