2016年下半年軟件設(shè)計(jì)師考試真題之下午題(3)

軟件設(shè)計(jì)師 責(zé)任編輯:木木 2016-11-24

添加老師微信

備考咨詢

加我微信

摘要:2016年下半年軟件設(shè)計(jì)師考試下午真題第三部分。

       >>>【希賽】2016年下半年軟考分?jǐn)?shù)早知道,希賽網(wǎng)解析真題


       軟考?xì)v年真題是考生備考的法寶,希賽軟考網(wǎng)整理了2016年下半年軟件設(shè)計(jì)師考試真題之下午題,供大家參考學(xué)習(xí)。以下為2016年下半年軟件設(shè)計(jì)師下午真題第三部分。


       試題五(共15分)

       閱讀下列說(shuō)明和C++-代碼,將應(yīng)填入(n)處的字句寫在答題紙的對(duì)應(yīng)欄內(nèi)。

       【說(shuō)明】

       某發(fā)票(lnvoice)由抬頭(Head)部分、正文部分和腳注(Foot)部分構(gòu)成?,F(xiàn)采用裝飾(Decorator)模式實(shí)現(xiàn)打印發(fā)票的功能,得到如圖5-1所示的類圖。

5軟設(shè).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;

       }

       程序的輸出結(jié)果為:

       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分)

       閱讀下列說(shuō)明和Java代碼,將應(yīng)填入(n)處的字句寫在答題紙的對(duì)應(yīng)欄內(nèi)。

       【說(shuō)明】

       某發(fā)票(lnvoice)由抬頭(Head)部分、正文部分和腳注(Foot)部分構(gòu)成。現(xiàn)采用裝飾(Decorator)模式實(shí)現(xiàn)打印發(fā)票的功能,得到如圖6-1所示的類圖。

6軟設(shè).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();

       }

       }

       程序的輸出結(jié)果為:

       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年下半年軟件設(shè)計(jì)師考試真題(下午題)

       >>>2016年下半年軟件設(shè)計(jì)師考試下午真題答案與解析


       相關(guān)推薦:

       軟件設(shè)計(jì)師考試歷年真題答案與解析

       2017年軟件設(shè)計(jì)師考試輔導(dǎo)教材推薦

       軟件設(shè)計(jì)師考試培訓(xùn)視頻教程

更多資料
更多課程
更多真題
溫馨提示:因考試政策、內(nèi)容不斷變化與調(diào)整,本網(wǎng)站提供的以上信息僅供參考,如有異議,請(qǐng)考生以權(quán)威部門公布的內(nèi)容為準(zhǔn)!

軟考備考資料免費(fèi)領(lǐng)取

去領(lǐng)取

!
咨詢?cè)诰€老師!