软件设计模式课件 Lect6-State-Behavioral-更新版-5.pptVIP

  • 3
  • 0
  • 约1.33万字
  • 约 43页
  • 2020-11-10 发布于四川
  • 举报

软件设计模式课件 Lect6-State-Behavioral-更新版-5.ppt

State transaction diagram NoTransactionFeeState TransactionFeeState OverDrawnState balance = 2000 -1000 balance 0 transaction fee ($5) 0 balance 2000 transaction fee ($2) withdraw withdraw deposit deposit deposit withdraw Design Example Using the State Pattern 限制:在以上任何状态下,都不允许超过透支上限(-1000)的交易发生。 The banking system is designed as below See next page Design Example Using the State Pattern 保持BankContext类 的引用. 该对象由setContext方法传入 保持一个State类的一个引用objState,维护banlance与state State #context: BankContext #changeState():void +passStateObjToContext():void +getAcctNum():String +getState():String +setCo

文档评论(0)

1亿VIP精品文档

相关文档