Skip to content

Instantly share code, notes, and snippets.

@Cowa
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save Cowa/1a49dfdb3dc7fef78f93 to your computer and use it in GitHub Desktop.

Select an option

Save Cowa/1a49dfdb3dc7fef78f93 to your computer and use it in GitHub Desktop.
class Car {
constructor(make, wheels) {
this.make = make;
this.wheels = wheels;
this.currentSpeed = 25;
}
printCurrentSpeed() {
console.log(this.make + ' is going ' + this.currentSpeed + ' mph.');
}
wheelsCheckUp() {
this.wheels.map(x => x.currentQuality());
}
}
class RaceCar extends Car {
constructor(make, wheels) {
super(make, wheels);
}
}
class Wheel {
constructor(quality) {
this.quality = quality;
}
currentQuality() {
console.log('Wheel quality: ', this.quality);
}
}
const car = new RaceCar('BabelCar', [new Wheel('poor'), new Wheel('good'), new Wheel('excellent'), new Wheel('good enough')]);
car.printCurrentSpeed();
car.wheelsCheckUp();
// car = 1; // <- const ! read-only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment