【说明】 某绘图系统存在point、line、square三种图元,它们具有Sha

题型:问答题

问题:

【说明】
某绘图系统存在point、line、square三种图元,它们具有Shape接口,图元的类图关系如图13-12所示。现要将circle图元加入此绘图系统以实现功能扩充。已知某第三方库已经提供了XCircle类,且完全满足系统新增的Circle图元所需的功能,但XCircle不是由 Shape派生而来的,它提供的接口不能被系统直接使用。代码13-2既使用了XCircle又遵循了Shape规定的接口,既避免了从头开发一个新的Circle类,又可以不修改绘图系统中已经定义的接口。代码13-3根据用户指定的参数生成特定的图元实例,并对之进行显示操作。绘图系统定义的接口与XCircle提供的显示接口及其功能如表13-5所示。
表13-5接口及其功能

Shape XCircle 功能
display() DisplayIt() 显示图元


【代码13-2】
class Circle (1)
private (2) pxc;
public Circle()
pxc=new (3)

public void display()
pxc. (4)
【代码13-3】
public class Factory
public (5) getShape Instance(int tyoe) //生成特定类实例
switch(type)
case 0: return new point();
case 1: return new Rectangle();
case 2: return new line();
case 3: return new Circle();
default: return null


;
public class App
public static viod main(String argv[

)
if(argv. length!=1)
system. out. println("error parameters!");
Return;

int type=(new Integer(argv[0

)). intValue();
Factory factory=new Factory();
shape s;
s=factory. (6) ;
if(s==null)
system.out. println("Error get instance!");
Return;

s.display();
return;

考点:计算机软件水平考试中级软件设计师中级软件设计师下午试题
题型:问答题

工程咨询的特点包括( )。

A.范围的广泛性

B.任务的唯一性

C.产品的非物质性

D.知识的密集性

E.成果的准确性

题型:问答题

井下接地网上任一保护接地点测得的接地电阻值不应超过().

A.1

B.2

C.3

题型:问答题

GTC型钢轨探伤车的车钩中心高为距轨面()。

A、580±10mm

B、680±10mm

C、780±10mm

D、880±10mm

题型:问答题

根据McCabe环路复杂性度量,下面程序图(图5-2)的复杂度是 (41) ,对这个程序进行路径覆盖测试,可得到的基本路径是 (42)
[*]

A.2

B.3

C.4

D.5

题型:问答题

倾斜井巷把钩工必须熟悉所在井巷的基本情况,本岗位的()等安全设施的性能和使用情况。

A、信号装置

B、机器

C、通讯设备

D、防跑车装置

E、跑车防护装置

更多题库