c++ example: [State machine]: use hash map design