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 makes it easy to add new objects 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.9 shows that the Shape class also inherits from the ...
Get Python Programming in Context, 4th 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.