In this assignment, you will be demonstrating your understanding and use of python classes and inheritance and polymorphism, as covered in module 6.
This assignment makes use of inheritance to create a set of related classes. At the end, you will have a more complex structure of parent-child classes than you saw in the modules examples.
- You will create the following classes using inheritance:
o A base class called Pet o A mix-in class called Jumper o A Dog class and a Cat class that each inherit from Pet and Jumper o Two classes that inherit from Dog: BigDog and SmallDog o One classes that inherit from Cat: HouseCat
- The general skeleton of the Pet, Dog, and BigDog classes will be given to you, but you will have to identify the required inheritance for a class. You will be responsible for writing the functionality of those classes and their methods.
- A description of each classs functionality, as well as the data to use, is in the requirements below.
- You will be required to write the code to exercise your classes per the requirements.
Requirements
Use the provided template to complete the following. The details are in the skeleton file.
- The Pet class:
- Assign values to two variables: kind and color
- Implement the constructor to initialize the pets name
- Implement __str__ method per skeleton
- Implement do_tricks method per skeleton
- The Jumper class
- Implement the jump method per the skeleton
- The Dog class
- Decide which classes to inherit from and implement inheritance
- Change the kind to canine
- Implement __str__ per skeleton
- Implement __call__ per skeleton
- The BigDog class
- Change the color to tan
- Implement __str__ per skeleton
- Implement speak per skeleton
- The SmallDog class
- Change the color to brindle
- Implement __str__ per skeleton
- Implement speak per skeleton
- The Cat class
- Change the kind to feline
- Implement __str__ per skeleton
- Implement speak per skeleton
- Implement climb per skeleton
- The HouseCat class
- Change the color to white
- Implement __str__ per skeleton
- Implement speak per skeleton
- Create the code to exercise the class structure according to the following:
- Instantiate each class(except Jumper)
- Create a list of the instantiated objects
- Loop through the objects
- For each object:
- Print __str__
- print the kind of pet
- Print the Color of the pet
- Have the pet do tricks
- if applicable, print rollover action and the owners name
- If applicable, have the pet climb vii. To separate each pet, print a line of underscores or dashes
Sample Output
Your output should look something like this and should be in this order:
I am a brown animal named Rover animal brown
Rover is doing tricks
– I am a cat named Lion
feline
brown
Lion is doing tricks Lion says Meow!!!
Lion is jumping
Lion is climbing the curtains again note climbing action is for Cats
–
I am a dog named Roo
canine brown
Roo is doing tricks
Roo is jumping
Roo is rolling over note rollover and owner actions are for Dogs
My owner is George
– Noah is a large, muscular dog canine tan
Noah is doing tricks Noah says Woof!!! Noah is jumping
Noah is rolling over
My owner is George
– Lucky is a tiny, cute dog canine brindle
Lucky is doing tricks Lucky says Yip!
Lucky is jumping
Lucky is rolling over
My owner is George
– Zebra is a cat with fluffy, white fur feline white
Zebra is doing tricks
Zebra says Purr
Zebra is jumping
Zebra is climbing the curtains again
–
Process finished with exit code 0
What to Deliver
You are required to supply a single file emailID_hw6.py (example: marc10is_hw6.py)
Notes
- Start by identifying and ordering the objectives.
- Look at the skeleton there is a lot of guidance in it. The amount you need to code is smaller than in our other assignments. We want to make sure that you see how the different classes work together to show inheritance and polymorphism. This would be way too big an assignment without the skeleton.
- The exercising your pet portion of this tests all the methods and classes created in this assignment. Your output should match the order of the sample output provided. You can get creative for instance, instead of My owner is George, feel free to say something along the lines of My owner, George, is the BEST owner in the whole world But it should all still print in the order below.
- A 25-point deduction for one day late. After 1 day late, a 0 will be given.
Reviews
There are no reviews yet.