Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: A base class called Pet A mix-in class called

Assignment Statement

Use the skeleton file starter code (below) to create the following classes using inheritance: A base class called Pet A mix-in class called Jumper A Dog class and a Cat class that each inherit from Pet and jumper Two classes that inherit from Dog: BigDog and SmallDog One classes that inherit from Cat: HouseCat

The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but you will have to identify the required inheritance for a class. You will be responsible for writing the functionality of those classes.

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 (see below).

1. The Pet class: a. Assign values to two variables: kind and color b. Implement the constructor to initialize the pets name c. Implement do_tricks method per skeleton (see Skeleton file below) 2. The Jumper class a. Implement the jump method per the skeleton (see Skeleton file below) 3. The Dog class a. Decide which classes to inherit from and implement inheritance b. Change the kind to canine c. Implement __str__ per skeleton (see Skeleton file below) d. Implement __call__ per skeleton (see Skeleton file below) 4. The BigDog class a. Change the color to tan b. Implement __str__ per skeleton (see Skeleton file below) c. Implement speak per skeleton (see Skeleton file below) 5. The SmallDog class a. Change the color to brindle b. Implement __str__ per skeleton (see Skeleton file below) c. Implement speak per skeleton (see Skeleton file below) 6. The Cat class a. Change the kind to feline b. Implement __str__ per skeleton (see Skeleton file below) c. Implement speak per skeleton (see Skeleton file below) d. Implement climb per skeleton (see Skeleton file below)

7. The HouseCat class a. Change the color to white b. Implement __str__ per skeleton (see Skeleton file below) c. Implement speak per skeleton (see Skeleton file below) 8. Run the code according to the following: a. Instantiate each class(except jumper) b. Create a list of the instantiated objects c. Loop through the objects d. For each object: i. Print __str__ ii. print the kind of pet

iii. Print the Color of the pet

iv. Have the pet do tricks v. if applicable, print rollover action and the owners name vi. If applicable, have the pet climb vii. To separate each pet print underscores

Sample Output Your output should look something like this

<__main__.Pet object at 0x101eaa898> animal brown Taz 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 ---------------------------------------- I am a dog named Roo canine brown Roo is doing tricks Roo is jumping Roo is rolling over 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

Hints (what to do in each class)

Pet class:

1. Variable assignment 2. Implement constructor 3. Implement do_tricks a. Print statement b. Call speak method c. Call jump method

Jumper Class: 4. Implement jump

Dog Class 5. Add inheritance 6. Change kind variable 7. Implement __str__ 8. Implement __call__

BigDog Class 9. Add inheritance 10. Change color to tan 11. Implement __str__ 12. Implement speak

SmallDog class 13. Add inheritance 14. Change color to brindle 15. Implement __str__ 16. Implement speak

Cat class 17. Add inheritance 18. Change kind to feline 19. Implement __str__ 20. Implement speak 21. Implement climb

HouseCat class 22. Add inheritance 23. Change color to white 24. Implement __str__ 25. Implement speak

How Use your code 26. Instantiate each class(except jumper) 27. Create a list of the instantiated objects 28. Loop through the objects 29. Print __str__ 30. print the kind of pet 31. Print the Color of the pet 32. Have the pet do tricks 33. if applicable, print rollover action and the owners name 34. If applicable, have the pet climb 35. To separate each pet print underscores

Skeleton File (to start with)

class Pet: #Create two variables kind and color; assign values def __init__(self, name): #In the constructor, initialize the pets name def do_tricks(self): #Print the name of the pet and that it is doing tricks #Call the speak method #Call the jump method def speak(self): pass def jump(self): pass class Jumper: 'This is a mixin class for jump' def jump(self): #Create jump method that prints that a Pet is jumping and the pets name class Dog: #You will need to inherit for this to work #Change kind to canine def __str__(self): #Print the name and description of dog def __call__(self, action): #Rollover action prints the name of the dog and that it is rolling over #Owner action returns the name of the owner class BigDog: #You will need to inherit for this to work # Change the color to tan def __str__(self): #Print the name and description of BigDog def speak(self): # Print dogs name and what it says class SmallDog: #You will need to inherit for this to work # Change the color to brindle def __str__(self): #Print the name and description of SmallDog def speak(self): # Print dogs name and what it says class Cat: #You will need to inherit for this to work #Change the kind to feline def __str__(self): #Print the name and description of cat def speak(self): # Print cats name and what it says def climb(self): #Prints the name of the cat and that it is climbing class HouseCat: #You will need to inherit for this to work #Change the color to white def __str__(self): #Print the name and description of cat def speak(self): # Print cats name and what it says ########################################### #EXERCISE YOUR CODE # 1. Instantiate each class(except jumper) # 2. Create a list of the instantiated objects # 3. Loop through the objects # 4. Print __str__ # 5. print the kind of pet # 6. Print the Color of the pet # 7. Have the pet do tricks # 8. if applicable, print rollover action and the owners name # 9. If applicable, have the pet climb # 10. To separate each pet print underscore 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions