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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access