-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathbridge.js
More file actions
38 lines (31 loc) · 672 Bytes
/
bridge.js
File metadata and controls
38 lines (31 loc) · 672 Bytes
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
const Bridge = (() => {
// refined Abstractions
function Circle(color) {
this.color = color;
this.plot = function() {
return `${this.color.getColorName()} Circle`;
};
}
function Rectangle(color) {
this.color = color;
this.draw = function() {
return `${this.color.getColorName()} Rectangle`;
};
}
// concrete Implementors
function Red() {
this.getColorName = function() {
return "Red";
};
}
function Blue() {
this.getColorName = function() {
return "Blue";
};
}
return {
Implementors: { Red, Blue },
Abstractions: { Circle, Rectangle }
};
})();
module.exports = Bridge;