test the results
This commit is contained in:
parent
9a496e0d25
commit
4ad8042522
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>();
|
Loading…
Reference in New Issue