HARMAN Interview Question

How do you implement state machine.