Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supply use case #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions abstract-factory/AbstractFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ int main()
ProductA *p2 = factoryY->createProductA();
std::cout << "Product: " << p2->getName() << std::endl;

ProductB *p3 = factoryX->createProductB();
std::cout << "Product: " << p3->getName() << std::endl;

ProductB *p4 = factoryY->createProductB();
std::cout << "Product: " << p4->getName() << std::endl;

delete p1;
delete p2;

Expand Down
5 changes: 2 additions & 3 deletions decorator/Decorator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ int main()
{
ConcreteComponent *cc = new ConcreteComponent();
ConcreteDecoratorB *db = new ConcreteDecoratorB( cc );
ConcreteDecoratorA *da = new ConcreteDecoratorA( db );
Component *component = new ConcreteDecoratorA( db );

Component *component = da;
component->operation();

delete da;
delete component;
delete db;
delete cc;

Expand Down
2 changes: 2 additions & 0 deletions flyweight/Flyweight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ int main()
FlyweightFactory *factory = new FlyweightFactory;
factory->getFlyweight(1)->operation();
factory->getFlyweight(2)->operation();
// already exist in pool
factory->getFlyweight(1)->operation();
delete factory;
return 0;
}
10 changes: 8 additions & 2 deletions strategy/Strategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@ class Context

int main()
{
Context context( new ConcreteStrategyA() );
context.contextInterface();
Context context1( new ConcreteStrategyA() );
context1.contextInterface();

Context context2( new ConcreteStrategyB() );
context2.contextInterface();

Context context3( new ConcreteStrategyB() );
context3.contextInterface();

return 0;
}