/
JohnAdemoye.html
66 lines (58 loc) · 1.4 KB
/
JohnAdemoye.html
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
<!DOCTYPE html>
<html>
<body>
<script>
// your code here
// 3/4
class TrafficLight {
constructor(color, address) {
this.color = color;
this.address = address;
}
// 6
get getColor() {
console.log(this.color);
}
set setColor(color) {
this.color = color;
}
// 7
canGo() {
if (this.color === 'green') {
return true;
}
return false;
}
}
// 5
const myTL = new TrafficLight('red', 'Avenue 1');
// 8/9
class VIPTrafficLight extends TrafficLight {
constructor(color, address, SpecialEffects) {
super(color, address)
this.SpecialEffects = SpecialEffects;
}
// 11
get getSpecialEffects() {
return this.SpecialEffects;
}
// 12
set setSpecialEffects(SpecialEffects) {
if (
SpecialEffects !== 'dotted' ||
SpecialEffects !== 'solid' ||
SpecialEffects !== 'dashed'
) {
console.log("No valid effect!");
break;
} else {
this.SpecialEffects = SpecialEffects;
}
}
}
// 10
const myVIP = new VIPTrafficLight('dotted');
console.log(myVIP.getSpecialEffects);
</script>
</body>
</html>