Slide 66
Slide 66 text
class Shape {
constructor(x, y, color) {
this.x = x;
this.y = y;
this.color = color;
}
}
class Rectangle extends Shape {
constructor (x, y, color, width, height) {
super(x, y, color);
this.width = width;
this.height = height;
}
}
class Circle extends Shape {
constructor (x, y, color, radius) {
super(x, y, color);
this.radius = radius;
}
}
let circle = new Circle(0,0,"red",5);
console.log(circle);
A lot nicer syntax for
creating inheritance!
66