As a property learning object, I created a small currency converter. See:
class converteMoeda():
def __init__(self, dollar=0, real=0):
self.dollar = dollar
self.real = real
def toDollar(self):
dollar = self.real/self.dollar
print("Convertendo Reais para Dólar.")
return(dollar)
def toReais(self):
reais = self.dollar/self.reais
print("Convertendo de Dólar para Reais.")
return(reais)
def setDollar(self,dollar):
print("Gravando valor do dólar.")
self._dollar = dollar
def setReais(self,real):
print("Gravando valor do real.")
self._real = real
def getDollar(self):
print("Recuperando valor do dólar.")
return(_dollar)
def getReais(self):
print("Recuperando valor do Real.")
reutrn(_real)
real = property(getReais,toReais)
dollar = property(getDollar,toDollar)
c = converteMoeda()
c.toReais(3.17)
However, for a reason that I could not identify, it is generating a parameter number error:
Traceback (most recent call last):
File "python", line 35, in <module>
File "python", line 5, in __init__
TypeError: toDollar() takes 1 positional argument but 2 were given
Can anyone help me with this adventure?