Separate state-related processing from a class into separate classes and program toward the interface. The effect is to simplify the code, avoid too much conditional judgment: if… The else…