Here is my code. Which is an exmaple of multiple inheritances in pyton. But it shows an error. I want to create a program where single inheritance and multiple inheritance will be used. To do this, create a base class Employee. And from Employee create two classes Programmer and Manager. Now using multiple inheritance create a class DevManager which inheritate from Programmer and Manager. But when I wnat to create an object of DevManager class with proper parameter it will show an error. Below is my code, I can't find where is the error.
class Employee:
def __init__(self, id, ename):
self.id = id
self.ename = ename
def showInfo(self):
print("ID=", self.id, "Name of employee=", self.ename)
class Programmer(Employee):
def __init__(self, id, ename, language):
super().__init__(id, ename)
self.language = language
def showInfo(self):
super().showInfo()
print("Development Language=", self.language)
class Manager(Employee):
def __init__(self, id, ename, department):
super().__init__(id, ename)
self.department = department
def showInfo(self):
super().showInfo()
print("Department=", self.department)
# Define Development Manager class using Multiple inheritances
class DevManager(Programmer, Manager):
def __init__(self, id, ename, language, department):
Programmer.__init__(self, id, ename, language)
Manager.__init__(self, id, ename, department)
def showInfo(self):
super().showInfo()
# Main
obj = DevManager("A101", "Rajib Menon", "Python", "Engineering")
obj.showInfo()
In this program it will not create an object of Programmer class. Following error shows to me.
Traceback (most recent call last):
File "C:\Users\Home\.spyder-py3\multiple.py", line 41, in <module>
obj = DevManager("A101", "Rajib Menon", "Python", "Engineering")
File "C:\Users\Home\.spyder-py3\multiple.py", line 33, in __init__
Programmer.__init__(self, id, ename, language)
File "C:\Users\Home\.spyder-py3\multiple.py", line 13, in __init__
super().__init__(id, ename)
TypeError: __init__() missing 1 required positional argument: 'department'