added more api methods

This commit is contained in:
musicLaptop
2025-11-22 16:27:56 +00:00
parent bf6b09c639
commit baecd1cd7d
3 changed files with 40 additions and 3 deletions

20
pots.py
View File

@@ -22,6 +22,7 @@ class CoffeePot(Pot):
def __init__(self, name):
super(CoffeePot, self).__init__(name)
self.coffeeOrders = []
print("Coffee pot initialised")
def brew(self, headers):
@@ -29,5 +30,24 @@ class CoffeePot(Pot):
new_order = order.Order("NewOrder")
new_order.configure(headers)
print(new_order.json_dump())
self.coffeeOrders.append(new_order)
return "Brewing"
def get(self):
if self.coffeeOrders:
return self.coffeeOrders[0].json_dump()
else:
return {}
def popOrder(self):
if self.coffeeOrders:
requestedOrder = self.coffeeOrders.pop()
return requestedOrder.json_dump()
else:
return {}
def getOrderCount(self):
return str(len(self.coffeeOrders))