EN: Thanks to the fact that the child-management operations are declared in the base Component class, the client code can work with any component, simple or complex, without depending on their concrete classes. RU: Благодаря тому, что операции управления потомками объявлены в базов
(component1: Component, component2: Component)
| 172 | |
| 173 | |
| 174 | def client_code2(component1: Component, component2: Component) -> None: |
| 175 | """ |
| 176 | EN: Thanks to the fact that the child-management operations are declared in |
| 177 | the base Component class, the client code can work with any component, |
| 178 | simple or complex, without depending on their concrete classes. |
| 179 | |
| 180 | RU: Благодаря тому, что операции управления потомками объявлены в базовом |
| 181 | классе Компонента, клиентский код может работать как с простыми, так и со |
| 182 | сложными компонентами, вне зависимости от их конкретных классов. |
| 183 | """ |
| 184 | |
| 185 | if component1.is_composite(): |
| 186 | component1.add(component2) |
| 187 | |
| 188 | print(f"RESULT: {component1.operation()}", end="") |
| 189 | |
| 190 | |
| 191 | if __name__ == "__main__": |
no test coverage detected