/
GlebBavykin
/
python_sketches
Обзор
Документация
Войти
/
GlebBavykin
/
python_sketches
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
design_patterns/structural/bridge.py
56 строк
1 KB
Gleb Bavykin
fixed mypy errors
10 июл 2026, 17:15
10 июл 2026, 17:15
1646d69
Код
Авторство
О чём код?
from enum import Enum, auto class Color(Enum): """ Color for a shape """ WITHOUT_COLOR = auto() RED = auto() WHITE = auto() BLACK = auto() YELLOW = auto() class Shape: """ Shape with color """ def __init__(self, color: Color = Color.WITHOUT_COLOR): self.color = color class Circle(Shape): """ Concrete Circle shape with color """ def __init__(self, radius): super().__init__() self.__radius = radius def change_radius(self, new_radius): self.__radius = new_radius def __repr__(self) -> str: return f"Circle({self.__radius}, {self.color}) with {self.color} color" class Rectangle(Shape): """ Concrete Rectangle shape with color """ def __init__(self, width, height): super().__init__() self.__width = width self.__height = height def change_width_and_height(self, new_width, new_height): self.__width = new_width self.__height = new_height def __repr__(self) -> str: return f"Rectangle({self.__width}, {self.__height}) with {self.color} color"