Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the shape class so that you can draw shapes with different colors. You new class should include two new variables: pencolor - for the

Modify the shape class so that you can draw shapes with different colors.

You new class should include two new variables:

pencolor - for the command turtle.pencolor(), and

fill_color for the command turtle.fillcolor().

You need to write 4 corresponding functions in the class:

get_pencolor(),

set_pencolor(c),

get_fillcolor(), and

set_fillcolor(c).

Your code should be tested by producing some sort of image to demonstrate that you can make shapes of different colors that you specify.

After drawing the shapes use your get_pencolor() and get_fillcolor() functions to print out the colors that were used.

Notes

You can copy paste the shape class above below and edit the code as you see fit.

you may want to rename it to something meaningful like class color_shape:

you can have the color_shape class inherit the shape class to not re-write the code, i.e. class color_shape(shape):

if you write the code as a sub-class of shape, you can also modify the rectangle, square, and triangle class to inherit the color_shape class

i.e. change the child-classes to class square(color_shape):

There are other ways to do this, but the notes above would be a convenient way to re-use the code above.

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

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions