I have rewriiten FSM class, changed the code style and done some modification:

a) changed the class name
b) changed the variable name to fit the c++ code style
c) put some variable prosperity to private,because it's better not set variable to public