Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if __name__ == "__main__":
- # The Client is the main python app
- # The Light is the Reciever
- LIGHT = Light()
- # Create Commands
- SWITCH_ON = SwitchOnCommand(LIGHT)
- SWITCH_OFF = SwitchOffCommand(LIGHT)
- # Register the commands with the invoker (Switch)
- SWITCH = Switch()
- SWITCH.register("ON", SWITCH_ON)
- SWITCH.register("OFF", SWITCH_OFF)
- # Execute the commands that are registered on the Invoker
- SWITCH.execute("ON")
- SWITCH.execute("OFF")
- SWITCH.execute("ON")
- SWITCH.execute("OFF")
- # For fun, we can see the history
- print(SWITCH.history)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement