Skip to content

Commit a949be8

Browse files
committed
stage 7
1 parent e15cc10 commit a949be8

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

stages/index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
'use strict';
22
/**
3-
* We add a `Circle` class to complement our `Rectangle`.
4-
* Circles have `x` and `y` position as well
5-
* as a radius (`r`).
3+
* We refactor the `Rectangle` and `Circle` classes,
4+
* taking the common properties and functions and
5+
* moving them to a new _superclass_ called `Shape`.
66
*/
77

8-
class Rectangle {
9-
constructor(x, y, width, height, col) {
8+
class Shape {
9+
constructor(x, y, col) {
1010
this.x = x;
1111
this.y = y;
12+
this.col = col;
13+
}
14+
}
15+
16+
class Rectangle extends Shape {
17+
constructor(x, y, width, height, col) {
18+
super(x, y, col);
1219
this.width = width;
1320
this.height = height;
14-
this.col = col;
1521
}
1622

1723
draw(ctx) {
@@ -20,12 +26,10 @@ class Rectangle {
2026
}
2127
}
2228

23-
class Circle {
29+
class Circle extends Shape {
2430
constructor(x, y, r, col) {
25-
this.x = x;
26-
this.y = y;
31+
super(x, y, col);
2732
this.r = r;
28-
this.col = col;
2933
}
3034

3135
draw(ctx) {

0 commit comments

Comments
 (0)