#include
閱讀下列說明和 C++代碼,填補(bǔ)代碼中的空缺,將解答填入答題紙的對(duì)應(yīng)欄內(nèi)。深夜成人在线,chinese国产一区二区,欧美精品乱码,日韩欧美在线视频免费观看,国产午夜不卡,日韩av影院在线,五月天婷婷国产精品
【說明】
以下 C++代碼實(shí)現(xiàn)一個(gè)簡(jiǎn)單客戶關(guān)系管理系統(tǒng)(CrM)中通過工廠(Customerfactory)對(duì)象來創(chuàng)建客戶(Customer)對(duì)象的功能??蛻舴譃閯?chuàng)建成功的客戶(realCustomer)和空客戶(NullCustomer)。空客戶對(duì)象是當(dāng)不滿足特定條件時(shí)創(chuàng)建或獲取的對(duì)象。類間關(guān)系如圖6-1 所示。
【C++代碼】
#include<iostream>
#include<string>
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<<Customer1->getName()<<endl; delete customer1;
cout<<Customer2->getName()<<endl; delete customer2;
cout<<Customer3->getName()<<endl; delete customer3;
cout<<Customer4->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
*/
相關(guān)試題
更多試題
10年專注信管,信管教育專注者,信管網(wǎng)優(yōu)勢(shì)
免費(fèi)試聽信管網(wǎng)信息系統(tǒng)項(xiàng)目管理師課程
全國(guó)前50名高分學(xué)員訪談:董麗(174)、李思...
信息系統(tǒng)項(xiàng)目管理師高端班培訓(xùn)課程
信管老師100小時(shí)直播課程
軟考報(bào)名專題(報(bào)名時(shí)間、入口等)
中級(jí)系統(tǒng)集成項(xiàng)目管理工程師通關(guān)課程
系統(tǒng)規(guī)劃與管理師課程(考試介紹與題型分析)
軟題庫(kù):軟考在線題庫(kù)、支持手機(jī)答題