-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadam-eve.js
37 lines (31 loc) · 919 Bytes
/
adam-eve.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
/*
According to the creation myths of the Abrahamic religions, Adam and Eve were the first Humans to wander the Earth.
You have to do God's job. The creation method must return an array of length 2 containing objects (representing Adam and Eve). The first object in the array should be an instance of the class Man. The second should be an instance of the class Woman. Both objects have to be subclasses of Human. Your job is to implement the Human, Man and Woman classes.
*/
// solution
class Human {
constructor(name, gender) {
this.name = name;
this.gender = gender;
}
}
class Man extends Human {
constructor(name) {
super(name, "male");
}
}
class Woman extends Human {
constructor(name) {
super(name, "female");
}
}
class God {
/**
* @returns Human[]
*/
static create() {
const adam = new Man("Adam");
const eve = new Woman("Eve");
return [adam, eve];
}
}