Finite State Machine Using Switch Statement.

if(state=="try"){ //do actions here }
if(state=="it"){ // ....}

basically it be done like that.