Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class Control Panel { private LinkedList onCommands; private LinkedList offCommands; public Control Panel() { onCommands = new LinkedList (); offCommands = new LinkedList (); public

image text in transcribedimage text in transcribedimage text in transcribed

class Control Panel { private LinkedList onCommands; private LinkedList offCommands; public Control Panel() { onCommands = new LinkedList(); offCommands = new LinkedList(); public void addOnCommand (DeviceOnCommand cmd) { onCommands.add (cmd); } public void addoffCommand (DeviceOffCommand cmd) { offCommands.add (cmd); } public void fullonButton() { for (DeviceOnCommand cmd: onCommands) { cmd.execute(); public void fulloffButton() { for (DeviceOffCommand cmd: offCommands) { cmd.execute(); interface Device public void on(); public void off(); 1 class Light implements Device { public void on() { System.out.println("light on"); } public void off () { System.out.println("light off"); } } class IndicatorLight extends Light { public void on() { System.out.println("indicator light on"); 1 public void off () { System.out.println("indicator light off"); class SecurityCamera implements Device { public void on() { System.out.println("security camera on"); } public void off() { System.out.println("security camera off"); class DeviceOnCommand private Device device; public DeviceOnCommand (Device device) { this.device = device; } public void execute() { device.on(); } class DeviceOffCommand { private Device device; public DeviceOffCommand (Device device) { this.device = device; } public void execute() { device.off(); } class Main public static Controlpanel loadtestConfigi() { IndicatorLight indicatorLight = new IndicatorLight(); DeviceOn Command indicatorLightOnCmd = new DeviceOnCommand (indicator Light); DeviceOffCommand indicator LightoffCmd = new DeviceOffCommand (indicatorLight); SecurityCamera securityCamera = new SecurityCamera(); DeviceOnCommand cameraOnCommand = new DeviceOnCommand (securityCamera); DeviceOffCommand cameraoffCommand = new DeviceOffCommand (securityCamera); Control Panel cp = new Control Panel(); cp.addon Command (indicatorLightOnCmd); cp.addOnCommand (cameraOn Command); cp.addoffCommand (indicator LightoffCmd); cp.addoffCommand (cameraOffCommand); return cp; } public static void runControlpanelTest (Controlpanel cp, int times) { for (int i=0; i onCommands; private LinkedList offCommands; public Control Panel() { onCommands = new LinkedList(); offCommands = new LinkedList(); public void addOnCommand (DeviceOnCommand cmd) { onCommands.add (cmd); } public void addoffCommand (DeviceOffCommand cmd) { offCommands.add (cmd); } public void fullonButton() { for (DeviceOnCommand cmd: onCommands) { cmd.execute(); public void fulloffButton() { for (DeviceOffCommand cmd: offCommands) { cmd.execute(); interface Device public void on(); public void off(); 1 class Light implements Device { public void on() { System.out.println("light on"); } public void off () { System.out.println("light off"); } } class IndicatorLight extends Light { public void on() { System.out.println("indicator light on"); 1 public void off () { System.out.println("indicator light off"); class SecurityCamera implements Device { public void on() { System.out.println("security camera on"); } public void off() { System.out.println("security camera off"); class DeviceOnCommand private Device device; public DeviceOnCommand (Device device) { this.device = device; } public void execute() { device.on(); } class DeviceOffCommand { private Device device; public DeviceOffCommand (Device device) { this.device = device; } public void execute() { device.off(); } class Main public static Controlpanel loadtestConfigi() { IndicatorLight indicatorLight = new IndicatorLight(); DeviceOn Command indicatorLightOnCmd = new DeviceOnCommand (indicator Light); DeviceOffCommand indicator LightoffCmd = new DeviceOffCommand (indicatorLight); SecurityCamera securityCamera = new SecurityCamera(); DeviceOnCommand cameraOnCommand = new DeviceOnCommand (securityCamera); DeviceOffCommand cameraoffCommand = new DeviceOffCommand (securityCamera); Control Panel cp = new Control Panel(); cp.addon Command (indicatorLightOnCmd); cp.addOnCommand (cameraOn Command); cp.addoffCommand (indicator LightoffCmd); cp.addoffCommand (cameraOffCommand); return cp; } public static void runControlpanelTest (Controlpanel 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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions