-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employee.js
49 lines (42 loc) · 1.12 KB
/
Employee.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
/**
* Employee.js
* This had better be a single object written in JavaScript, if you like your job.
*
*
* @license The Unlicense, http://unlicense.org/
* @version 1.0
* @author Daniel Flores, https://github.com/danielfloresd/
* @updated 2022-11-16
* @link url goes here
*
*
*/
class Employee {
constructor(name, id, email) {
if (typeof name !== "string" || !name.trim().length) {
throw new Error("Expected parameter 'name' to be a non-empty string");
}
if (typeof id !== "number" || isNaN(id) || id < 0) {
throw new Error("Expected parameter 'id' to be a non-negative number");
}
if (typeof email !== "string" || !email.trim().length) {
throw new Error("Expected parameter 'email' to be a non-empty string");
}
this.name = name;
this.id = id;
this.email = email;
}
getName() {
return this.name;
}
getId() {
return this.id;
}
getEmail() {
return this.email;
}
getRole() {
return 'Employee';
}
}
module.exports = Employee;