Created
April 10, 2019 20:12
-
-
Save Sean-Bradley/9cb728b58e1b1844427680c61b6ce12e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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