Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago