Advertisement
vesso8

dsada

Aug 13th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. from abc import ABC, abstractmethod
  2.  
  3. class Card(ABC):
  4.     @abstractmethod
  5.     def __init__(self, name, damage_points, health_points):
  6.         self.name = name
  7.         self.damage_points = damage_points
  8.         self.health_points = health_points
  9.        
  10.     @property
  11.     def name(self):
  12.         return self.__name
  13.    
  14.     @name.setter
  15.     def name(self, value):
  16.         if value == "":
  17.             raise ValueError("Card's name cannot be an empty string.")
  18.         self.__name = value
  19.     @property
  20.     def damage_points(self):
  21.         return self.__damage_points
  22.    
  23.     @damage_points.setter
  24.     def damage_points(self, value):
  25.         if value < 0:
  26.             raise ValueError("Card's damage points cannot be less than zero.")
  27.         self.__damage_points = value
  28.     @property
  29.     def health_points(self):
  30.         return self.__health_points
  31.    
  32.     @health_points.setter
  33.     def health_points(self, value):
  34.         if value < 0:
  35.             raise ValueError("Card's HP cannot be less than zero.")
  36.         self.__health_points = value
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement