I am using a sample from my book for testing a car class. I get this error and I am not sure why. I am only giving one argument that I can tell.
Here is my error code:
Traceback (most recent call last):
File "G:\Python_Stuff\car.py", line 79, in <module>
myCar.getVIN('V81FDX')
TypeError: getVIN() takes exactly 1 argument (2 given)
This is the code:
class Car:
def __init__(self):# VIN, Make, Model, Color, Year, Price):
self._VIN = ' ' #VIN
self._Make = ' ' #Make
self._Model = ' ' #Model
self._Color = ' ' #Color
self.setYear(' ')
self.setPrice(0)
def getOwner(self):
return self._Owner
def setVIN(self, VIN):
self._VIN = VIN
def getVIN(self):
return self._VIN
def setMake(self, Make):
self._Make = Make
def getMake(self):
return self._Make
def setModel(self, Model):
self._Model = Model
def getModel(self):
return self._Model
def setColor(self, Color):
self._Color = Color
def getColor(self):
return self._Color
def setYear(self, Year):
if Year >= 1980:
self._Year = Year
else:
print('invalid input for year, set to default value.')
self._Year = 1980
def getYear(self):
return Year
def setPrice(self, Price):
if Price >= 5000:
self._Price = Price
else:
print("invalid input for price, set to default value.")
self._Price = 5000
def __str__(self):
display = "The car with the VIN '" + str(self._VIN) + "' is a '"
display += str(self._Year) + "' " + str(self._Color) + " " + str(self._Make) + "\n"
display += str(self._Model) + " with the price of '$" + str(self._Price) + "'"
display += "\nOwner: " + str(self._Owner)
return display
#Test class Car code test
if __name__ == '__main__':
myCar = Car()
myCar.getVIN('V81FDX')
print myCar
print
myCar.getMake('Toyota')
print myCar
print
myCar.getModel('Camry')
print myCar
print
myCar.getColor('Grey')
print myCar
print
myCar.setYear('2007')
print myCar
print
myCar.setPrice(18000)
print myCar
print