Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- class Developer {
- constructor(firstName, lastName) {
- this.firstName = firstName;
- this.lastName = lastName;
- this.baseSalary = 1000;
- this.tasks = [];
- this.experience = 0;
- }
- addTask(id, taskName, priority) {
- if (priority === 'high') {
- this.tasks.unshift({ id, taskName, priority });
- } else {
- this.tasks.push({ id, taskName, priority });
- }
- return `Task id ${id}, with ${priority} priority, has been added.`
- }
- doTask() {
- if (this.tasks.length === 0) {
- return `${this.firstName}, you have finished all your tasks. You can rest now.`
- } else {
- let task = this.tasks.shift();
- return task.taskName;
- }
- }
- getSalary() {
- return `${this.firstName} ${this.lastName} has a salary of: ${this.baseSalary}`
- }
- reviewTasks() {
- let result = ["Tasks, that need to be completed:"];
- while (this.tasks.length > 0) {
- let r = this.tasks.shift();
- result.push(`${r.id}: ${r.taskName} - ${r.priority}`)
- }
- return result.join('\n')
- }
- }
- class Junior extends Developer {
- constructor(firstName, lastName, bonus, experience) {
- super(firstName, lastName);
- this.baseSalary = 1000 + bonus;
- this.tasks = [];
- this.experience = experience;
- }
- learn(years) {
- this.experience += years;
- }
- }
- class Senior extends Developer {
- constructor(firstName, lastName, bonus, experience) {
- super(firstName, lastName);
- this.baseSalary = 1000 + bonus;
- this.tasks = [];
- this.experience = experience + 5;
- }
- changeTaskPriority(taskId) {
- let find = this.tasks.find((o) => { return o.id === taskId });
- if (find.priority === 'high') {
- find.priority = 'low';
- let i = this.tasks.indexOf(find);
- this.tasks.push(find);
- this.tasks.splice(i, 1);
- return 'low';
- } else {
- find.priority = 'high';
- let i = this.tasks.indexOf(find);
- this.tasks.unshift(find);
- this.tasks.splice(i, 1);
- return 'high';
- }
- }
- }
- return {
- Developer,
- Junior,
- Senior
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement