Aug-25-2020, 12:46 PM
(This post was last modified: Aug-25-2020, 12:46 PM by deanhystad.)
Python does not support polymorphism based on the signature. Each time you you use the same name for a method it replaces the previous method declaration.
https://docs.python.org/3.8/library/func...l#property
The total field is 0 because you initialize total to zero and never change it. I would not make total a variable in class because it can be calculated from hours and hourly wage. If you want to have a total in Pay you'll have to compute total each time hours or pay rate is changed.
def total(self): # This method is thrown away because of the method below. return self.__total def total(self, newtotal): # This method replaces the total method defined above self.__total = newtotalI think you want to use properties.
https://docs.python.org/3.8/library/func...l#property
The total field is 0 because you initialize total to zero and never change it. I would not make total a variable in class because it can be calculated from hours and hourly wage. If you want to have a total in Pay you'll have to compute total each time hours or pay rate is changed.