Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created October 27, 2021 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsibinski/5ecdd052adb538e50e3f4917d11fe785 to your computer and use it in GitHub Desktop.
Save dsibinski/5ecdd052adb538e50e3f4917d11fe785 to your computer and use it in GitHub Desktop.
class Person {
name: string;
constructor(name: string) {
this.name = name;
}
}
class Employee extends Person {
salary: number;
constructor(name: string, salary: number) {
super(name);
this.salary = salary;
}
getYearlySalary() {
return 12 * this.salary;
}
}
class Manager extends Person {
employees: Employee[];
constructor(name: string, employees: Employee[]) {
super(name);
this.employees = employees;
}
getYearlySalariesOfAllEmployees() {
let salary = 0;
this.employees.forEach(employee => {
salary += employee.getYearlySalary();
});
return salary;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment