diff --git a/core-java/src/main/java/com/baeldung/designpatterns/composite/CompositeDemo.java b/core-java/src/main/java/com/baeldung/designpatterns/composite/CompositeDemo.java index 83024b7d21..9537dd0d2b 100644 --- a/core-java/src/main/java/com/baeldung/designpatterns/composite/CompositeDemo.java +++ b/core-java/src/main/java/com/baeldung/designpatterns/composite/CompositeDemo.java @@ -6,6 +6,14 @@ package com.baeldung.designpatterns.composite; public class CompositeDemo { public static void main(String args[]) { - Department salesDepartment = new SalesDepartment(); + Department salesDepartment = new SalesDepartment(1, "Sales department"); + Department financialDepartment = new FinancialDepartment(2, "Financial department"); + + HeadDepartment headDepartment = new HeadDepartment(3, "Head department"); + + headDepartment.addDepartMent(salesDepartment); + headDepartment.addDepartMent(financialDepartment); + + headDepartment.printDepartmentName(); } } diff --git a/core-java/src/main/java/com/baeldung/designpatterns/composite/GeneralDepartment.java b/core-java/src/main/java/com/baeldung/designpatterns/composite/HeadDepartment.java similarity index 86% rename from core-java/src/main/java/com/baeldung/designpatterns/composite/GeneralDepartment.java rename to core-java/src/main/java/com/baeldung/designpatterns/composite/HeadDepartment.java index 15c5bc9494..8854fce5b3 100644 --- a/core-java/src/main/java/com/baeldung/designpatterns/composite/GeneralDepartment.java +++ b/core-java/src/main/java/com/baeldung/designpatterns/composite/HeadDepartment.java @@ -6,14 +6,14 @@ import java.util.List; /** * Created by Gebruiker on 5/1/2018. */ -public class GeneralDepartment implements Department { +public class HeadDepartment implements Department { private Integer id; private String name; private List childDepartments; - public GeneralDepartment(Integer id, String name) { + public HeadDepartment(Integer id, String name) { this.id = id; this.name = name; this.childDepartments = new ArrayList();