Question: a . Write a default constructor that sets state to 1 . b . Write an overloaded constructor to set the value of state from

a. Write a default constructor that sets state to 1.b. Write an overloaded constructor to set the value of state from a parameterc. Write a getter function that returns a description of the state (see comment above)d. Write a member function called string change(). This function willi. take the current value and change it to its next value following the normal pattern of red->green> yellow->red and back again.ii. Return the new state's text description (if the light is red, it returns "red"). Remember the getter function in (c). Example, if state was red, calling the change () function will set state to green and then return the word "green"e. In main,i. create a TrafficLight object with an initial state of redii. Write a loop that will simply repeat 12 times. The loop body will call the object's change() function. This loop will simply be used to see that the change sequence is correct.iii. The output of the loop above should be something like GREEN YELLOW RED GREEN YELLOW RED GREEN YELLOW RED GREEN YELLOW RED
 a. Write a default constructor that sets state to 1.b. Write

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!