首页
登录
从业资格
某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构
某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构
admin
2022-08-02
16
问题
某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。
【C++代码】#includeusing namespace std;class Invoice{public:(1){cout<<"This is the content of the invoice!"<<endl;}};class Decorator:public Invoice{Invoice*ticket;public:Decorator(lnvoice*t){ticket=t;}void printInvoice( ){if(ticket!=NULL)(2);}};class HeadDecorator:public Decorator{public:HeadDecorator(lnvoice*t):Decorator(t){}void printInvoice( ){cout<<"This is the header of the invoice!"<<endl;(3);}};class FootDecorator:public Decorator{public:FootDecorator(Invoice*t):Decorator(t){}void printlnvoice( ){(4);cout<<"This is the footnote of the invoice!"<<endl;}};int main(void){Invoice t;FootDecorator f(&t);HeadDecorator h(&f);h.printInvoice( );cout<<”------------------------”<<endl;FootDecorator a(NULL);HeadDecorator b((5));b.printInvoice( );return 0;}程序的输出结果为:This is the header of the invoice!This is the content of the invoice!This is the footnote of the invoice!----------------------------This is the header of the invoice!This is the footnote of the invoice!
选项
答案
解析
(1)virtual void printInvoice()
(2)ticket->printInvoice()
(3)Decorator::printInvoice()
(4)Decorator::printInvoice()
(5)&a
1.Invoice类下,定义虚函数,按类图,函数名是printInvoice。
2.前面定义对象名是ticket,那么在ticket不为空的时候调用函数printInvoice。
3.这部分填写发票的抬头,看类图应该实现函数printInvoice,Decorator装饰模式使用该方法。
4.这部分是发票的脚注,看类图应该实现函数printInvoice,Decorator装饰模式使用该方法。
5.FootDecorator a(NULL);脚步的装饰参数是a,调用a参数。
转载请注明原文地址:https://tihaiku.com/congyezige/2409837.html
本试题收录于:
中级 软件设计师题库软件水平考试初中高级分类
中级 软件设计师
软件水平考试初中高级
相关试题推荐
某企业信息系统的部分关系模式及属性说明如下: (1)员工关系模式:员工(员工编
某法院要开发一个诉讼案件信息处理系统,该信息系统的部分关系模式如下: 职工(职
某医院管理系统部分关系模式为:科室(科室号,科室名,负责人,电话)、病患(病历号
天津市某银行信息系统的数据库部分关系模式如下所示: 客户(客户号,姓名,性别,
计算机指令一般包括操作码和地址码两部分,为分析执行一条指令,则其( )。A.操
操作系统的功能可分为相互配合、协调工作的5大部分,其中不含()。A.进程管理
某超市销售系统的部分关系模式如下:商品表:Commodity(Ccode,C
某航空公司要开发一个订票信息处理系统,该系统的部分关系模式如下:航班(航班编号,
某工厂的信息管理数据库的部分关系模式如下所示:职工(职工号,姓名,年龄,月工资,
某汽车租赁公司建立汽车租赁管理系统,其数据库的部分关系模式如下:用户:USERS
随机试题
______ofusgetshomefirststartscooking.A、WhoB、WhichC、WhicheverD、AnyoneC
Athirdoftheplanet’slandisseverelydegradedandfertilesoilisbeing
[originaltext]W:Hi,Jack.Howwasthecampinglastweek?M:Oh,itwashorribl
【B1】[br]【B13】A、anybodyB、anotherC、otherD、everybodyB“一个……另一个……”的表达为one...an
在我国,涉及数字出版行政管理的法规主要包括()。A.《出版管理条例》 B.《
某同学用显微镜观察水中微小生物,图1中的箭头表示显微镜视野中微小生物的游走方向,
患者女,50岁。胃大部切除术后2周。患者进食20分钟后出现上腹饱胀、恶心、呕吐、
患者,男性,65岁,3年前起中上腹部隐痛,呈间歇性,通常于饭前或饭后4~5h发生
A.便秘B.脑缺血C.高脂血症D.胆道蛔虫症E.精神分裂症泽泻的现代应用是
位于内踝尖上5寸,胫骨内侧面的中央的是( )。A.蠡沟 B.飞扬 C.地机
最新回复
(
0
)