-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathemployee salary part one.js
More file actions
37 lines (32 loc) · 1011 Bytes
/
employee salary part one.js
File metadata and controls
37 lines (32 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Employee Salary Management System
class Employee {
constructor(id, name, position, baseSalary) {
this.id = id;
this.name = name;
this.position = position;
this.baseSalary = baseSalary;
this.benefits = [];
}
// Calculate total salary including benefits
calculateTotalSalary() {
const benefitsTotal = this.benefits.reduce((sum, benefit) => sum + benefit.amount, 0);
return this.baseSalary + benefitsTotal;
}
// Add a benefit to the employee
addBenefit(benefit) {
this.benefits.push(benefit);
}
// Generate employee details
getEmployeeDetails() {
return {
id: this.id,
name: this.name,
position: this.position,
baseSalary: this.baseSalary,
totalSalary: this.calculateTotalSalary(),
benefits: this.benefits
};
}
}
class Benefit {
constructor(name, amount) {</antArtifact>