Skip to content

Instantly share code, notes, and snippets.

@Sean-Bradley
Last active April 9, 2019 20:36
Show Gist options
  • Save Sean-Bradley/0665c4740f28ada0c34a6862888a6529 to your computer and use it in GitHub Desktop.
Save Sean-Bradley/0665c4740f28ada0c34a6862888a6529 to your computer and use it in GitHub Desktop.
# Asking for a `SmallChair` will pass the request to the `Chair Factory`
FURNITURE = FurnitureFactory.get_furniture("SmallChair")
print(f"{FURNITURE.__class__} : {FURNITURE.dimensions()}")
# prints <class 'chair_factory.SmallChair'> : {'width': 40, 'depth': 40, 'height': 40}
# And Asking for a `MediumTable` will pass the request to the `TableFactory`
FURNITURE = FurnitureFactory.get_furniture("MediumTable")
print(f"{FURNITURE.__class__} : {FURNITURE.dimensions()}")
# prints <class 'table_factory.MediumTable'> : {'width': 110, 'depth': 70, 'height': 60}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment