Skip to content

Instantly share code, notes, and snippets.

@axel-andrade
Last active October 25, 2022 22:39
Show Gist options
  • Save axel-andrade/a48fe5683f48aaa2a604bd7721155b0c to your computer and use it in GitHub Desktop.
Save axel-andrade/a48fe5683f48aaa2a604bd7721155b0c to your computer and use it in GitHub Desktop.
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