Complete the code to define the Command interface method.
interface Command {
void [1]();
}The Command interface defines the execute method which all commands implement.
Complete the code to implement the execute method in a concrete command.
class LightOnCommand implements Command { private Light light; public LightOnCommand(Light light) { this.light = light; } public void [1]() { light.on(); } }
The concrete command implements the execute method to call the receiver's action.
Fix the error in the Invoker class to call the command properly.
class RemoteControl { private Command slot; public void setCommand(Command command) { this.slot = command; } public void buttonWasPressed() { slot.[1](); } }
The Invoker calls the execute method on the command to perform the action.
Fill both blanks to complete the UndoableCommand interface extending Command and adding undo method.
interface UndoableCommand extends Command {
void [1]();
void [2]();
}The UndoableCommand interface extends Command by adding undo method alongside execute.
Fill all three blanks to complete the Client code that creates a command, sets it to the invoker, and triggers execution.
Light light = new Light(); Command lightOn = new LightOnCommand([1]); RemoteControl remote = new RemoteControl(); remote.[2](lightOn); remote.[3]();
The client creates a receiver light, a command with that receiver, sets the command on the invoker, and presses the button to execute.
