Activity 01
Pair Programming: Shape Hierarchy Build
Pairs start with a Shape parent class including area and perimeter methods. They create Circle and Rectangle children that override these with specific formulas. Finally, they instantiate objects and test polymorphism by calling methods on a list of shapes.
How can we design a class hierarchy that is flexible enough for future requirements?
Facilitation TipDuring Pair Programming: Shape Hierarchy Build, circulate and ask each pair to explain why they chose a particular attribute or method for their child class over the parent.
What to look forPresent students with a scenario, e.g., modeling different types of musical instruments. Ask them to identify a potential superclass and two subclasses, listing one unique attribute or method for each subclass. This checks their ability to conceptualize hierarchies.