摘要:2016年下半年軟件設(shè)計(jì)師考試下午真題第三部分。
>>>【希賽】2016年下半年軟考分?jǐn)?shù)早知道,希賽網(wǎng)解析真題
軟考?xì)v年真題是考生備考的法寶,希賽軟考網(wǎng)整理了2016年下半年軟件設(shè)計(jì)師考試真題之下午題,供大家參考學(xué)習(xí)。以下為2016年下半年軟件設(shè)計(jì)師下午真題第三部分。
試題五(共15分)
閱讀下列說明和C++-代碼,將應(yīng)填入(n)處的字句寫在答題紙的對應(yīng)欄內(nèi)。
【說明】
某發(fā)票(lnvoice)由抬頭(Head)部分、正文部分和腳注(Foot)部分構(gòu)成。現(xiàn)采用裝飾(Decorator)模式實(shí)現(xiàn)打印發(fā)票的功能,得到如圖5-1所示的類圖。
【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分)
閱讀下列說明和Java代碼,將應(yīng)填入(n)處的字句寫在答題紙的對應(yīng)欄內(nèi)。
【說明】
某發(fā)票(lnvoice)由抬頭(Head)部分、正文部分和腳注(Foot)部分構(gòu)成。現(xiàn)采用裝飾(Decorator)模式實(shí)現(xiàn)打印發(fā)票的功能,得到如圖6-1所示的類圖。
【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)推薦:
軟考備考資料免費(fèi)領(lǐng)取
去領(lǐng)取
共收錄117.93萬道題
已有25.02萬小伙伴參與做題