-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy path30-abstract-classes.py
34 lines (27 loc) · 991 Bytes
/
30-abstract-classes.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
# Tutorials > 30 Days of Code > Day 13: Abstract Classes
# Build on what you've already learned about Inheritance with this Abstract Classes challenge
#
# https://www.hackerrank.com/challenges/30-abstract-classes/problem
#
from abc import ABCMeta, abstractmethod
class Book(object, metaclass=ABCMeta):
def __init__(self,title,author):
self.title=title
self.author=author
@abstractmethod
def display(): pass
# (skeliton_head) ----------------------------------------------------------------------
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:", self.price)
# (skeliton_tail) ----------------------------------------------------------------------
title=input()
author=input()
price=int(input())
new_novel=MyBook(title,author,price)
new_novel.display()