"use strict"; class OrganizationCompany { Operation() { /* abstract */ } Add(Component) { /* abstract */ } Remove(Component) { /* abstract */ } } class Departments extends OrganizationCompany { constructor(department) { super(); this.department = department; this.children = []; } Operation(department) { for (let i in this.children) { this.children[i].Operation( `${department ? `${department}>` : ""} ${this.department}` ); } } Add(component) { this.children.push(component); } Remove(component) { for (let i in this.children) { if (this.children[i] === component) { this.children.splice(i, i); } } } } class Employee extends OrganizationCompany { constructor(name) { super(); this.name = name; } Operation(department) { console.log(`Mi nombre es: ${this.name} y pertenezco a ${department}`); } } //Nodo Principal let laEmpresa = new Departments("La Empresa S.A.S"); // Áreas de la empresa let presidencia = new Departments("Presidencia"); presidencia.Add(new Employee("Antonio")); presidencia.Add(new Employee("Maria Carmen")); laEmpresa.Add(presidencia); let administracion = new Departments("Administración"); let contabilidad = new Departments("Contabilidad"); contabilidad.Add(new Employee("Jose")); administracion.Add(contabilidad); let secretaria = new Departments("Secretaria"); secretaria.Add(new Employee("Carmen")); administracion.Add(secretaria); laEmpresa.Add(administracion); let ventas = new Departments("Ventas"); ventas.Add(new Employee("Jose Antonio")); ventas.Add(new Employee("Laura")); laEmpresa.Add(ventas); laEmpresa.Operation(); /* Mi nombre es: Antonio y pertenezco a La Empresa S.A.S> Presidencia Mi nombre es: Maria Carmen y pertenezco a La Empresa S.A.S> Presidencia Mi nombre es: Jose y pertenezco a La Empresa S.A.S> Administración> Contabilidad Mi nombre es: Carmen y pertenezco a La Empresa S.A.S> Administración> Secretaria Mi nombre es: Jose Antonio y pertenezco a La Empresa S.A.S> Ventas Mi nombre es: Laura y pertenezco a La Empresa S.A.S> Ventas */