From the given code, it seems that you are missing the implementations for the doesAnimalExist, GetSpecies, and removeSpecies methods in your AnimalShelter class. I’ll provide you with the missing implementations for these methods.
-
doesAnimalExistmethod:
pythonCopy code
def doesAnimalExist(self, animal):
if animal is None or animal.species is None:
return False
species = animal.species.upper()
if species in self.AnimalDictionary:
return animal in self.AnimalDictionary[species]
return False
-
GetSpeciesmethod:
pythonCopy code
def GetSpecies(self, species):
if species is None:
return None
species = species.upper()
if species in self.AnimalDictionary:
return '\n'.join([animal.toString() for animal in self.AnimalDictionary[species]])
return None
-
removeSpeciesmethod:
pythonCopy code
def removeSpecies(self, species):
if species is None:
return False
species = species.upper()
if species in self.AnimalDictionary:
del self.AnimalDictionary[species]
return True
return False
Add these methods to your AnimalShelter class and then rerun your tests.