Conditions with switch case

Found most of the code and modified.
I've tried several ways to get it to work but I think the problem I am having is reading that specific variable and storing it's state.
I've tried creating variables within the class as well as in the loop, I've use if/else within and outside the class.