Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add task solution #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
53 changes: 52 additions & 1 deletion classes/Employees.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
class Employees {
#salary;
#isHired;
static #allEmployees = [];

constructor(name, title, salary) {
this.name = name;
this.title = title;
this.#salary = salary;
this.#isHired = true;

Employees.#allEmployees.push(this);
}


static getEmployees() {
return Employees.#allEmployees;
}

static getTotalPayroll() {
let totalSalary = 0;

for (const employee of Employees.#allEmployees) {
const salary = employee.getSalary();
console.log(`Name: ${employee.name}, Salary: ${salary}`);

if (salary === undefined) {
totalSalary += 120000;
} else {
totalSalary += salary;
}
}

return totalSalary;
}

getSalary() {
return this.#salary;
}

setSalary(amount) {
this.#salary = amount;

return this.#salary;
}

getStatus() {
return this.#isHired
}

setStatus(command) {
if (command === 'hire') {
this.#isHired = true;
} else if (command === 'fire') {
this.#isHired = false;
}
}
}

module.exports = {
Expand Down
16 changes: 15 additions & 1 deletion classes/Manager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
class Manager {
const { Employees } = require('./Employees');

class Manager extends Employees {
#employeesManaged;

constructor(name, title, department) {
super(name, title);
this.department = department;
this.#employeesManaged = [];
}

getEmployeesManaged() {
return this.#employeesManaged;
}

setEmployeesManaged(employee) {
return this.#employeesManaged.push(employee);
}

}

Expand Down
16 changes: 15 additions & 1 deletion classes/SalesPerson.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
class SalesPerson {
const { Employees } = require("./Employees");

class SalesPerson extends Employees {
#totalSales;

constructor(name, title, salary, clients) {
super(name, title, salary)
this.clients = clients;
this.#totalSales = 0;
}

getSalesNumber() {
return this.#totalSales;
}

makeSale(amount) {
return this.#totalSales += amount;
}

}

Expand Down
15 changes: 14 additions & 1 deletion classes/SoftwareEngineer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
class SoftwareEngineer {
const { Employees } = require('./Employees');

class SoftwareEngineer extends Employees {
#programmingLanguages;

constructor(name, title, salary, programmingLanguages) {
super(name, title, salary)
this.#programmingLanguages = programmingLanguages;
}

getProgrammingLanguages() {
return this.#programmingLanguages;
}

setProgrammingLanguages(language) {
return this.#programmingLanguages.push(language);
}

}

Expand Down
Loading