基本概念

【设计模式12】外观模式_#include

具体案例

【设计模式12】外观模式_#include_02

//#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

// 外观模式股票代码
//股票1
class Stack1
{
public:
	Stack1();
	~Stack1();
	void Sell() {
		cout << "股票1抛出" << endl;
	}
	void Buy() {
		cout << "股票1买入" << endl;
	}

private:

};

//股票2
class Stack2
{
public:
	Stack2();
	~Stack2();
	void Sell() {
		cout << "股票2抛出" << endl;
	}
	void Buy() {
		cout << "股票2买入" << endl;
	}

private:

};

//国债1
class NationalDebtl
{
public:
	NationalDebtl();
	~NationalDebtl();

	void Sell() {
		cout << "国债1抛出" << endl;
	}
	void Buy() {
		cout << "国债1买入" << endl;
	}
private:

};

//国债 2
class NationalDebt2
{
public:
	NationalDebt2();
	~NationalDebt2();
	void Sell() {
		cout << "国债2抛出" << endl;
	}
	void Buy() {
		cout << "国债2买入" << endl;
	}

private:

};

//房地产
class Relty
{
public:
	Relty();
	~Relty();
	void Sell() {
		cout << "房地产2抛出" << endl;
	}
	void Buy() {
		cout << "房地产2买入" << endl;
	}

private:

};

//基金类
class Fundional
{
public:
	Fundional() {
		by1 = new Stack1;
		by2 = new Stack2;
		by3 = new NationalDebtl;
		by4 = new NationalDebt2;
		by5 = new Relty;
	}
	~Fundional();
	void BuyFundional() {
		by1->Buy();
		by2->Buy();
		by3->Buy();
		by4->Buy();
		by5->Buy();
	}
	void SellFundional() {
		by1->Sell();
		by2->Sell();
		by3->Sell();
		by4->Sell();
		by5->Sell();
	}
private:
	Stack1* by1;
	Stack2* by2;
	NationalDebtl* by3;
	NationalDebt2* by4;
	Relty* by5;
};

Fundional::~Fundional()
{
}

Relty::Relty()
{
}

Relty::~Relty()
{
}

NationalDebt2::NationalDebt2()
{
}

NationalDebt2::~NationalDebt2()
{
}

NationalDebtl::NationalDebtl()
{
}

NationalDebtl::~NationalDebtl()
{
}

Stack2::Stack2()
{
}

Stack2::~Stack2()
{
}


Stack1::Stack1()
{
}

Stack1::~Stack1()
{
}


int main(int argc, char** argv)
{

	Fundional *myFund = new Fundional();
	myFund->BuyFundional();
	myFund->SellFundional();

	delete myFund;
	return 0;
}