// @topic S-0314-12-01-40 Java composite design pattern
// @brief class ShapeComposite extends Shape

package composite;

import java.util.ArrayList;

public class ShapeComposite extends Shape {
    private ArrayList<Shape> shapeList_ = new ArrayList<Shape>();

    @Override
    public void print() {
        System.out.println(" ShapeComposite " + this.hashCode() + " {");
        // for each element in shapeList_, call the print member function
        for( Shape shape : shapeList_) {
            shape.print();
        }
        System.out.println("}");
    }

    public void add(Shape aShape) {
        shapeList_.add(aShape);
    }
}//class ShapeComposite