SHARE
TWEET

Untitled

a guest Apr 20th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top