# You need to create the 8 classes complete with their
# attributes and methods.
class Customer:
def __init__(self, name, loyalDiscount):
self.name = name
self.is_loyal = bool(loyalDiscount)
class Order:
def __init__(self,customer,itemsOrdered,cost):
self.customer = customer
self.itemsOrdered = itemsOrdered
self.itemsOrdered = []
self.cost = cost
def addToOrder(self,goods):
self.order.append(goods)
class Item:
def __init__(self,name,price):
self.name = name
self.price = price
class Drink(Item):
def __init__(self,name,price,size):
super().__init__(name,price)
self.size = size
class Tea(Drink):
def __init__(self,name,price,flavour):
super().__init__(name,price)
self.flavour = flavour
def displayDetails(self):
print(self.name,self.price,self.flavour)
class MineralWater(Drink):
def __init__(self,name,price,isCarbonated):
super().__init__(name,price)
self.isCarbonated = bool(isCarbonated)
def displayDetails(self):
print(self.name,self.price,self.isCarbonated)
class Cake(Item):
def __init__(self,name,price,sliceSize,type,hasNuts):
super().__init__(name,price)
self.sliceSize = sliceSize
self.type = type
self.hasNuts = bool(hasNuts)
def displayDetails(self):
print(self.name,self.price,self.sliceSize,self.type,self.hasNuts)
class Sandwich(Item):
def __init__(self,name,price,breadType,Filling):
super().__init__(name,price)
self.breadType = breadType
self.Filling = Filling
def displayDetails(self):
print(self.name,self.price,self.breadType,self.Filling)
def main():
# Create two customers ...
cust1 = Customer('Harry Palmer', False)
cust2 = Customer('Bill Preston', True) # A loyal regular customer
# Order some items ...
order1 = Order(cust1)
order1.addToOrder(Tea('Black tea', 2.00, 'large','Earl Gray'))
order1.addToOrder(Sandwich('Club special',4.50,'brown','chicken'))
order2 = Order(cust2)
order2.addToOrder(MineralWater('Evian',1.50,'small',False))
order2.addToOrder(Sandwich('Simple sandwich',1.50,'white','cheese'))
order2.addToOrder(Cake('Chocolate dream',2.30,'medium','chocolate',True))
# Summarise our orders ...
order1.summariseOrder()
print()
order2.summariseOrder()
print()
if __name__ == "__main__":
main()