-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicSubclassesAdamAndEve.js
More file actions
47 lines (41 loc) · 1.02 KB
/
Copy pathbasicSubclassesAdamAndEve.js
File metadata and controls
47 lines (41 loc) · 1.02 KB
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
// Description:
// 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.
//my solution
class God {
/**
* @returns Human[]
*/
static create() {
// code
return [new Man(), new Woman()];
}
}
// code
class Human {
constructor(name) {
this.name = name;
}
}
class Man extends Human {
constructor(name) {
super(name);
}
}
class Woman extends Human {
constructor(name) {
super(name);
}
}
//shorter solution
class God {
/**
* @returns Human[]
*/
static create() {
return [new Man(), new Woman()];
}
}
class Human {}
class Man extends Human {}
class Woman extends Human {}