软件水平考试(中级)软件设计师下午(应用技术)试题模拟试卷35

0
收藏   分享
  • 卷面总分:75分
  • 试卷类型:模拟考试
  • 测试费用:免费
  • 答案解析:是
  • 练习次数:47次
  • 作答时间:150分钟
试卷简介
试卷预览
1

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

【说明】

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

【代码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;

 }

}

1

阅读以下说明和C代码(代码13-4),将应填入(n)处的字句写在对应栏内。

【说明】

在一公文处理系统中,开发者定义了一个公文结构OfficeDoc,其中定义了公文应该具有的属性。当公文的内容或状态发生变化时,与之相关联的DocExplorer结构的值都需要发生改变。一个OfficeDoc结构能够关联一组DocExplorer结构。当OfficeDoc结构的内容或状态发生变化时,所有与之相关联的DocExplorer结构都将被更新,这种应用被称为观察者模式。以下代码采用C语言实现,能够正确编译通过。

【代码13-4】

# include<stdio.h>

# define OBS_MAXNUM 20 /*一个OfficeDoc变量最多能够关联的DocExplorer变量的个数*/

typedef void( (1) )(struc OffieeDoc*, struct DoeExplorer*)I;

struct DocExplorer{

 func update;/*DocExplorer结构采用的更新函数*/

 /*其它的结构字段省略*/

 };

struet OffieeDoc{

  (2) myObs[OBS_MAXNUM];

 /*存储所有与OfficeDoc相关联的DocExplorer结构指针*/

 int index;/*与OffieeDoc结构变量相关联的DoeExplorer结构变量的个数*/

};

void attaeh(struct OfficeDoc*doc, struct DocExplorer*ob){

 /*关联Observer结构ob与OffieeDoe结构doe*/

 int loop=0;

 if(doc->index>=OBS_MAXNUM||ob==NULL)return;

 for(loop=0, loop<doc->index; loop++)

 if(doc->myObs[loop]==ob)return;

 doc->myObs[doe->index]=ob;

 doc->index++;

}

void detaeh(struct OfficeDoc*doc, struct DocExplorer*ob){

 /*解除doc结构与ob结构间的关联*/

 int loop;

 if(ob==NULL)return;

 for(loop=0;loop<doc->index; loop++){

   if(doe->myObs[loop]==ob){

    if(loop<=doc->index-2)

     doc->myObs[loop]=doc->myObs[(3)];

    doc->myObs[doc->index-1]=NULL;

    doc->index——;

    breack;

   }

 }

}

void updatel(struct OfficeDoe*doe, struct DoeExplorer *ob){

/*更新ob结构的值,更新代码省略*/

} void update2(struct OffieeDoc*doc,struet DocExplorer *ob){

/*更新ob结构的值,更新代码省略*/

}

void notifyObs(struct OfficeDoc* doc){

 /*当doc结构的值发生变化时,通知与之关联的所有DocExplorer结构变量*/

 int loop;

 for(loop=0; loop<doc->index; loop++){

   (doc->myObs[loop])->update((4));

 }

}

void main(){

 struct OfficeDoc doc; /*定义一了OfficeDoe变量*/

 struct DocExplorer explorer1, explorer2; /*定义两个DocExplorer变量*/

 /*初始化与OfficeDoc变量相关的DocExplorer变量个数为0*/

 doc.index=0;

 explorer1.update=update1; /*设置explorer1变量的更新函数*/

 explorer2. update=update2; /*设置explorer2变量的更新函数*/

 attach(&doc, &explorer1); /*关联explorer1与doc对象*/

 attach(&doc, &explorer2); /*关联explorer2与doc对象*/

 /*其它代码省略*/

  (5); /*通知与OfficeDoe相关的所有DoeExploer变量*/

 return;

}

1

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

【说明】

软件设计师东方飞龙利用UML设计了一个迷你小型复数类,其类图如图13-11所示。 

