You are viewing a single comment's thread. Return to all comments →
1) Inherit from Book You create a new class MyBook that uses Book as its base.
2) Constructor with 3 inputs:
title, author, and price
Use super() to send title and author to the parent (Book).
Then use self.price = price to save the price in this class.
3) Use self to store values
self.title, self.author, and self.price This means you’re saving the data inside the object so it can be used later.
4) Implement the display() method print()
Seems like cookies are disabled on this browser, please enable them to open this website
Day 13: Abstract Classes
You are viewing a single comment's thread. Return to all comments →
1) Inherit from Book You create a new class MyBook that uses Book as its base.
2) Constructor with 3 inputs:
title, author, and price
Use super() to send title and author to the parent (Book).
Then use self.price = price to save the price in this class.
3) Use self to store values
self.title, self.author, and self.price This means you’re saving the data inside the object so it can be used later.
4) Implement the display() method print()