Flipping Switches

I want to set up a system in which a number of switches have to be activated in a certain order to activate the door. Example – There are five switches in a room, and the player has to flip them in the right order to get access to the next room. Is this possible through an else-if function?

Make a progress variable, and in each point check what is being switched next.

something like:

int progress = 0;
void OnSwitcheSwitched{
        if(progress == 0){
            if(switch1 == true)
                progress++;
            else
                progress = 0;
        }
        if(progress == 1){
            if(switch3 == true)
                progress++;
            else
                progress = 0;
        }
        ...
    }