Skip to content

Instantly share code, notes, and snippets.

@MeetMartin
Created April 20, 2019 06:54
Show Gist options
  • Save MeetMartin/07b0982155d346a7b502951ccf9014d7 to your computer and use it in GitHub Desktop.
Save MeetMartin/07b0982155d346a7b502951ccf9014d7 to your computer and use it in GitHub Desktop.
import {Animal, Dog} from './animals';
import {Robot} from './robots';
class RoboDog {
constructor(animal, dog, robot) {
this.animal = new animal();
this.dog = new dog();
this.robot = new robot();
}
move() {
return this.animal.move();
}
bark() {
return this.dog.bark();
}
chargeBattery() {
return this.robot.chargeBattery();
}
roboBark() {
return 2 * this.dog.bark();
}
}
const roboDog = new RoboDog(Animal, Dog, Robot);
roboDog.roboBark();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment