The Abstract Factory pattern builds families of related products that must match, without hard-coding which concrete classes you use. We are building a themed UI kit. Every widget is a product, and each theme provides a matching set of products.
Two abstract products, Button and Checkbox, are already defined for you. Each declares a render() method that returns a plain string (imagine the drawn widget). Your job is to implement the first concrete family: the Light theme.
Implement:
Return the strings exactly, including the square brackets.
class Button:
"""Abstract product: a clickable button."""
def render(self):
raise NotImplementedError
class Checkbox:
"""Abstract product: a toggle checkbox."""
def render(self):
raise NotImplementedError
class LightButton(Button):
def render(self):
# TODO: return the light button string, e.g. [Light Button]
pass
class LightCheckbox(Checkbox):
def render(self):
# TODO: return the light checkbox string, e.g. [Light Checkbox]
passThe editor and the test runner need a wide screen. Open this page on a desktop browser and your progress will be waiting.
The Abstract Factory pattern builds families of related products that must match, without hard-coding which concrete classes you use. We are building a themed UI kit. Every widget is a product, and each theme provides a matching set of products.
Two abstract products, Button and Checkbox, are already defined for you. Each declares a render() method that returns a plain string (imagine the drawn widget). Your job is to implement the first concrete family: the Light theme.
Implement:
Return the strings exactly, including the square brackets.
Press Run Tests or ββ© to check your solution.