- Open your command line application and navigate to your workspace.
- Create a new folder named 08-10-use-throw-to-simulate-abstract-class.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file that defines a new class named Rocket. In the constructor, check the constructor of the instance, if it's Rocket, then throw an error:
// main.js class Rocket { constructor (name) { this.name = name; if (this.constructor === Rocket) { throw new Error('Abstract Class Should not be instantiated'); } } }
- Create two child classes of Rocket:
// main.js class ActiveRocket extends Rocket {} class InactiveRocket extends Rocket {}
- Create a main function that creates instances of each class ...