class Employee:
raise_amount = 1.02
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first+'.'+last+'@company.com'
def fullname(self):
return f"Full name is {self.first} {self.last}"
def apply_raise(self):
self.pay = int(self.pay * Employee.raise_amount)
class Developer(Employee):
raise_amount = 1.10
dev1 = Developer('Test1','User1',20000)
dev2 = Developer('Test2','User2',25000)
print(dev1.pay)
dev1.apply_raise()
print(dev1.pay)
O/p : 20000 20400
where as the o/p should have been 20000 22000
22000, Because we are overriding the class variable in the subclass
what is that which im doing wrong here
Employee.raise_amounttoself.raise_amountand think about it