Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Now that we have a Caterpillar created, we are going to expand out Caterpillar class to include Butterflies! In this problem you will be

python

image text in transcribed

Now that we have a Caterpillar created, we are going to expand out Caterpillar class to include Butterflies! In this problem you will be using inheritance to create a Butterfly class that inherits all of the properties of the Caterpillar class (Caterpillar will be the parent class and Butterfly will be the child) which means that the Butterfly will have the same body, legs, and antennae of the Caterpillar, but will also have wings on top! Butterfly object will contain the following information: 1. 2. Wing color (default - "red") The same information as the Caterpillar object (leg color, body color, body size) (defaults are the same as Caterpillar) Like the Caterpillar class, you are going to need to create a turtle object in the constructor, but it will not be a parameter required to create a Butterfly. Your Butterfly should have all of the features from Caterpillar including the body, antennae, and legs, as well as the new feature of wings! In this problem, you will be creating a new function draw wings0 that will add the wings to the Butterfly! In the Butterfly class, you will also override the display) function inherited from the Caterpillar class. For the new display0 function, you will use the parent functions from Caterpillar to draw the body, antennae, legs, and use the new draw_wings() to draw the wings. Here is a sample Butterfly with all of the defaults (this picture is smaller than what it would look like in the turtle window) traint You must create a class called Butterfly that inherits the parent class Caterpillar * You must create a function named draw wings () that will draw the Butterfly's wings You will override the Caterpillar's display) method to draw the Butterfly o In the overridden display0 you should still call the Parent class (Caterpillar) draw_body0, draw_legs), draw_antennae0 Your solution must correctly implement inheritance * You may only import turtle graphics (import turtle) You must use turtle. speed (0) 1n the display() function or in the Butterfly constructor before you draw the Butterfly Now that we have a Caterpillar created, we are going to expand out Caterpillar class to include Butterflies! In this problem you will be using inheritance to create a Butterfly class that inherits all of the properties of the Caterpillar class (Caterpillar will be the parent class and Butterfly will be the child) which means that the Butterfly will have the same body, legs, and antennae of the Caterpillar, but will also have wings on top! Butterfly object will contain the following information: 1. 2. Wing color (default - "red") The same information as the Caterpillar object (leg color, body color, body size) (defaults are the same as Caterpillar) Like the Caterpillar class, you are going to need to create a turtle object in the constructor, but it will not be a parameter required to create a Butterfly. Your Butterfly should have all of the features from Caterpillar including the body, antennae, and legs, as well as the new feature of wings! In this problem, you will be creating a new function draw wings0 that will add the wings to the Butterfly! In the Butterfly class, you will also override the display) function inherited from the Caterpillar class. For the new display0 function, you will use the parent functions from Caterpillar to draw the body, antennae, legs, and use the new draw_wings() to draw the wings. Here is a sample Butterfly with all of the defaults (this picture is smaller than what it would look like in the turtle window) traint You must create a class called Butterfly that inherits the parent class Caterpillar * You must create a function named draw wings () that will draw the Butterfly's wings You will override the Caterpillar's display) method to draw the Butterfly o In the overridden display0 you should still call the Parent class (Caterpillar) draw_body0, draw_legs), draw_antennae0 Your solution must correctly implement inheritance * You may only import turtle graphics (import turtle) You must use turtle. speed (0) 1n the display() function or in the Butterfly constructor before you draw the Butterfly

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

Step: 3

blur-text-image

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

Sql++ For Sql Users A Tutorial

Authors: Don Chamberlin

1st Edition

0692184503, 978-0692184509

More Books

Students also viewed these Databases questions

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago