added more api methods
This commit is contained in:
20
pots.py
20
pots.py
@@ -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))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user