一起答

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

如果您发现本试卷没有包含本套题的全部小题,请尝试在页面顶部本站内搜索框搜索相关题目,一般都能找到。
  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;

     }

    }

  2. 阅读以下说明和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;

    }

  3. 阅读以下说明和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;<

  4. 阅读以下说明,回答问题1、问题2和问题3。

      【说明】

     某单位正在使用一套C/S模式的应用软件系统,现在需要升级为B/S应用模式,但需要保持业务的连续性。开发人员提出用Web Service作为中间层的接口进行开发。

     【问题1】

     请用120字以内文字,从业务的继承性、升级成本(时间、工作量)和扩展性三个方面简要说明开发人员所提方案的优点。

     【问题2】

     Web Service的三个基本技术是WSDL、SOAP、UDDI,它们都是以XML为基础定义的。请用120字以内文字,简要说明WSDL、SOAP和UDDI的作用。

     【问题3】

     服务注册中心、服务提供者和服务请求者之间的交互和操作构成了Web Service的体系结构,如图13-21所示。请用180字以内文字,说明这三者的主要功能及其交互过程。

  5. 阅读下列说明和相关的类图,回答问题。

      【说明】

     在一栋m层楼的大厦里,用电梯内和每个楼层的按钮来控制n部电梯的运作。当按下电梯内按钮请求电梯在指定楼层停下时,按钮指示灯亮,当电梯到达指定楼层时,指示灯熄灭。除了大厦的最底层和最高层之外,每层楼都有两个按钮分别指示电梯上行和下行,当这两个按钮之一被按下时相应的指示灯亮,当电梯到达此楼层时灯熄灭,电梯向要求的方向移动。当电梯无升降运动时,关门并停止在当前楼层。

     软件设计师火云龙采用面向对象分析的方法,经过三次逐步求精设计之后,得到如图 13-19所示的类图。

               

     【问题1】

     按钮类有一个重要的属性,请将该属性填入图13-19中的(a)处。

     【问题2】

     识别关联的多重性是面向对象建模重要的一步,请根据题目说明填空(1)~(6)。

     【问题3】

     软件设计师火云龙在初步设计类时,将门(的状态)作为电梯的属性,后经思考,将电梯门设计成一个独立的类,这么做的好处是什么?

     软件设计师火云龙在初步设计类时,并没有设计“请求”类,后来又加入了该类,这么做的原因是什么?

  6. 阅读以下说明和E-R图,回答问题。

      【说明】

     某高校要设计一个教学管理数据库系统。通过调查,设计者了解到学生每学期按照事先安排的课程计划开始学习。每门课程由一名教师讲授;一个教师可以讲授多门课程;每名学生可以选修多门课程;学期结束后通过考试,教师登记每门课程、每名学生的成绩,并得到确认后存档。

    数据库工程师风清扬设计了如图13-20所示的E-R图。

                

     【问题1】

     把该E-R图中的实体和联系转化为相应的关系模式,并指出其主码、候选码以及外码(若无外码也须指出)。

     【问题2】

     现要查询出所有的没有学生选修的课程的全部信息,请写出相应的SQL语句。注意,要查询出符合条件的课程的全部信息。

     【问题3】

     现要查询出所有选修了教师号为'001'的老师所授课程的学生的学号与姓名,请写出相应的SQL语句。

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

      【说明】

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

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

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

                                        

     【问题1】

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

     【问题2】

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

     【问题3】

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

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