Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 03e75a4

Browse files
Day 13: Abstract Classes
1 parent 5ba544f commit 03e75a4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎Day 13: Abstract Classes.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from abc import ABCMeta, abstractmethod
2+
class Book(object, metaclass=ABCMeta):
3+
def __init__(self,title,author):
4+
self.title=title
5+
self.author=author
6+
@abstractmethod
7+
def display(): pass
8+
9+
#Write MyBook class
10+
class MyBook(Book):
11+
def __init__(self,title,author,price):
12+
self.price = price
13+
super().__init__(title,author)
14+
def display(self):
15+
print("Title:",self.title)
16+
print("Author:",self.author)
17+
print("Price:",self.price)
18+
19+
title=input()
20+
author=input()
21+
price=int(input())
22+
new_novel=MyBook(title,author,price)
23+
new_novel.display()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /