Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Modify the shape class so that you can draw shapes with different colors. 1. You new class should include two new variables: * ```pencolor```

Python

Modify the shape class so that you can draw shapes with different colors. 1. You new class should include two new variables: * ```pencolor``` - for the command ```turtle.pencolor()```, and * ```fill_color``` for the command ```turtle.fillcolor()```. 2. You need to write 4 corresponding functions in the class: * get_pencolor(), * set_pencolor(c), * get_fillcolor(), and * set_fillcolor(c). 3. Your code should be tested by producing some sort of image to demonstrate that you can make shapes of different colors that you specify. 4. After drawing the shapes use your get_pencolor() and get_fillcolor() functions to print out the colors that were used. **Notes** 1. 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):``` 2. 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

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

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

=+ How would you advise those problems be resolved?

Answered: 1 week ago