Question: In Python Modify the Cat class in inClass5 to a Dog Class and add a breed as an argument for the __init__(self, breed) function. For

In Python

Modify the Cat class in inClass5 to a Dog Class and add a breed as an argument for the __init__(self, breed) function. For the class exercise, we use a function setColor(self, color) to set the color attribute (instead of using the __init__() ) , and getColor(self) to retrieve the object color. Add the __str__(self) method to return the specified object attributes class Dog: # The init method or constructor def __init__(self, breed): # Instance Variable self.breed = breed # self.color = " " # you can set the color attribute here as well. # comment it out for now. In the Dog class, add three functions (def) def setColor(self, color): # this creates a instances variable self.color = color # Retrieves instance variable def getColor(self): return self.color def __str__(self): return (f' breed: {self.breed}, color: {self.color} ') - Create two Dog objects: roger, sue to initialize their breed as pug and lab - Since there is only one argument in the __init__(self, breed), you use the setColor function for the color attribute. Write the rest of the program to generate the following: rodger's color is green sue's color is pink Dog roger: breed: pug, color: green Dog sue: breed: lab, color: pink

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!