阅读下列说明和C++代码,将应填入(n)处的字句写在答题纸的对应栏内。 说明:某大型商场内安装了多个简易的纸巾售卖机,自动售出2元钱一包的纸巾,且每次仅售出一包纸巾。纸巾售卖机的状态如图10.35所示。采用状态(State)模式来实现该纸巾售卖机,得到如图10.36所示的类图。其中类State为抽象类,定义了投币、退币、出纸巾等方法接口。类SoldState、SoldOutState、NoQuarterState和HasQuarterState分别对应图10.35中纸巾售卖机的4种状态:售出纸巾、纸巾售完、没有投币、有2元钱。 C++代码如下:
正确答案:
(1)State
(2)tissueMachine->getHasQuarterState()或newHasQuarterState()
(3)tissueMachine->getNoQuarterState()或newNoQuarterState()
(4)tissueMachine->getNoQuarterState()或newNoQuarterState()
(5)tissueMachine->getSoldOutState()或newSoldOutState()
(2)tissueMachine->getHasQuarterState()或newHasQuarterState()
(3)tissueMachine->getNoQuarterState()或newNoQuarterState()
(4)tissueMachine->getNoQuarterState()或newNoQuarterState()
(5)tissueMachine->getSoldOutState()或newSoldOutState()
答案解析:有
微信扫一扫手机做题