Define Magic Methods Use Pythons built-In sorting capability

computer science

Description

Define Magic Methods

Use Pythons built-In sorting capability

In this assignment. you will add two magic methods to your class Employee, and write a test program that shows how you can use symbo’s to call these two methods.

Step 1: Make any changes suggested in my comments for Assignment #7. Test thoroughly.

Step 2; Add a definition for a method ,eqjself, other) tu your class Employee. This method should return True when both the first name and the last name in the two objects (self and other) are the same, it returns False otherwise. The names must be compared without regard to case, Le. “case insensitive”.

Step 3: Add a definition for a method _lt_(self, other) to your class Employee. This method must return True when the name in self is alphabetically less than the name ¡n other, and return False otherwise. If the last names are equal. then your method must check the first names to determine which object is less than the other. This must be dictionary ordering. aka “case insensitive”, which does not depend on the capitalization of the names. This is the way that an address book is ordered.

Instruction Files

Related Questions in computer science category