//状态转换 public override void StateCheck() { if (Acc.Balance > 0) { Acc.SetState(new NormalState(this)); } else if (Acc.Balance > -2000) { Acc.SetState(new OverdraftState(this)); } }
//状态转换 public override void StateCheck() { if (Acc.Balance > -2000 && Acc.Balance <= 0) { Acc.SetState(new OverdraftState(this)); } else if (Acc.Balance == -2000) { Acc.SetState(new RestrictedState(this)); } else if (Acc.Balance < -2000) { Console.WriteLine("操作受限!"); } }
public override void StateCheck() { if (Acc.Balance > 0) { Acc.SetState(new NormalState(this)); } else if (Acc.Balance == -2000) { Acc.SetState(new RestrictedState(this)); } else if (Acc.Balance < -2000) { Console.WriteLine("账号受限"); } }