EN: The Director is only responsible for executing the building steps in a particular sequence. It is helpful when producing products according to a specific order or configuration. Strictly speaking, the Director class is optional, since the client can control builders directly.
| 141 | |
| 142 | |
| 143 | class Director: |
| 144 | """ |
| 145 | EN: The Director is only responsible for executing the building steps in a |
| 146 | particular sequence. It is helpful when producing products according to a |
| 147 | specific order or configuration. Strictly speaking, the Director class is |
| 148 | optional, since the client can control builders directly. |
| 149 | |
| 150 | RU: Директор отвечает только за выполнение шагов построения в определённой |
| 151 | последовательности. Это полезно при производстве продуктов в определённом |
| 152 | порядке или особой конфигурации. Строго говоря, класс Директор необязателен, |
| 153 | так как клиент может напрямую управлять строителями. |
| 154 | """ |
| 155 | |
| 156 | def __init__(self) -> None: |
| 157 | self._builder = None |
| 158 | |
| 159 | @property |
| 160 | def builder(self) -> Builder: |
| 161 | return self._builder |
| 162 | |
| 163 | @builder.setter |
| 164 | def builder(self, builder: Builder) -> None: |
| 165 | """ |
| 166 | EN: The Director works with any builder instance that the client code |
| 167 | passes to it. This way, the client code may alter the final type of the |
| 168 | newly assembled product. |
| 169 | |
| 170 | RU: Директор работает с любым экземпляром строителя, который передаётся |
| 171 | ему клиентским кодом. Таким образом, клиентский код может изменить |
| 172 | конечный тип вновь собираемого продукта. |
| 173 | """ |
| 174 | self._builder = builder |
| 175 | |
| 176 | """ |
| 177 | EN: The Director can construct several product variations using the same |
| 178 | building steps. |
| 179 | |
| 180 | RU: Директор может строить несколько вариаций продукта, используя одинаковые |
| 181 | шаги построения. |
| 182 | """ |
| 183 | |
| 184 | def build_minimal_viable_product(self) -> None: |
| 185 | self.builder.produce_part_a() |
| 186 | |
| 187 | def build_full_featured_product(self) -> None: |
| 188 | self.builder.produce_part_a() |
| 189 | self.builder.produce_part_b() |
| 190 | self.builder.produce_part_c() |
| 191 | |
| 192 | |
| 193 | if __name__ == "__main__": |