Last active
September 11, 2019 00:00
-
-
Save OnePro/06a45b0d87789149c39b1d014c9ed868 to your computer and use it in GitHub Desktop.
JS code for example
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
/** | |
* This is the detail about the constructor | |
* @class Main class for all books | |
* @param {String} title Book title | |
* @param {String} author Name of author | |
* @param {Number} pages How many pages in the book | |
*/ | |
class Book { | |
constructor(title, author, pages) { | |
this.title = title; | |
this.author = author; | |
this.pages = pages; | |
} | |
get PageCount() { | |
return this.pages; | |
} | |
get AuthorName() { | |
return this.author; | |
} | |
get BookTitle() { | |
return this.title; | |
} | |
} | |
/** | |
* @class Type of genre | |
* @param {String} title Book title | |
* @param {String} author Name of author | |
* @param {Number} pages How many pages in the book | |
* @param {String} genre Gener of book | |
*/ | |
class Novel extends Book { | |
constructor(title, author, pages, genre) { | |
super(title, author, pages); | |
this.genre = genre; | |
} | |
get BookGenre() { | |
return this.genre; | |
} | |
} | |
let book = new Novel('The Hobbit', 'J.R.R. Tolkien', 310, 'Fantasy'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment