Advertisement
Dammiejoy20

Untitled

Mar 29th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. # Superclass declaration with instance methods
  2. class Clothing():
  3.     def wear(self):
  4.         print("I'm wearing this fashionable piece of clothing!")
  5.  
  6.     def sell(self):
  7.         print("Buy my piece of clothing!")
  8.  
  9. # Subclass declaration with instance methods which will inherit the instances in the superclass above. Since the subclass
  10. # has the same name instance as the superclass, it will automatically override the instances in the parent class when
  11. # accessed.
  12. class Socks(Clothing):
  13.      def lose_one(self):
  14.          print("Where did my one go?")
  15.  
  16.      def wear(self):
  17.         print("Take a look at my sock! They're gorgeous")
  18.  
  19.      def sell(self):
  20.         print("Buy my socks")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement