Skip to content

Instantly share code, notes, and snippets.

@Sean-Bradley
Created April 10, 2019 20:12
Show Gist options
  • Save Sean-Bradley/9cb728b58e1b1844427680c61b6ce12e to your computer and use it in GitHub Desktop.
Save Sean-Bradley/9cb728b58e1b1844427680c61b6ce12e to your computer and use it in GitHub Desktop.
class ICommand(metaclass=ABCMeta):
"""The command interface, which all commands will implement"""
@abstractstaticmethod
def execute():
"""The required execute method which all command obejcts will use"""
class SwitchOnCommand(ICommand):
"""A Command object, which implemets the ICommand interface"""
def __init__(self, light):
self._light = light
def execute(self):
self._light.turn_on()
class SwitchOffCommand(ICommand):
"""A Command object, which implemets the ICommand interface"""
def __init__(self, light):
self._light = light
def execute(self):
self._light.turn_off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment