es6 syntax learning

This commit is contained in:
Blue 2018-11-18 21:14:06 +03:00
parent a463c64b01
commit 42f5b4fb63
3 changed files with 1 additions and 7 deletions

View File

@ -1,7 +1,6 @@
import Color from "./color.js"; import Color from "./color.js";
class Canvas { class Canvas {
element;
constructor() { constructor() {
this.element = document.createElement("canvas"); this.element = document.createElement("canvas");
this.element.width = 1000; this.element.width = 1000;

View File

@ -1,8 +1,6 @@
import Shape from "./shape.js"; import Shape from "./shape.js";
class Rectangle extends Shape { class Rectangle extends Shape {
className = "Rectangle";
constructor(x, y, color, width, height) { constructor(x, y, color, width, height) {
super(x, y, color); super(x, y, color);

View File

@ -1,16 +1,13 @@
import Color from "./color.js"; import Color from "./color.js";
class Shape { class Shape {
className = "Shape";
color;
constructor(x, y, color) { constructor(x, y, color) {
this._x = x; this._x = x;
this._y = y; this._y = y;
this.color = color; this.color = color;
} }
draw(context) { draw(context) {
throw new Error("A pure virtual method call of a shape " + this.className); throw new Error("A pure virtual method call of a shape " + this.constructor.name);
} }
static randomOptions() { static randomOptions() {