I am looking for tips on improving my implementation of an OOP design problem in Python3
Here is the problem (paraphrasing to save space):
There is a call center with three levels of employees - Respondent, Manager and Director. A call that goes to the center propagates as Respondent -> Manager -> Director depending on whether or not
a) The respondent is free and can handle the call
b) The manager is free and can handle the call
The call center needs to have a dispatchCall() method that assigns the call to the first available employee
Here is the code
#! /usr/bin/env python3 from abc import ABCMeta, abstractmethod from random import random class CallCenter(): """ A call center class that will be inherited from by the director Attributes: name: Name of the employee number: Mobile phone number of the employee level: Define level of the employee - respondent, manager or director """ __metaclass__ = ABCMeta def __init__(self, name, number, level): self.name = name self.number = number self.level = level def canEmployeeHandle(self): canHandle = random() if canHandle > 0.5: return True else: return False def isEmployeeBusy(self): busy = True if random() <= 0.5 else False return busy @staticmethod def dispatchCall(): return respondent.answerCall() @abstractmethod def answerCall(self): """Print a string indicating that this employee is currently answering the call or propogate up the chain""" pass class Director(CallCenter): """ A class definition for the director who will be the third in chain to answer the call """ def answerCall(self): print("The director is now on call with you") class Manager(Director): """ A class definition for the manager who will be the second in chain to answer the call """ def answerCall(self): if not self.isEmployeeBusy() and self.canEmployeeHandle(): print("The manager is answering your call") else: super(Manager, self).answerCall() class Respondent(Manager): canHandle = random() #class variable to check if respondent can handle call """ A class definition for the respondent who will be the first in chain to answer the call """ def answerCall(self): if not self.isEmployeeBusy() and self.canEmployeeHandle(): print("The respondent is answering your call") else: super(Respondent, self).answerCall() if __name__ == "__main__": director = Director("Alex", "+17654736791", "director") manager = Manager("Unai", "+331577285782", "manager") respondent = Respondent("Mark", "+16574872817", "respondent") CallCenter.dispatchCall()