Design Patterns, Behavioural Design, Java, Software Development.
invoker RemoteControl remoteControl = new RemoteControl(); // Set and execute the commands remoteControl.setCommand(turnOnCommand); remoteControl.pressButton(); // Output: Light is on remoteControl.setCommand(turnOffCommand); remoteControl.pressButton(); // Output: Light is off } } Real-world Use