OOP Studio Ages 9-15
Polymorphism Builder
Build three versions of speak(), then send one shared command through the whole robo-pet team.
1. Override
Give each child class its own speak() result.
2. Build the team
Put all three objects in one pets array.
3. Run one loop
The same command activates the correct behavior automatically.
Match each child class to its behavior.
RoboCatspeak() →
RoboDogspeak() →
RoboRabbitspeak() →
One loop visits every object.
pets[0]
PixelRoboCatwaiting
PixelRoboCatwaitingpets[1]
BoltRoboDogwaiting
BoltRoboDogwaitingpets[2]
ZippyRoboRabbitwaiting
ZippyRoboRabbitwaitingTeam not programmed yet
Build all three versions of speak().
Polymorphism builder complete!
Three child classes answered the same pet.speak() call with three behaviors.