-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntern.js
73 lines (69 loc) · 1.89 KB
/
Intern.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
71
72
73
const Employee = require('./Employee');
const EnumEmployeeType = require('../enum/EnumEmployeeType');
/**
* Intern class is a class for all intern employees. It extends the Employee class.
* @class Intern
* @typedef {Intern}
* @extends {Employee}
* @property {string} school The school of the intern
* @property {EnumEmployeeType.INTERN} role The role of the intern
* @method getSchool Get the school of the intern
* @method getRole Get the role of the intern
* @instance Intern
* @example
* const intern = new Intern('John Doe', 1, 'john.doe@mail.com', 'Harvard');
* intern.getSchool(); // 'Harvard'
* intern.getRole(); // 'Intern'
*/
class Intern extends Employee {
/**
* Creates an instance of Intern.
* @constructor Intern
* @param {string} name
* @param {number} id
* @param {string} email
* @param {string} school
*/
constructor(name, id, email, school) {
super(name, id, email);
this.school = school;
this.role = EnumEmployeeType.INTERN;
}
/**
* Get the school of the intern.
* @returns {string}
* @memberof Intern
* @method getSchool
* @instance Intern
* @example
* const intern = new Intern('John Doe', 1, 'john.doe@mail.com', 'Harvard');
* intern.getSchool(); // 'Harvard'
*/
getSchool() {
return this.school;
}
/**
* Get the role of the intern.
* @returns {EnumEmployeeType.INTERN}
* @throws {Error} If the employee type is invalid
* @override Employee.getRole
* @memberof Intern
* @method getRole
* @instance Intern
* @example
* const intern = new Intern('John Doe', 1, 'john.doe@mail.com', 'Harvard');
* intern.getRole(); // 'Intern'
*/
getRole() {
try {
if (this.role !== EnumEmployeeType.INTERN) {
throw new Error('Invalid employee type');
} else {
return this.role;
}
} catch (error) {
console.error(error);
}
}
}
module.exports = Intern;