Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function () {
- function Employee(name, age) {
- this.name = name;
- this.age = age;
- this.salary = 0;
- this.dividend = 0;
- this.tasks = [];
- this.work = function () {
- let currentTask = this.tasks.shift();
- console.log(`${this.name}${currentTask}`);
- this.tasks.push(currentTask);
- }
- this.collectSalary = function () {
- console.log(`${this.name} received ${this.salary + this.dividend} this month.`);
- };
- }
- function Junior(name, age) {
- Employee.call(this, name, age);
- this.tasks = [' is working on a simple task.'];
- }
- Junior.prototype = Object.create(Employee.prototype);
- // Object.setPrototypeOf(Junior, Employee);
- // Junior.prototype.constructor = Junior;
- function Senior(name, age) {
- Employee.call(this, name, age);
- this.tasks = [' is working on a complicated task.', ' is taking time off work.', ' is supervising junior workers.'];
- }
- Senior.prototype = Object.create(Employee.prototype);
- // Object.setPrototypeOf(Senior, Employee)
- // Senior.prototype.constructor = Senior;
- function Manager(name, age) {
- Employee.call(this, name, age);
- this.tasks = [' scheduled a meeting.', ' is preparing a quarterly report.'];
- }
- Manager.prototype = Object.create(Employee.prototype);
- // Object.setPrototypeOf(Manager, Employee);
- // Manager.prototype.constructor = Manager;
- return { Employee, Junior, Senior, Manager }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement