Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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() { System.out.println("light on"); } public void off() { System.out.println("light off"); } class LightOnCommand { Light light; public LightOnCommand (Light light) { this.light = light; } public void execute() { light.on(); } } class LightOffCommand { Light light; public LightOffCommand (Light light) { this.light = light; } public void execute() { light.off(); class Maint public static Controlpanel loadRoomLightingConfigl () { Light roomLight = new Light(); LightOnCommand roomLightOnCmd = new LightOnCommand (roomLight); LightOffCommand roomLightOffCmd = new LightoffCommand (roomLight); Control Panel cp = new Control Panel (roomLightOnCmd, roomLightOffCmd); return cp; ) public static void runControl PanelTest (Control Panel cp, int times) { for (int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started