【代码13-l】

 /*___________________________________*/

 /********* 文件 MiniComplex. h*********/

 /*___________________________________*/

 #include<iostream>

 using namespace std;

 class MiniComplex

 {(1):

   //重载流插入和提取运算符

    (2) ostream & operator <<(ostream & osObject, const MiniComplex & complex)

 { osObject <<"("<<complex. realPart<<"+"<<complex. imagPart <<"I"<<")";

   return osObject;

 }

 friend (3) operator >>(istream & isObject, MiniComplex & complex)

 { char ch;

   isObject >>complex. realPart >>ch>>complex. imagPart >>ch;

   return isObject;

 }

 MiniComplex(double real=0, double imag=0);           //构造函数

 MiniComplex operator+(const MiniComplex & otherComplex)const!  //重载运算符+

 MiniComplex operator--(const MiniComplex & otherComplex)const! //重载运算符-

 MiniComplex operator*(const MiniComplex& othmComplex)const;  //重载运算符*

 MiniComplex operator/(const MiniComplex & otherComplex)const; //重载运算符/

 bool perator==(const MiniComplex &otherComplex)const;     //重载运算符==

 private:

   double realPart;                      //存储实部变量

   double imagPart;                      //存储虚部变量

 };

 /*_______________________________________________________*/

 /* * * * * * * * *文件 MiniComplex. cpp* * * * * * * * * */

 /*_______________________________________________________*/

 # include "MiniComplex.h"

 bool MiniComplex:: perator==(const MiniComplex & otherComplex)const

 { (1);}

 MiniComplex:: MiniComplex(double real, double imag){realPart=real;imagPart=imag!}

 MiniComplex MiniComplex:: operator+(const MiniComplex & otherComplex)const

 { MiniComplex temp;

   temp. realPart=realPart+ otherComplex. realPart;

   temp. imagPart=imagPart+ otherComplex. imagPart;

   return temp;

 }

 MiniComplex MiniComplex::operator--(const MiniComplex & otherComplex)const

 { MiniComplex temp;

   temp.realPart=realPart-otherComplex.realPart;

   temp. imagPart=imagPart-otherCompler.imagPart;

   return temp;

 }

 MiniComplex MiniComplex:: operator*(const MiniComplex& otherComplex)const

 { MiniComplex temp;

   temp.realPart=(realPart* otherComplex.realPart)-(imag-Part* otherComplex.imag-Part);

   temp imagPart=(realPart* otherComplex. imagPart)+(imag-Part *otherComplex.realPart);

   return temp,

 }

 MiniComplex MiniComplex:: operator/(const MiniComplex& otherComplex)eonst

 { MiniComplex temp;

   float tt;

   tt=1/(otherComplex. realPart *otherComplex. realPart+otherComplex. imagPart* other Complex.imagPart);

   temp. realPart=((realPart* otherComplex.realPart)+(imagPart* otherComplex.imagPart))*tt;

   temp. imagPart=((imagPart * otherComplex.realPart)-(realPart* otherComplex.imagPart))*tt;<

1

阅读下列说明和数据流图,回答问题。

  【说明】

 某网络故障诊断系统使用故障代理(agent、SNMP Trap等)来检测各种意外情况,如大幅丢包、路由冲突、广播风暴等。网络管理员可以在安装该系统时配置安全监控程序(如故障代理程序、实时诊断程序、报警器等),也可以在系统运行时修改配置,通过网络状态采集器和故障特征数据库,并通过控制面板上的键盘与系统进行信息交互。

 在安装过程中,系统给每个故障代理赋予一个编号(即ID)和类型,并设置管理员密码以启动和关闭系统,设置故障代理事件发生时应自动拨出的电话号码。当系统检测到一个故障代理事件时,就激活警报,拨出预置的电话号码,并报告位置和检测到的事件的性质等信息。

 该网络故障诊断系统的顶层图如图13-16所示,0层图如图13-17所示,加工4的子图如图13-18所示。

                                    

 【问题1】

 将顶层图中的(1)和(2)空填充完整。

 【问题2】

 0层图中的数据文件“配置信息”是多余的吗?若是,请说明理由;若不是,请指出它会影响。层图中的哪些(哪个)加工(除加工“1系统配置”之外)?

 【问题3】

 指出图13-18所示的加工4的子图中遗漏的数据流。

 注意:书写格式为“缺少从××到××的数据流××”或“××缺少输入(出)数据流××”。若未按格式书写,将被扣分。