导航
您当前的位置:首页 > 计算机 > 软件水平
问题:

[问答题] 欲开发一个绘图软件,要求使用不同的绘图程序绘制不同的图形。以绘制直线和圆形为例,对应的绘图程序如表5-1所示。表5-1不同的绘图程序中级软件设计师,历年真题,2013年下半年(下午)《软件设计师》真题该绘图软件的扩展性要求,将不断扩充新的图形和新的绘图程序。为了避免出现类爆炸的情况,现采用桥接(Bridge)模式来实现上述要求,得到如图5-1所示的类图。中级软件设计师,历年真题,2013年下半年(下午)《软件设计师》真题图5-1类图【C++代码】class?DP1{public:static void draw_a_line(double?x1,double?y1,double?x2,double?y2){/*代码省略*/}static void draw_a_circle(double?x,double?y,double?r){/*代码省略*/}};class?DP2{public:static void drawline(double x1,double x2,double y1,double y2){/*代码省略*/}static void drawcircle(double x,double y,double r){/*代码省略*/}};class?Drawing{public:(1);(2);};class V1Drawing:public Drawing{public:void drawLine(double?x1,double?y1,double?x2,double?y2){/*代码省略*/}void drawCircle(double?x,double?y,double?r){(3);}};class V2Drawing:public?Drawing{public:void drawLine(double?x1,double?y1,double?x2,double?y2){/*代码省略*/}void drawCircle(double?x,double y,double?r){(4);}};class Shape{public:(5);Shape(Drawing*dp){_dp=dp;}void drawLine(double?x1,double?y1,double?x2,double y2){_dp->drawLine(x1,y1,x2,y2);}void drawCircle(double?x,double?y,double r){_dp->drawCircle(x,y,r);}private:Drawing*_dp;};class?Rectangle:public?Shape{public:void draw(  ){/*代码省略*/}//其余代码省略};class Circle:public Shape{private:double_x,_y,_r;public:Circle(Drawing*dp,double x,double?y,double r):(6){_x=x;_y=y;_r=r;}void draw(  ){drawCircle(_x,_y,_r);}};
答案解析:

相关问题
关于我们 | 用户指南 | 版权声明 | 给我留言 | 联系我们 | 积分商城 | 答案求助 | 网站地图
Copyright © 2024 www.daanwo.com All Rights Reserved