Ask Question

Simulate a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the light can be on or off. Toggling either switch turns the lamp on or off. Provide member functions.

+1
Answers (1)
  1. 16 March, 18:50
    0
    int switch_1, switch_2;

    int get_first_switch_state ()

    {

    return switch_1;

    }

    int get_second_switch_state ()

    {

    return switch_1;

    }

    int get_lamp_state ()

    {

    if ((get_first_switch_state ())

    if (get_second_switch_state ()) return 1;

    else

    if (! get_second_switch_state ()) return 1;

    return 0;

    }

    void toggle_first_switch ()

    {

    if (get_first_switch_state ()) switch_1=0;

    else switch_1=1;

    }

    void toggle_second_switch ()

    {

    if (get_second_switch_state ()) switch_2=0;

    else switch_2=1;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Simulate a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers