composition/source/logic/bookkeeper.ts
2025-03-03 06:15:30 +00:00

50 lines
525 B
TypeScript

class Bookkeeper implements Employee {
private identity: Identity;
private occupation: Occupation;
public constructor(name: string) {
this.identity = new Identity("bookkeeper", name);
this.occupation = new Calculating();
}
public introduce(): void {
this.identity.introduce();
}
public work(): void {
this.occupation.work();
}
}
function makeBookkeeper(name: string): Employee {
return compose(
new Identity("smartly composed bookkeeper", name),
new Calculating()
);
}