Created
October 27, 2021 02:44
-
-
Save dsibinski/5ecdd052adb538e50e3f4917d11fe785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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