I am supposed to use setters and getters for this class instance but getting the following error after I prompt user for input.
Traceback (most recent call last): File "python", in File "python", in init File "python", in Name File "python", in Name File "python", in Name [Previous line repeated 492 more times] RecursionError: maximum recursion depth exceeded
class Pet:
def __init__(self, nameOfPet, typeOfPet, ageOfPet):
self.Name = nameOfPet
self.Types = typeOfPet
self.Age = ageOfPet
@property
def Name(self):
return self.Name
@Name.setter
def Name(self, petName):
self.Name = petName
@property
def Types(self):
return self.Types
@Types.setter
def Types(self, petType):
self.Types = petType
@property
def Age(self):
return self.Age
@Age.setter
def Age(self, petAge):
self.Age = petAge
def printPetInfo(self):
print("Hello. Your pet's name is {}, it is a {} type and it is {} years old. ".format(self.Name,self.Types,self.Age))
#Get input from user.
name = input("Enter the pet's name: ")
types = input("Enter the pet's type (Dog, Cat, Bird, etc.): ")
age = input("Enter the pet's age (in years): ")
while age.isalpha():
print()
print("Age cannot contain numbers. Try again.")
age = input("Enter the pet's age (in years): ")
#Instantiate a new Pet Instance.
myPet = Pet(name,types,age)
myPet.printPetInfo()
print("\n \n \n \n \n \n")