Skip to content

Instantly share code, notes, and snippets.

@OnePro
Last active September 11, 2019 00:00
Show Gist options
  • Save OnePro/06a45b0d87789149c39b1d014c9ed868 to your computer and use it in GitHub Desktop.
Save OnePro/06a45b0d87789149c39b1d014c9ed868 to your computer and use it in GitHub Desktop.
JS code for example
/**
* 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