Advertisement
Nenogzar

handball - BaseEquipment

Aug 11th, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. from abc import ABC, abstractmethod
  2.  
  3.  
  4. class BaseEquipment(ABC):
  5.     equipment_properties = {
  6.         'ElbowPad': {'PROTECTION': 90, 'PRICE': 25.0, 'INCREASES_PRICE': 1.1},
  7.         'KneePad': {'PROTECTION': 120, 'PRICE': 15.0, 'INCREASES_PRICE': 1.2}
  8.     }
  9.  
  10.     def __init__(self, protection: int = None, price: float = None):
  11.         class_name = self.__class__.__name__
  12.  
  13.  
  14.         self._protection = self.equipment_properties[class_name]['PROTECTION']
  15.         self._price = self.equipment_properties[class_name]['PRICE']
  16.  
  17.     def increase_price(self) -> None:
  18.         class_name = self.__class__.__name__
  19.         increase_factor = self.equipment_properties[class_name]['INCREASES_PRICE']
  20.         self._price *= increase_factor
  21.  
  22.     @property
  23.     def protection(self):
  24.         return self._protection
  25.  
  26.     @property
  27.     def price(self):
  28.         return self._price
  29.  
  30.     @price.setter
  31.     def price(self, value):
  32.         self._price = value
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement