Hi!
I am trying to study Object Oriented Design questions. I'm developing them in Python and I have a question about the implementation.
I am currently developing a solution for the problem "Design a Call Center":
"Imagine you have a call center with three levels of employees: respondent, manager, and director. An incoming telephone call must be first allocated to a respondent who is free. If the respondent can't handle the call, he or she must escalate the call to a manager. If the manager is not free or not able to handle it, then the call should be escalated to a director. Design the classes and data structures for this problem. Implement a method dispatchCall() which assigns a call to the first available employee".
To provide some context, I've designed different classes for this problem:
class Rank(Enum):
Respondent = 0
Manager = 1
Director = 2
class Call:
def assign_handler(self, employee):
pass
def disconnect(self):
pass
class Employee(metaclass=ABCMeta):
def assign_call(self, call: Call):
pass
def is_available(self):
pass
def finish_call(self):
pass
""" Different employees """
class Respondent(Employee):
self.rank = Rank.Respondent
class Manager(Employee):
self.rank = Rank.Manager
class Director(Employee):
self.rank = Rank.Director
""" The body of the program """
class CallHandler:
self.employee_list = [...]
self.call_queues = [...]
def dispatch_call(self, call: Call):
passIf I want to implement the code so that the employee is able to escalate a call and reassign it to another employee, what would be the best way to do it?
class Employee(metaclass=ABCMeta):
def __init__(self, call_handler):
self.call_handler = call_handler
def escalate_call(self):
self.call_handler.reassign_call(self.current_call, new_rank)Is there a better solution? How would you implement it?