pseudosubs-v1/srv/GestorDeTareas/GestorDeTareas.ts
2024-02-29 08:15:31 -05:00

23 lines
446 B
TypeScript

export class GestorDeTareas {
tareas: boolean[] = [];
alCompletar: (() => void);
constructor(alCompletar: (() => void)) {
this.alCompletar = alCompletar;
}
agregarTarea() {
return (this.tareas.push(false) - 1);
}
terminarTarea() {
this.tareas.pop();
this.verificarTareas();
}
verificarTareas() {
if (this.tareas.length === 0)
this.alCompletar();
}
}