class Business:
'''An institution with some employees and an owner.'''
def __init__(self, name, owner=None):
self.owner = owner
self.name = name
self.employees = []
def add_employee(self, employee):
'''Add an employee to the list.'''
self.employees.append(employee)
def remove_employee(self, employee):
'''Remove an employee from the list.'''
self.employees.remove(employee)
class Restaurant(Business):
'''A business with particular types of employees.'''
>>> fastbobs = Restaurant("Fast Bob's")
>>> fastbobs.name
"Fast Bob's"
>>> fastbobs.add_employee('Carol')
>>> fastbobs.employees
['Carol']
class Worker:
'''A person with a job (normally).'''
def __init__(self, name, boss, employer, salary):
self.name = self
self.boss = boss
self.salary = salary
# The employer is an instance of the Business class
self.employer = employer
def quit(self):
'''Lose employer, salary, boss.'''
self.boss = None
self.employer = None
self.salary = 0
class Owner(Worker):
'''A worker who owns a business.'''
def quit(self):
'''Overrides Worker.quit(); the employer no longer has an owner.'''
self.employer.owner = None
self.employer = None
self.salary = 0
class Worker:
...__init__...
def quit(self):
'''Lose employer and salary.'''
self.employer = None
self.salary = 0
class Owner(Worker):
def quit(self):
'''Overrides Worker.quit(); the employer no longer has an owner.'''
self.employer.owner = None
Worker.quit(self)
class Employee(Worker):
def quit(self):
'''Overrides Worker.quit(); the employee no longer has a boss.'''
Worker.quit(self)
self.boss = None
...
>>> fastbobs = Restaurant("Fast Bob's")
>>> bob = Owner('Bob', None, fastbobs, 100000)
>>> fastbobs.owner = bob
>>> carol = Employee('Carol', bob, fastbobs, 10000)
>>> carol.quit()
>>> carol.boss, carol.employer, carol.salary
(None, None, 0)
>>> bob.quit()
>>> fastbobs.owner
add_item method to Menu, finish the constructor for Person, and write the various action methods for Person.
Each of the action methods should print out a message explaining that it is happening if it succeeds.
set_participants and run.