es6 syntax learning
This commit is contained in:
parent
a463c64b01
commit
42f5b4fb63
@ -1,7 +1,6 @@
|
||||
import Color from "./color.js";
|
||||
|
||||
class Canvas {
|
||||
element;
|
||||
constructor() {
|
||||
this.element = document.createElement("canvas");
|
||||
this.element.width = 1000;
|
||||
|
@ -1,8 +1,6 @@
|
||||
import Shape from "./shape.js";
|
||||
|
||||
class Rectangle extends Shape {
|
||||
className = "Rectangle";
|
||||
|
||||
constructor(x, y, color, width, height) {
|
||||
super(x, y, color);
|
||||
|
||||
|
@ -1,16 +1,13 @@
|
||||
import Color from "./color.js";
|
||||
|
||||
class Shape {
|
||||
className = "Shape";
|
||||
color;
|
||||
|
||||
constructor(x, y, color) {
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this.color = color;
|
||||
}
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user