Loading...
For each class, define the attributes (data) it will hold and the methods (functions) that operate on the attributes. Ensure they align with the object's responsibilities and adhere to the principle of encapsulation.
class Drink:
def __init__(self, name, price):
self.name = name
self.price = price
def price(self):
return self.price
def name(self):
return self.name
class VendingMachineRow:
def init(self, drinkInformation: List[tuple(string,int,drinkQuantity)]):
self.[
Drink(drinkName,drinkPrice)
for drinkName,drinkPrice,drinkQuantity
in drinkInformation
]
class VendingMachine:
def init(self, drinksLayout):
self.quantityCounter = {}
for row in drinksLayout:
for drinkName,drinkPrice,drinkQuantity in row:
self.quantityCounter[drinkName] += drinkQuantity
self.vendingMachine = [
VendingMachineRow(drinksLayout[i])
for i in range(len(drinksLayout))
]
self.paymentsManager = PaymentsManager()
def placeOrder(self, row, col, paidAmount):
drink = self.vendingMachine[row][col]
if self.quantityCounter[drink.Name]:
if self.paymentsManager.processPayment(paidAmount, drink.drinkPrice) >= 0:
self.quantityCounter[drink.Name] -= 1
return drink
class PaymentsManager:
def init(self):
def processPayment(self, paidAmount, cost):
return cost-paidAmount
Explain design tradeoffs you considered. Check and explain whether your design adheres to SOLID principles. Explain how your design can handle changes in scale and whether it would be easy to extend with new functionalities. Identify areas for future improvement...