from multipledispatch import dispatch
class Vehicle:
def __init__(self, ownerID, category, power, make, model, year):
self.ownerID = self.personID
self.category = category
# Ask if we need to enforce "N", "G", "D", "H", "E", "O"
self.power = power
self.make = make
self.model = model
self.year = int(year)
class Car(Vehicle):
def __init__ (self, make, model, year, vin, stateReg, plate, odometer, carType, axles):
#if self.make != None and self.model != None and self.year != None:
self.vin = vin
#Do we have to enforce 2 characters in statereg? use if statement here to enforce them
self.stateReg = str(stateReg)
self.plate = plate
self.odometer = odometer
self.cartype = carType
self.axles = axles
class Person:
@dispatch(int, str, str)
def __init__(self,personID, lastName, firstName):
self.personID = personID
self.lastName = str(lastName)
self.firstName = str(firstName)
@dispatch(int,str,str,str,str,int,int)
def __init__(self, personID, lastName, firstName, address, city, state, zipcode, telephone):
self.personID = personID
self.lastName = lastName
self.firstName = firstName
self.address = address
self.city = city
self.state = state
self.zipcode = zipcode
self.telephone = telephone
def main():
personid1 = Person(1, "Dwarf", "Grumpy", "1 East North Drive", 'Utopia', 'NY', 99991-1492, None)
personid2 = Person(2, "White", "Snow", "14 Empty Tree Lane", 'Enchanted Forest', 'NY', 99992-1498, None)
personid3 = Person(3, "Witch", "Wicked", "Unknown", None, None,None, 555-555-1234)
personid4 = Person(4, "Charming", "Prince", "1 Majestic Palace", 'NY', 'NY', 99997, None)
p1 = (1, "ln", "fn", "sd","sd",21, 13)
car1 = Car('Chevy', 'Chevelle', 1971, None,'NY','#POIZNAPPL', 0, 'COU', 2)
car1.ownerID = 1
car2 = Car(1967, "Ford Shelby" , 'NY' ,'#EVELYN', "Prince Charming",47,281, 'COU', 2)
car3 = Car(2021 , )
car4 = Car(1971, "Chevy Chevelle" , 'NY' ,'#POIZNAPPL', 0000 , 'COU', 2)
listpc =(p1, car1, car2, car3, car4)
print(listpc)
if __name__ == '__main__':
main()
I get an error saying that the second constructor in class Person is not used. The error is:
NotImplementedError
: Could not find signature for__init__
:<int, str, str, str, str, str, int, NoneType>
Also in the second list of objects for class car it says missing arguments.