handler: This method retrieves whatever the user has typed into the upper entry, converts it into an integer, calls the method getAge() to determine the equivalent cat age for the specified number of years, and places the cats's age into the lower entry. If the user enters something into the upper entry that cannot be evaluated as an integer or can be evaluated as an integer and is negative (e.g., less than zero), the handler displays a showinfo box with an appropriate message (title="Ooops!", message="The number of years is invalid.") and then clear() upper entry and lower entry instead of duplicating the code. A correct method must also call the getAge() method to obtain the cat's age. --------------------------------------------------------------------------- def getAge(self, years): if years <= 0: return 0 elif years == 1: return 15 else: return 24 + (year - 2) * 4 # Write this method def handler(self): pass def clear(self): self.ent.delete(0, END)
handler: This method retrieves whatever the user has typed into the upper entry, converts it into an integer, calls the method getAge() to determine the equivalent cat age for the specified number of years, and places the cats's age into the lower entry. If the user enters something into the upper entry that cannot be evaluated as an integer or can be evaluated as an integer and is negative (e.g., less than zero), the handler displays a showinfo box with an appropriate message (title="Ooops!", message="The number of years is invalid.") and then clear() upper entry and lower entry instead of duplicating the code. A correct method must also call the getAge() method to obtain the cat's age.
---------------------------------------------------------------------------
def getAge(self, years):
if years <= 0:
return 0
elif years == 1:
return 15
else:
return 24 + (year - 2) * 4
# Write this method
def handler(self):
pass
def clear(self):
self.ent.delete(0, END)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images