Last active
October 25, 2022 22:39
-
-
Save axel-andrade/a48fe5683f48aaa2a604bd7721155b0c 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
interface ConventionalEmployee { | |
getName(): string; | |
getSalary(): number; | |
} | |
interface CommissionableEmployee extends ConventionalEmployee { | |
getCommission(): number; | |
} | |
class SecurityEmployee implements ConventionalEmployee { | |
private name: string; | |
private salary: number; | |
constructor(name: string, salary: number) { | |
this.name = name; | |
this.salary = salary; | |
} | |
public getName(): string { | |
return this.name; | |
} | |
public getSalary() { | |
return this.salary; | |
} | |
} | |
class WaiterEmployee implements CommissionableEmployee { | |
private name: string; | |
private salary: number; | |
private salesAmount: number; | |
constructor(name: string, salary: number, salesAmount: number) { | |
this.name = name; | |
this.salary = salary; | |
this.salesAmount = salesAmount; | |
} | |
public getName(): string { | |
return this.name; | |
} | |
public getSalary(): number { | |
return this.salary + this.getCommission(); | |
} | |
public getCommission(): number { | |
return this.salesAmount * 0.2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment