example code for Composite design pattern