Answer:
class Barber(object):
barber_shop = "Big AI's barber shop"
def __init__(self, customer_name, type_of_service=[], tip=0):
self.cust_name = customer_name
self.tos = type_of_service
self.tip = tip
def service_type(self, *args):
for i in args:
self.tos.append(i)
def total(self):
services = {'trimming':10, 'hair_cut':20, 'shaving':15, 'washing':5, 'dyeing':5}
contain = ''
total = 0
for service in self.tos:
if service in services.keys():
total += services[service]
contain += f'{service}: {services[service]}\\'
print(self.barber_shop,'\\', self.cust_name,'\\', 'Services:',contain.splitlines(),'\\', \
f'total: ${total}', '\\',f'Tip: ${self.tip}')
mycust = Barber('John',['washing'],6 )
mycust.service_type('shaving', 'dyeing')
mycust.total()
Step-by-step explanation:
The Barber class is a blueprint used to create an object instance of customers that visits the barber-shop. It has two methods 'service_type' and 'total' which are just defined functions of the class that appends services to the type of service variable and total that prints the total cost of services on the screen.