Advertisement
DrAungWinHtut

oop_basic.py

Dec 1st, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. class CAR:
  2.     def __init__(self,model,price,color):
  3.         self._model = model
  4.         self.price = price
  5.         self.color = color
  6.  
  7.     def setModel(self,model):
  8.         self._model = model
  9.    
  10.     def setColor(self,color):
  11.         self.color = color
  12.    
  13.     def setPrice(self,price):
  14.         self.price = price
  15.    
  16.     def getModel(self):
  17.         return self._model
  18.    
  19.     def getColor(self):
  20.         return self.color
  21.    
  22.     def getPrice(self):
  23.         return self.price
  24.  
  25.  
  26. class EV(CAR):
  27.     def __init__(self,model,price,color,max_dist):
  28.         super().__init__(model,price,color)
  29.         self._max_dist = max_dist
  30.  
  31.     def getMaxDist(self):
  32.         return self._max_dist
  33.    
  34.  
  35. tesla = EV('Tesla',200000,'white',1000)
  36.  
  37. print(tesla.getModel())
  38. print(tesla.getMaxDist())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement