Hy evry one i need your help for a class room project

In my last project I did something like this.

while (state == 0){
//do whatever it takes to make LED off
//check for pressed button, increment state etc
}

while (state ==1){
//do whatever it takes to make LED on
//check for pressed button, increment state etc
} 

while (state ==2){
//do whatever it takes to make LED flash
//check for pressed button, put state back to zero etc
}

But that's mainly because the separate states in my project needed to be loops. I think the flashing state probably would here. All the different ways have their advantages I think.