Skip to content

Commit f0b56e6

Browse files
authored
Merge pull request #934 from ShenpaiSharma/Fixes-Issue_#921
Corrected code for Inheritance which was not implementing inheritance using extends keyword
2 parents e54ff82 + 52c6cf2 commit f0b56e6

File tree

4 files changed

+40
-44
lines changed

4 files changed

+40
-44
lines changed

src/data/examples/en/11_Objects/04_Inheritance.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function draw() {
2121
spots.display();
2222
}
2323

24-
class SpinArm {
24+
class Spin {
2525
constructor(x, y, s) {
2626
this.x = x;
2727
this.y = y;
@@ -32,6 +32,12 @@ class SpinArm {
3232
update() {
3333
this.angle += this.speed;
3434
}
35+
}
36+
37+
class SpinArm extends Spin {
38+
constructor(x, y, s) {
39+
super(x, y, s)
40+
}
3541

3642
display() {
3743
strokeWeight(1);
@@ -45,17 +51,10 @@ class SpinArm {
4551
}
4652
}
4753

48-
class SpinSpots {
54+
class SpinSpots extends Spin {
4955
constructor(x, y, s, d) {
50-
this.x = x;
51-
this.y = y;
52-
this.speed = s;
56+
super(x, y, s)
5357
this.dim = d;
54-
this.angle = 0.0;
55-
}
56-
57-
update() {
58-
this.angle += this.speed;
5958
}
6059

6160
display() {
@@ -68,4 +67,4 @@ class SpinSpots {
6867
ellipse(this.dim/2, 0, this.dim, this.dim);
6968
pop();
7069
}
71-
}
70+
}

src/data/examples/es/11_Objects/04_Inheritance.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function draw() {
2121
spots.display();
2222
}
2323

24-
class SpinArm {
24+
class Spin {
2525
constructor(x, y, s) {
2626
this.x = x;
2727
this.y = y;
@@ -32,6 +32,12 @@ class SpinArm {
3232
update() {
3333
this.angle += this.speed;
3434
}
35+
}
36+
37+
class SpinArm extends Spin {
38+
constructor(x, y, s) {
39+
super(x, y, s)
40+
}
3541

3642
display() {
3743
strokeWeight(1);
@@ -45,17 +51,10 @@ class SpinArm {
4551
}
4652
}
4753

48-
class SpinSpots {
54+
class SpinSpots extends Spin {
4955
constructor(x, y, s, d) {
50-
this.x = x;
51-
this.y = y;
52-
this.speed = s;
56+
super(x, y, s)
5357
this.dim = d;
54-
this.angle = 0.0;
55-
}
56-
57-
update() {
58-
this.angle += this.speed;
5958
}
6059

6160
display() {
@@ -68,4 +67,4 @@ class SpinSpots {
6867
ellipse(this.dim/2, 0, this.dim, this.dim);
6968
pop();
7069
}
71-
}
70+
}

src/data/examples/ko/11_Objects/04_Inheritance.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function draw() {
2121
spots.display();
2222
}
2323

24-
class SpinArm {
24+
class Spin {
2525
constructor(x, y, s) {
2626
this.x = x;
2727
this.y = y;
@@ -32,6 +32,12 @@ class SpinArm {
3232
update() {
3333
this.angle += this.speed;
3434
}
35+
}
36+
37+
class SpinArm extends Spin {
38+
constructor(x, y, s) {
39+
super(x, y, s)
40+
}
3541

3642
display() {
3743
strokeWeight(1);
@@ -45,17 +51,10 @@ class SpinArm {
4551
}
4652
}
4753

48-
class SpinSpots {
54+
class SpinSpots extends Spin {
4955
constructor(x, y, s, d) {
50-
this.x = x;
51-
this.y = y;
52-
this.speed = s;
56+
super(x, y, s)
5357
this.dim = d;
54-
this.angle = 0.0;
55-
}
56-
57-
update() {
58-
this.angle += this.speed;
5958
}
6059

6160
display() {
@@ -68,4 +67,4 @@ class SpinSpots {
6867
ellipse(this.dim/2, 0, this.dim, this.dim);
6968
pop();
7069
}
71-
}
70+
}

src/data/examples/zh-Hans/11_Objects/04_Inheritance.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function draw() {
2020
spots.display();
2121
}
2222

23-
class SpinArm {
23+
class Spin {
2424
constructor(x, y, s) {
2525
this.x = x;
2626
this.y = y;
@@ -31,6 +31,12 @@ class SpinArm {
3131
update() {
3232
this.angle += this.speed;
3333
}
34+
}
35+
36+
class SpinArm extends Spin {
37+
constructor(x, y, s) {
38+
super(x, y, s)
39+
}
3440

3541
display() {
3642
strokeWeight(1);
@@ -44,17 +50,10 @@ class SpinArm {
4450
}
4551
}
4652

47-
class SpinSpots {
53+
class SpinSpots extends Spin {
4854
constructor(x, y, s, d) {
49-
this.x = x;
50-
this.y = y;
51-
this.speed = s;
55+
super(x, y, s)
5256
this.dim = d;
53-
this.angle = 0.0;
54-
}
55-
56-
update() {
57-
this.angle += this.speed;
5857
}
5958

6059
display() {
@@ -67,4 +66,4 @@ class SpinSpots {
6766
ellipse(this.dim/2, 0, this.dim, this.dim);
6867
pop();
6968
}
70-
}
69+
}

0 commit comments

Comments
 (0)