Question: Assume we are developing an application that enables a user to control lights and other electronics. We are exploring possible architectures with code samples
Assume we are developing an application that enables a user to control lights and other electronics. We are exploring possible architectures with code samples like the following. class Control Panel { LightOnCommand lightOnCmd; LightOffCommand lightOffCmd; public Control Panel (LightOnCommand lightOnCmd, LightOffCommand lightOffCmd) { this.lightOnCmd=lightOnCmd; this.lightOffCmd = lightOffCmd; } public void onButton Pushed () { lightOnCmd.execute(); } public void offButton Pushed () { lightOffCmd. execute(); class Light { public void on () { } public void off () { } System.out.println("light on"); class LightOnCommand { Light light; } public LightOnCommand (Light light) { this.light = light; System.out.println ("light off"); } public void execute() { light.on(); class LightOffCommand { Light light; } public LightOffCommand (Light light) { this.light = light; public void execute() { light.off (); class Main { public static Control Panel loadRoomLightingConfigl () { Light roomLight = new Light (); } } public static void runControl PanelTest (Control Panel cp, int times) { for (int i-0; i
Step by Step Solution
3.37 Rating (147 Votes )
There are 3 Steps involved in it
The code sample provided is an example of a simple architecture for controlling lights and other ele... View full answer
Get step-by-step solutions from verified subject matter experts
