Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Day-2/Employee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ var Employee = (function () {
this.id = id;
this.name = name;
this.salary = salary;
this.rating = 0;
this.bonus = 0;
}
Employee.prototype.printInfo = function () {
console.log(this.name + " gets " + this.salary);
console.log(this.name + " gets " + this.salary + " and bonus " + this.bonus + " with rating " + this.rating);
};
Employee.prototype.updateSalary = function (newSalary) {
this.salary = newSalary;
Expand Down
7 changes: 5 additions & 2 deletions Day-2/Employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ export class Employee {
id: number;
name: string;
salary: number;
rating: number;
bonus: number;
constructor(id: number, name: string, salary: number) {
this.id = id;
this.name = name;
this.salary = salary;
this.rating = 0;
this.bonus = 0;
}
printInfo() {
console.log(`${this.name} gets ${this.salary}`);
console.log(`${this.name} gets ${this.salary} and bonus ${this.bonus} with rating ${this.rating}`);
}
updateSalary(newSalary: number) {
this.salary = newSalary;
Expand All @@ -17,4 +21,3 @@ export class Employee {
return this.salary;
}
}

2 changes: 2 additions & 0 deletions Day-2/salary-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ org.printEmployeesInfo();
var salaryUpgrader = new salary_upgrader_1.SalaryUpgrader();
salaryUpgrader.incrementSalary(10, org.getEmployeeList());
org.printEmployeesInfo();
salaryUpgrader.addBonus(org.getEmployeeList());
org.printEmployeesInfo();
4 changes: 3 additions & 1 deletion Day-2/salary-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ org.printEmployeesInfo();
let salaryUpgrader: SalaryUpgrader = new SalaryUpgrader();
salaryUpgrader.incrementSalary(10, org.getEmployeeList());
org.printEmployeesInfo();

salaryUpgrader.addBonus(org.getEmployeeList());
org.printEmployeesInfo();

11 changes: 10 additions & 1 deletion Day-2/salary-upgrader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ var SalaryUpgrader = (function () {
emp.updateSalary(newSalary);
});
};
SalaryUpgrader.prototype.addBonus = function () {
SalaryUpgrader.prototype.rateEmployee = function (empList) {
empList.map(function (emp, i) {
emp.rating = (i + 1) / 2;
});
};
SalaryUpgrader.prototype.addBonus = function (empList) {
this.rateEmployee(empList);
empList.map(function (emp, i) {
emp.rating >= 3 ? emp.bonus = (i / 2) * 1000 : emp.bonus = 0;
});
};
return SalaryUpgrader;
}());
Expand Down
12 changes: 10 additions & 2 deletions Day-2/salary-upgrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ export class SalaryUpgrader {
emp.updateSalary(newSalary);
})
}
addBonus() {

rateEmployee(empList){
empList.map((emp,i) => {
emp.rating = (i+1)/2;
})
}
addBonus(empList: Employee[]) {
this.rateEmployee(empList);
empList.map((emp,i) => {
emp.rating >= 3 ? emp.bonus = (i/2) * 1000 : emp.bonus = 0;
})
}
}