class Car {
constructor(make) { //constructors!
this.make = make;
this.currentSpeed = 25;
}
printCurrentSpeed(){
console.log(this.make + ' is going ' + this.currentSpeed + ' mph.');
}
}
class RaceCar extends Car { //inheritance
constructor(make, topSpeed) {
super(make); //call the parent constructor with super
this.topSpeed = topSpeed;
}
goFast(){
this.currentSpeed = this.topSpeed;
}
}
let stang = new RaceCar('Mustang', 150);
stang.printCurrentSpeed();
stang.goFast();
stang.printCurrentSpeed();