软题库 移动APP 扫码下载APP 随时随地移动学习 培训课程
当前位置:信管网 >> 在线考试中心 >> 信息系统项目管理师题库 >> 试题查看
试卷年份2017年上半年
试题题型【分析简答题】
试题内容

阅读下列说明和C++代码,填补代码中的空缺,将解答填入答题纸的对应栏内。
【说明】
以下C++代码实现一个简单客户关系管理系统(CrM)中通过工厂(Customerfactory)对象来创建客户(Customer)对象的功能。客户分为创建成功的客户(realCustomer)和空客户(NullCustomer)。空客户对象是当不满足特定条件时创建或获取的对象。类间关系如图6-1所示。

 
图6-1
【C++代码】
#include
#include
using namespace std;
 
class Customer{
protected:
     string name;
public:
   (   1   ) boll isNil()=0;
   (   2   ) string getName()=0;
﹜;
 
class RealCustomer (   3   ){
Public:
     realCustomer(string name){this->name=name;﹜
     bool isNil(){ return false;  ﹜  
     string getName(){ return name;  ﹜
﹜;
class NullCustomer (    4   ) {
public:
     bool isNil(){  return true; ﹜
     string getName(){ return 〝Not Available in Customer Database〞; ﹜
﹜;
 
class Customerfactory{
public:
    string names[3]={〝rob〞, 〝Joe〞,〝Julie〞﹜;
public:
Customer*getCustomer(string name){
   for (int i=0;i<3;i++){
       if (names[i].(   5   ) ){
           return new realCustomer(name);
      ﹜
    ﹜
     return (   6   );
  ﹜
﹜;
 
class CRM{
public:
    void getCustomer(){
         Customerfactory*(   7   );
         Customer*customer1=cf->getCustomer(〝Rob〞);
Customer*customer2=cf->getCustomer(〝Bob〞);
Customer*customer3=cf->getCustomer(〝Julie〞);
Customer*customer4=cf->getCustomer(〝Laura〞);
 
cout<<〝Customers〞<<endl;
 cout<getName()<<endl;  delete customer1;
 cout<getName()<<endl;  delete customer2;
 cout<getName()<<endl;  delete customer3;
 cout<getName()<<endl;  delete customer4;
 delete cf;
         ﹜
     ﹜;
 int main(){
      CRM*crs=new CRM();
      crs->getCustomer();
      delete crs;
      return 0;

 
/*程序输出为:
Customers
rob
Not Available in Customer Database
Julie
Not Available in Customer Database
*/</endl;  delete customer4;
</endl;  delete customer3;
</endl;  delete customer2;
</endl;  delete customer1;
</endl;


相关试题

推荐文章
合作网站内容