DesignPattern/10.DecoratorPattern/2.Code/main.cpp

46 lines
945 B
C++
Raw Normal View History

2019-10-24 16:02:47 +00:00
#include <iostream>
#include "DecoratorPattern.h"
int main()
{
2020-11-29 05:40:29 +00:00
printf("\nJungle's first phone\n");
2019-10-24 16:02:47 +00:00
Component *c;
Component *com_Shell;
c = new Phone();
com_Shell = new DecoratorShell(c);
com_Shell->operation();
2020-11-29 05:40:29 +00:00
printf("\nJungle's second phone'\n");
2019-10-24 16:02:47 +00:00
Component *c2;
Component *com_Shell2;
c2 = new Phone();
com_Shell2 = new DecoratorShell(c2);
Component *com_Sticker;
com_Sticker = new DecoratorSticker(com_Shell2);
com_Sticker->operation();
2020-11-29 05:40:29 +00:00
printf("\nJungle's third phone'\n");
2019-10-24 16:02:47 +00:00
Component *c3;
Component *com_Shell3;
c3 = new Phone();
com_Shell3 = new DecoratorShell(c3);
Component *com_Sticker2;
com_Sticker2 = new DecoratorSticker(com_Shell3);
Component *com_Rope;
com_Rope = new DecoratorRope(com_Sticker2);
com_Rope->operation();
printf("\n\n");
2020-11-29 05:40:29 +00:00
delete c;
delete com_Shell;
delete c2;
delete com_Shell2;
delete com_Sticker;
delete c3;
delete com_Sticker2;
delete com_Rope;
2019-10-24 16:02:47 +00:00
system("pause");
return 0;
}