Merevoli

Untitled

Sep 15th, 2022
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. class AbstractShape(ABC):
  2.     pass
  3.    
  4. class Circle(AbstractShape):
  5.     pass
  6.  
  7. class Rectangle(AbstractShape):
  8.     pass
  9.  
  10. circles = []
  11. rectangle = []
  12.  
  13. class AbstractFactory(ABC):
  14.     @abstractmethod
  15.     def execute(shape: AbstractShape = None):
  16.         pass
  17.        
  18. class AddFatory(ABC):
  19.     def execute(shape: AbstractShape = None):
  20.         global circles, rectangle
  21.         if isinstance(shape, Circle):
  22.             circles.append(Circle())
  23.        
  24. class RemoveFatory(ABC):
  25.     def execute(shape: AbstractShape = None):
  26.         global circles, rectangle
  27.        
  28. class UndoFatory(ABC):
  29.     def execute(shape: AbstractShape = None):
  30.         global circles, rectangle
  31.        
  32. class RedoFatory(ABC):
  33.     def execute(shape: AbstractShape = None):
  34.         global circles, rectangle
  35.        
  36. class PrintFatory(ABC):
  37.     def execute(shape: AbstractShape = None):
  38.         global circles, rectangle
  39.        
  40.        
  41. action_user = input()
  42.  
  43. if action_user == 'Add':
  44.     AddFatory().execute(shape)
Advertisement
Add Comment
Please, Sign In to add comment