Today we did:
- We reviewed all the topics in Python OOP.
Homework:
- Create a new Python file called animal.py. It will have an Animal class. The Animal class will have three attributes: species, age, type. Make a constructor using these attributes. The species is the name of the animal, such as snake, lizard, dog, cat, etc. The type attribute refers to the class, such as mammal, bird, fish, etc.
- The Animal class will have a method called “describe”. This method prints: “Hi, I’m a <species> that is <age> years old. I belong to the <type> class!”
- Make a new Python file called dog.py. It will have a Dog class that inherits from Animal. Make the constructor, where you put the species as automatically “dog”. It will have its own “describe” method (overriding), where it prints: “Hi, I’m a <species> that is <age> years old. I belong to the <type> class! I make a ‘woof woof’ sound!”.
- Make a main file and class called AnimalSystem. You will have a dictionary to store animals. Have a menu as well, which gives the user these options:
- Add an animal
- List all animals
- Find an animal
- Exit
- Similar to the way we did SchoolSystem, make all 4 selections work properly.
If you have any questions, feel free to email me at joel@ayclogic.com.