-
Notifications
You must be signed in to change notification settings - Fork 0
/
day-13-solution.py
41 lines (30 loc) · 932 Bytes
/
day-13-solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Import packages
from abc import ABCMeta, abstractmethod
class Book(object, metaclass=ABCMeta):
def __init__(self, title, author):
self.title = title
self.author = author
@abstractmethod
def display():
# Abstract methods are to be implemented in sub-class
pass
# Create sub-class by inheriting the above parent class
class MyBook(Book):
def __init__(self, title, author, price):
self.price = price
super(MyBook, self).__init__(title, author)
def display(self):
print("Title:", self.title)
print("Author:", self.author)
print("Price:", self.price)
if __name__ == "__main__":
# Read input title from stdin
title = input()
# Read input author from stdin
author = input()
# Read input price from stdin
price = int(input())
# Create an instance of the custom class `MyBook`
new_novel = MyBook(title,author,price)
# Call `display` class method to print details of the book
new_novel.display()