12.8 Implementing Polygons
We have neglected a large part of our initial inheritance hierarchy in favor of focusing on a few key implementation details. Now that we have made it possible to properly modify the color, line width, and visibility of Points
and Lines
, we can turn our attention to adding new graphical objects. You will see that inheritance will make it easy to add new objects that are quite powerful without writing a lot of code.
Let’s begin by working down the inheritance hierarchy, starting with Shape
. Shape
is an abstract class that will hold an instance variable that will let us know whether an instance of Shape
should appear as an outline or whether the shape should be filled in with a color. LISTING 12.10 shows that the ...
Get Python Programming in Context, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.