Advertisement
robertvari

Inheritance example

May 12th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. class Vehicle:
  2.     def __init__(self):
  3.         self.type=None
  4.         self.name=None
  5.         self.color=None
  6.         self.max_speed=None
  7.  
  8. class Car(Vehicle):
  9.     def __init__(self):
  10.         Vehicle.__init__(self)
  11.  
  12. class Byke(Vehicle):
  13.     def __init__(self):
  14.         Vehicle.__init__(self)
  15.  
  16. myCar = Car()
  17. myCar.max_speed = 180
  18.  
  19. yourByke = Byke()
  20. yourByke.max_speed = 60
  21.  
  22. print(myCar.max_speed)
  23. print(yourByke.max_speed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement