📌  相关文章
📜  day 13 抽象类hackerrank解决方案javascript代码示例

📅  最后修改于: 2022-03-11 15:02:11.010000             🧑  作者: Mango

代码示例1
// day 13 abstract classes hackerrank solution javascript
// Declare your class here.
class MyBook extends Book {
    
    /**   
    *   Class Constructor
    *   
    *   @param title The book's title.
    *   @param author The book's author.
    *   @param price The book's price.
    **/
    // Write your constructor here
    constructor(title, author, price){
        super();
        this.title = title;
        this.author = author;
        this.price = price;
    }
    /**   
    *   Method Name: display
    *   
    *   Print the title, author, and price in the specified format.
    **/
    // Write your method here
    display() {
        console.log(`Title: ${this.title}`);
        console.log(`Author: ${this.author}`);
        console.log(`Price: ${this.price}`);
    }
// End class
}