Sort by

recency

|

589 Discussions

|

  • + 1 comment

    Just MyBook class Python implementation code:

    # Write MyBook class
    class MyBook(Book):
        def __init__(self, title, author, price):
            self.title = title
            self.author = author
            self.price = price
            
        def display(self):
            print(f"Title: {self.title}")
            print(f"Author: {self.author}")
            print(f"Price: {self.price}")
    
  • + 0 comments

    javascript

    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(title, 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}\nAuthor: ${this.author}\nPrice: ${this.price}`)
        }
    // End class
    }
    
  • + 0 comments

    Pretty easy challange *My code: *

    class MyBook(Book):
        def __init__(self, title, author, price):
            super().__init__(title, author)
            self.price = price
        def display(self):
            print("Title: " + self.title)
            print("Author: " + self.author)
            print("Price: " + str(self.price))
    
  • + 0 comments

    python solution :

    class MyBook(Book): def init(self, title, author, price): super().init(title, author) self.price = price def display(self): print(f"Title: {self.title}\nAuthor: {self.author}\nPrice: {self.price}")

  • + 0 comments

    import java.util.*;

    abstract class Book { String title; String author;

    Book(String title, String author) {
        this.title = title;
        this.author = author;
    }
    
    abstract void display();
    

    }

    class MyBook extends Book{ int price; MyBook(String title, String author,int price){ super(title,author); this.price=price;

    }
     void display(){
       System.out.println("Title: " + this.title);
       System.out.println("Author: " + this.author);
       System.out.println("Price: " + this.price); 
    }
    

    }

    public class Solution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String title = scanner.nextLine();
        String author = scanner.nextLine();
        int price = scanner.nextInt();
        scanner.close();
    
        Book book = new MyBook(title, author, price);
        book.display();
    }
    

    }