Last active
August 29, 2015 14:27
-
-
Save Cowa/1a49dfdb3dc7fef78f93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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