88.8k views
4 votes
A friend a just opened his own barber shop and has asked you to develop a program to track the type of service the customer is receiving and the cost for the service and also include any tips the customer may give to the barber. The name of your friend's barber shop is Big Al's and on each customer receipt he wants to display the name of his shop, customer name, the type of service, cost of the service, and the amount of the tip for a total price of the service rendered. Name your variables Declare your variables

User Syberdoor
by
6.3k points

1 Answer

4 votes

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.

User Prabhagaran
by
5.8k points