initialize repository of design pattern template
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#include "decorate.hpp"
|
||||
|
||||
void Person::wear()
|
||||
{
|
||||
cout << "着装" << endl;
|
||||
}
|
||||
|
||||
string Engineer::getSkill()
|
||||
{
|
||||
return m_Skill;
|
||||
}
|
||||
|
||||
string Teacher::getTitle()
|
||||
{
|
||||
return m_Title;
|
||||
}
|
||||
|
||||
void Teacher::wear()
|
||||
{
|
||||
cout << "我是" << m_Name << m_Title << endl;
|
||||
Person::wear();
|
||||
}
|
||||
|
||||
void Engineer::wear()
|
||||
{
|
||||
cout << "我是" << m_Skill << "工程师 " << m_Name << " " << endl;
|
||||
Person::wear();
|
||||
}
|
||||
|
||||
ClothingDecorator::~ClothingDecorator()
|
||||
{
|
||||
if (m_pPerson != nullptr)
|
||||
{
|
||||
delete m_pPerson;
|
||||
}
|
||||
}
|
||||
|
||||
void ClothingDecorator::wear()
|
||||
{
|
||||
m_pPerson->wear();
|
||||
decorate();
|
||||
}
|
||||
|
||||
void CasualPantDecorator::decorate()
|
||||
{
|
||||
cout << "一件卡其色休闲裤" << endl;
|
||||
}
|
||||
|
||||
void BeltDecorator::decorate()
|
||||
{
|
||||
cout << "一条银色针扣头得黑色腰带" << endl;
|
||||
}
|
||||
|
||||
void LeatherShoesDecorator::decorate()
|
||||
{
|
||||
cout << "一双深色休闲皮鞋" << endl;
|
||||
}
|
||||
|
||||
void KnittedSweaterDecorator::decorate()
|
||||
{
|
||||
cout << "一件紫红色针织毛衣" << endl;
|
||||
}
|
||||
|
||||
void WhiteShirtDecorator::decorate()
|
||||
{
|
||||
cout << "一件白色衬衫" << endl;
|
||||
}
|
||||
|
||||
void GlassesDecorator::decorate()
|
||||
{
|
||||
cout << "一副方形黑框眼镜" << endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user