Ok, I'm new to OOP, and my problem is that I have this parent class and it has information about the method in it. I want to reuse the two print statements in this method for my subclass inside the method of the same name and add additional information to it. but i cant make it work
class company:
def __init__(self, fName, lName, salary):
self.fName = fName
self.lName = lName
self.salary = salary
def info(self):
print("Name:", self.fName, self.lName)
print("Salary:", self.salary)
class programmers(company):
def __init__(self, fName, lName, salary, progLang):
super().__init__(fName, lName, salary)
self.progLang = progLang
def info(self):
print("Programming language:", self.progLang)
programmer1 = programmers("John", "Doe", 1000, "Python")
programmer1.info()
I thought I was just rewriting the lines of code that I want to reuse, but although that might take the OOP point.
I am looking for such a conclusion ...
Name: John Doe
Salary: 1000
Programming language: Python
I am using Python 3
Thanks in advance!
source
share