摘要:2016年下半年软件设计师考试下午真题第三部分。
>>>【希赛】2016年下半年软考分数早知道,希赛网解析真题
软考历年真题是考生备考的法宝,希赛软考网整理了2016年下半年软件设计师考试真题之下午题,供大家参考学习。以下为2016年下半年软件设计师下午真题第三部分。
试题五(共15分)
阅读下列说明和C++-代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图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;
}
程序的输出结果为:
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所示的类图。
【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年下半年软件设计师考试真题(下午题)
相关推荐:
软考备考资料免费领取
去领取