首页 > 软考
题目内容 (请给出正确答案)
[主观题]

装饰器 (Decorator) 模式用于();外观 (Facade) 模式用于()。 ①将一个对象加以包装以给客户提供

装饰器 (Decorator) 模式用于();外观 (Facade) 模式用于()。 ①将一个对象加以包装以给客户提供其希望的另外一个接口 ②将一个对象加以包装以提供一些额外的行为 ③将一个对象加以包装以控制对这个对象的访问 ④将一系列对象加以包装以简化其接口

A.①B.②C.③D.④A.①B.②C.③D.④

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“装饰器 (Decorator) 模式用于();外观 (Fac…”相关的问题
第1题
图7-6UML类图所描绘的设计模式中的(43)模式。图7-6UML类图所描绘的设计模式中的(43)模式。

A.Iterator(迭代器)

B.Decorator(装饰器)

C.Interpreter(解释器)

D.Adapter(适配器)

点击查看答案
第2题
下列设计模式中,()模式既是类结构型模式,又是对象结构型模式。

A.桥接(Bridge)

B.适配器(Adapter)

C.组成(Composite)

D.装饰器(Decorator)

点击查看答案
第3题
下图所示为(46)设计模式,A.组件(Component)B.适配器(Adapter)C.组合(Composit

下图所示为(46)设计模式,

下图所示为(46)设计模式,A.组件(Component)B.适配器(Adapter)C.组合(Co

A.组件(Component)

B.适配器(Adapter)

C.组合(Composite)

D.装饰器(Decorator)

点击查看答案
第4题
下列设计模式中,()模式既是类结构型樽式,又是对象结构型模式。此模式与()模式类似的特征是,都给
另一个对象提供了一定程度上的间接性,都涉及到从自身以外的一个接口向这个对象转发请求。

A.桥接(Bridge) B.适配器(Adapter) C.组成(Composite) D.装饰器 (Decorator) A.桥接(Bridge) B.适配器(Adapter) C.组成(Composite) D.装饰器 (Decorator)

点击查看答案
第5题
此模式与()模式类似的特征是,都给另一个对象提供了一定程度上的间接性,都涉及到从自身以外的一个接口向这个对象转发请求。

A.桥接(Bridge)

B.适配器(Adapter)

C.组成(Composite)

D.装饰器(Decorator)

点击查看答案
第6题
为图形用户界面(GUI)组件定义不同平台的并行类层次绩构,适合采用()模式。A.享元(Flyweight)B.抽象

为图形用户界面(GUI)组件定义不同平台的并行类层次绩构,适合采用()模式。

A.享元(Flyweight)

B.抽象工厂(Abstract Factory)

C.外观(Facade))

D.装饰器(Decorator)

点击查看答案
第7题
● 设计模式中的(45)模式将对象组合成树形结构以表示“部分-整体”的层次结构,使得客户对单个对象和

● 设计模式中的(45)模式将对象组合成树形结构以表示“部分-整体”的层次结构,使得客户对单个对象和组合对象的使用具有一致性。下图为该模式的类图,其中,(46)定义有子部件的那些部件的行为;组合部件的对象由(47)通过component提供的接口操作。

● 设计模式中的(45)模式将对象组合成树形结构以表示“部分-整体”的层次结构,使得客户对单个对象和

(45)A.代理(Proxy)

B.桥接器(Bridge)

C.组合(Composite)

D.装饰器(Decorator)

(46) A. Client

B. Component

C. Leaf

D. Composite

(47) A. Client

B. Component

C. Leaf

D. Composite

点击查看答案
第8题
● 已知某子系统为外界提供功能服务,但该子系统中存在很多粒度十分小的类,不便被外界系统直接使用
,采用(41)设计模式可以定义一个高层接口,这个接口使得这一子系统更加容易使用;当不能采用生成子类的方法进行扩充时,可采用(42)设计模式动态地给一个对象添加一些额外的职责。

(41)

A. Facade(外观)

B. Singleton(单件)

C. Participant(参与者)

D. Decorator(装饰)

(42)

A. Facade(外观)

B. Singleton(单件)

C. Participant(参与者)

D. Decorator(装饰)

点击查看答案
第9题
试题五(共15分)阅读下列说明和C++-代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明】某发

试题五(共15分)

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

【说明】

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

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

【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!

点击查看答案
第10题
试题六(共15分)阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明】某发

试题六(共15分)

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

【说明】

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

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

【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!

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改