forked from utnfrrottads/presentacion-es6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.js
45 lines (43 loc) · 964 Bytes
/
module.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
export class Shape {
constructor (id, x, y) {
this.id = id
this.move(x, y)
}
toString () {
return `Shape(${this.id})`
}
move (x, y) {
this.x = x
this.y = y
}
}
export class Rectangle extends Shape {
static defaultRectangle () {
return new Rectangle("default", 0, 0, 100, 100)
}
constructor (id, x, y, width, height) {
super(id, x, y)
this.width = width;
this.height = height;
}
toString () {
return "Rectangle > " + super.toString();
}
perimeter() {
return (width + height) * 2
}
}
export const pi = 3.14159;
class Circle extends Shape {
constructor (id, x, y, radius) {
super(id, x, y);
this.radius = radius;
}
toString () {
return "Circle > " + super.toString()
}
perimeter() {
return pi * this.radius * this.radius;
}
}
var defRectangle = Rectangle.defaultRectangle()