Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. if __name__ == "__main__":
  2. # The Client is the main python app
  3.  
  4. # The Light is the Reciever
  5. LIGHT = Light()
  6.  
  7. # Create Commands
  8. SWITCH_ON = SwitchOnCommand(LIGHT)
  9. SWITCH_OFF = SwitchOffCommand(LIGHT)
  10.  
  11. # Register the commands with the invoker (Switch)
  12. SWITCH = Switch()
  13. SWITCH.register("ON", SWITCH_ON)
  14. SWITCH.register("OFF", SWITCH_OFF)
  15.  
  16. # Execute the commands that are registered on the Invoker
  17. SWITCH.execute("ON")
  18. SWITCH.execute("OFF")
  19. SWITCH.execute("ON")
  20. SWITCH.execute("OFF")
  21.  
  22. # For fun, we can see the history
  23. print(SWITCH.history)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement