"""Concrete Products are created by corresponding Concrete Factories.""" from creational.abstract_factory.AbstractProductA import AbstractProductA from creational.abstract_factory.AbstractProductB import AbstractProductB class ConcreteProductA1(AbstractProductA): def useful_function_a(self) -> str: return "The result of the product A1." class ConcreteProductA2(AbstractProductA): def useful_function_a(self) -> str: return "The result of the product A2." class ConcreteProductB1(AbstractProductB): def useful_function_b(self) -> str: return "The result of the product B1." def another_useful_function_b(self, collaborator: AbstractProductA) -> str: """ The variant, Product B1, is only able to work correctly with the variant, Product A1. Nevertheless, it accepts any instance of AbstractProductA as an argument. """ result = collaborator.useful_function_a() return f"The result of the B1 collaborating with the ({result})" class ConcreteProductB2(AbstractProductB): def useful_function_b(self) -> str: return "The result of the product B2." def another_useful_function_b(self, collaborator: AbstractProductA): """ The variant, Product B2, is only able to work correctly with the variant, Product A2. Nevertheless, it accepts any instance of AbstractProductA as an argument. """ result = collaborator.useful_function_a() return f"The result of the B2 collaborating with the ({result})"