2016年下半年软件设计师考试真题之下午题(3)

软件设计师 责任编辑:木木 2016-11-24

添加老师微信

备考咨询

加我微信

摘要:2016年下半年软件设计师考试下午真题第三部分。

       >>>【希赛】2016年下半年软考分数早知道,希赛网解析真题


       软考历年真题是考生备考的法宝,希赛软考网整理了2016年下半年软件设计师考试真题之下午题,供大家参考学习。以下为2016年下半年软件设计师下午真题第三部分。


       试题五(共15分)

       阅读下列说明和C++-代码,将应填入(n)处的字句写在答题纸的对应栏内。

       【说明】

       某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。

5软设.png

       【C++代码】

       #include<iostream>

       using 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 printinvoice0{

       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.printlnvoice();

       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!


       试题六(共15分)

       阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。

       【说明】

       某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。

6软设.png

       【java代码】

       class invoice{

       public void printInvoice(){:

       System.out.println("This is the content of the invoice!");

       }

       }

       class Decorator:extends Invoice{

       protected Invoice ticket;

       public Decorator(lnvoice t){

       ticket=t;

       }

       public void printinvoice(){

       if(ticket!=NULL)

       (1);

       }

       }

       class FootDecorator extends Decorator{

       public FootDecorator(lnvoice t){

       super(t);

       }

       public void printinvoice(){

       Systent.out.println("This is the header of the invoice!");

       (2);

       }

       }

       class FootDecorator extends Decorator{

       public FootDecorator(invoice t):{

       super(t);

       }

       public void printlnvoice(){

       (3);

       Systent.out.println("This is the header of the invoice!");

       }

       }

       Class test{

       public static void main(string[]args){

       Invoice t=new invioce();

       Invoice ticket;

       Ticket=(4);

       Ticket.Printinvoice();

       Systent.out.println(“--------------“)

       Ticket=(5);

       Ticket.Printinvoice();

       }

       }

       程序的输出结果为:

       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!


       >>>返回目录:2016年下半年软件设计师考试真题(下午题)

       >>>2016年下半年软件设计师考试下午真题答案与解析


       相关推荐:

       软件设计师考试历年真题答案与解析

       2017年软件设计师考试辅导教材推荐

       软件设计师考试培训视频教程

更多资料
更多课程
更多真题
温馨提示:因考试政策、内容不断变化与调整,本网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准!

软考备考资料免费领取

去领取

!
咨询在线老师!