Exercise: Composite Design Pattern

Test your understanding of the composite design pattern and add a leap node.

We'll cover the following

Problem statement

Modify the example code in the previous lesson and add the following functionalities:

  • Add a new leap class called a Circle.
  • Make some instances of the Circle and add them to the grafik1 or grafik2 objects.
  • The leaf objects of the Circle class should print Circle.

Coding challenge

Get hands-on with 1200+ tech skills courses.