We continue our discussion on subclassing, i.e., extending an existing class in order to get a new class that has behaviors modified from those of the existing class.
We continue with the class Shape
and its subclasses that we started last lecture. This time, we will consider the design choices regarding the (overridden) draw
methods, class attributes, and methods to support different kinds of comparison between objects.
There is no new reading assigned, but be sure to review the slides and your notes from last lecture and perhaps review Section 18.7 Inheritance from the textbook.
Slides: individual slides for viewing, 6-up layout for printing
Above slides were updated after lecture to correct Slide 12: the tabs on the bottom two class folders were incorrectly labelled. The class Shape
folder's tab should read Shape or Shape(object). The class Circle
folder's tab should read Circle(Shape).
Examples:
__eq__
Answers to questions on slides 13, 15, 19, and 23: Try to answer the questions yourself first (see slides above); then check the answers here.