had a hard time trying to figure out how he defined his states.
The code uses an enum (something for you to Google) which is a convenient way to assign a numerical value to a variable without even having to know the value assigned. The values can be used throughout the program by using the descriptive names assigned to them. Out of interest try printing the states to see the values assigned.