test the results

This commit is contained in:
mherbaghinyan 2018-05-05 10:26:51 +04:00
parent 9a496e0d25
commit 4ad8042522
2 changed files with 11 additions and 3 deletions

View File

@ -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();
}
}

View File

@ -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<Department> childDepartments;
public GeneralDepartment(Integer id, String name) {
public HeadDepartment(Integer id, String name) {
this.id = id;
this.name = name;
this.childDepartments = new ArrayList<Department>();