TOP

状态模式的应用(二)
2019-09-03 03:33:39 】 浏览:32
Tags:状态 模式 应用

tch to pause", 1); } public function resume($context){ throw new Exception("The state is no service ,can not switch to resume", 1); } public function over($context){ $context->agreement->overDate = date(); $context->state = new AgreementOverState(); } } class AgreementServiceState extends AgreementState { public function start($context){ throw new Exception("...", 1); } public function pause($context){ if($context->agreement->begin_time >= time() && $context->agreement->begin_time<=time()){ $context->agreement->stopDate = date(); $context->state = new AgreementPauseState(); } } public function resume($context){ throw new Exception("...", 1); } public function over($context){ $context->agreement->overDate = date(); $context->state = new AgreementOverState(); } } class AgreementPauseState extends AgreementState { .... public function resume($context){ $context->agreement->resumeDate = date(); $context->state = new AgreementServiceState(); } public function over($context){ $context->agreement->overDate = date(); $context->state = new AgreementOverState(); } .... } class AgreementOverState extends AgreementState { ... }

  


状态模式的应用(二) https://www.cppentry.com/bencandy.php?fid=97&id=249226

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇说说设计模式~观察者模式(Observe.. 下一篇设计模式(七)原型模式(创建型)