-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEngineer.js
70 lines (66 loc) · 1.85 KB
/
Engineer.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const Employee = require('./Employee');
const EnumEmployeeType = require('../enum/EnumEmployeeType');
/**
* Engineer class is a class for all engineer employees. It extends the Employee class.
* @class Engineer
* @typedef {Engineer}
* @extends {Employee}
* @property {string} github The GitHub username of the engineer
* @property {EnumEmployeeType.ENGINEER} role The role of the engineer
* @method getGithub Get the GitHub username of the engineer
* @method getRole Get the role of the engineer
* @instance Engineer
* @example
* const engineer = new Engineer('John Doe', 1, 'john.doe@mail.com', 'johndoe');
* engineer.getGithub(); // johndoe
* engineer.getRole(); // 'Engineer'
*/
class Engineer extends Employee {
/**
* Creates an instance of Engineer.
* @constructor Engineer
* @param {string} name
* @param {number} id
* @param {string} email
* @param {string} github
*/
constructor(name, id, email, github) {
super(name, id, email);
this.github = github;
this.role = EnumEmployeeType.ENGINEER;
}
/**
* Get the GitHub username of the engineer
* @returns {string}
* @memberof Engineer
* @method getGithub
* @instance Engineer
* @example
* const engineer = new Engineer('John Doe', 1, 'test@test.com', 'johndoe');
* engineer.getGithub(); // johndoe
*/
getGithub() {
return this.github;
}
/**
* Get the role of the engineer.
* @returns {EnumEmployeeType.ENGINEER}
* @throws {Error} If the employee type is invalid
* @override Employee.getRole
* @memberof Engineer
* @method getRole
* @instance Engineer
*/
getRole() {
try {
if (this.role !== EnumEmployeeType.ENGINEER) {
throw new Error('Invalid employee type');
} else {
return this.role;
}
} catch (error) {
console.error(error);
}
}
}
module.exports = Engineer;