Question: I need help starting this assignment: Problem You are the technical director for a small playhouse. You have installed an array of ten (10) overhead
I need help starting this assignment:
Problem
You are the technical director for a small playhouse. You have installed an array of ten (10) overhead lights above your stage. Conveniently, you have labeled the lights from left to right (assuming stage directions), starting with "light 0" and ending with "light 9."
You want to program an on/off-style switch that set these lights to a specific pattern.
Implementation
This on/off switch must follow the behavior specified by the following two functions:
- leftLights() - flips the switch ON and turns on the left half of the stage lights
- rightLights() - flips the switch OFF and turns on the right half of the stage lights
To simulate the behavior of a real-life on/off switch, you'll need a boolean variable, switchState, that keeps track of whether the switch is ON or OFF. Thus, you'll need your leftLights() and rightLights() functions to return a value of the appropriate type.
If the switch is already toggled in a specific direction, you must print out a message in a function indicating that nothing has changed. Example: if you call leftLights() while switchState is already set to its corresponding ON state, then print out the following:
Warning: Switch is already ON, light pattern is unchanged.
You must use only ONE array to represent these stage lights, and it must have an appropriate data type (Hint: you only have two choices of values, on or off).
This array MUST be declared in main().
Results
In main(), call the following functions in this sequence:
- leftLights()
- rightLights()
- rightLights()
Output the light values between each call in this form:
Light [Number]: [ON/OFF] Light [Number]: [ON/OFF] Light [Number]: [ON/OFF]" ...
Recall that boolean values print out as 0 or 1, so you'll have to print some string equivalent similar to the previous lecture.
It may help to create a function to handle this output, but you are not required to do so.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
