Skip to content
Permalink
Browse files

adding example (extends,this, super)

  • Loading branch information...
Risyandi committed Sep 5, 2019
1 parent 17a4ae5 commit 1140f55288bac03c05a55f94cf6068a9102ac9cc
Showing with 51 additions and 1 deletion.
  1. +1 −1 class-construct/class-construct.js
  2. +50 −0 class-construct/extends-this-super.js
@@ -7,7 +7,7 @@ class classAndConstruct {
this.width = width;
}

// getter
// getter value from calculate
get areaCalculate() {
return this.calculate();
}
@@ -0,0 +1,50 @@
class Animal {
constructor(name, weight) {
this.name = name;
this.weight = weight;
}

eat() {
return `${this.name} is eat`;
}

sleep() {
return `${this.name} is sleep`;
}

wakeUp() {
return `${this.name} is wakeup`;
}
}

class Gorilla extends Animal {
constructor(name, weight) {
super(name, weight);
}

climbTree() {
return `${this.name} is climb tree`;
}

poundChest() {
return `${this.name} is pound chest`;
}

showVigour() {
return `${super.eat()} and ${this.poundChest()}`;
}

dailyRoutine() {
return `${super.wakeUp()} ${this.climbTree()} and ${super.sleep()}`;
}
}

function display(content) {
console.log(content);
}

const gorilla = new Gorilla('George', '160Kg');
display(gorilla.poundChest());
display(gorilla.sleep());
display(gorilla.showVigour());
display(gorilla.dailyRoutine());

0 comments on commit 1140f55

Please sign in to comment.
You can’t perform that action at this time.