Advertisement
Adehumble

Week8|9 Coding Exercise 6

Apr 1st, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #6
  2. #This program demonstrates the idea of inheritance
  3.  
  4. class Store():
  5.     """This is a superclass"""
  6.     def __init__(self):
  7.         self.owner="Boris"
  8.    
  9.     def exclaim(self):
  10.         return "I'm defined in the superclass!"
  11.        
  12. #This HardwareStore class will inherits the instance methods from a Store superclass
  13. class HardwareStore(Store):
  14.     """This is a subclass"""
  15.     pass
  16.  
  17. #This is class object created from HardwareStore subclass  
  18. home_depot=HardwareStore()
  19.  
  20. print(home_depot.owner)
  21. print("\n")
  22. print(home_depot.exclaim())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement