Created
April 8, 2019 17:25
-
-
Save raikusy/5330a16801faf02e1f17f4f9e407070d to your computer and use it in GitHub Desktop.
This file contains 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 Book { | |
constructor(author, isbn, genre) { | |
this.author = author; | |
this.isbn = isbn; | |
this.genre = genre; | |
} | |
getDescription() { | |
return this.author+' '+this.isbn+' '+this.genre; | |
} | |
} | |
class Adventure extends Book { | |
constructor(author, isbn, genre, price) { | |
super(author, isbn, genre); | |
this.price = price; | |
} | |
getDescription() { | |
return super.getDescription() + ' ' + this.price; | |
} | |
} | |
let book = new Book('Fundamentals of Javascript', 'BA1234UX09', 'Herbert Shin'); | |
console.log(book.author); | |
console.log(book.getDescription()); | |
let adventure = new Adventure('Around the world in 80 days', 'YT46582BNH', 'Jules Verne', 7.99); | |
console.log(adventure.getDescription()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment