Question: USE PYHTON CODING ####################### ## ## Definition for the class Pet ## ######################## class Pet: owner= name= alive=False def __init__(self,new_name): self.name=new_name self.alive=True Using the code

USE PYHTON CODING

#######################

##

## Definition for the class Pet

##

########################

class Pet:

owner=""

name=""

alive=False

def __init__(self,new_name):

self.name=new_name

self.alive=True

Using the code shown above as a base write a code to do the following:

- Add to the Pet class a method setName(...) which assigns a name to the pet

- Add to the Pet class a method setOwner(...) which takes the owners name as a parameter and applies it to the pet

- Add to the Pet class a method called speak() and a variable called sound which is an empty string by default

- Create and demonstrate sub-classes of the Pet called Dog and Cat

- Override the function speak() so that Dog.speak() returns Woof and Cat.speak() returns Meow

- Override the __str__ function to display the Pets name and owner.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!