-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
71 lines (67 loc) · 1.57 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<iostream>
#include"Design-patterns.h"
using namespace std;
Singleton* Singleton::m_pInstance = nullptr;
Singleton::CGarbo Singleton::Garbo;
int main()
{
#if 0
//데절꿎桿
auto test = []()
{
Singleton* newSingleton = Singleton::GetInstance();
Singleton* newSingleton1 = Singleton::GetInstance();
};
test();
//int a;
//cin >> a;
#elif 0
//묏낍꿎桿
ConcreteFactory<Shoes, NikeShoes>SFactory;
Shoes* s = SFactory.CreateProduct();
s->Show();
ConcreteFactory<Shoes, adidasShoes>AFactory;
s = AFactory.CreateProduct();
s->Show();
ConcreteFactory<Clothes, UniClothes>UFactory;
Clothes* c = UFactory.CreateProduct();
c->Show();
#elif 0
//데절묏낍꿎桿
ProductRegistrar<Shoes, NikeShoes>NRegistrar("nike");
Shoes* s = ProductFactory<Shoes>::Instance().GetProduct("nike");
s->Show();
ProductRegistrar<Shoes, adidasShoes>ARegistrar("adidasShoes");
s = ProductFactory<Shoes>::Instance().GetProduct("adidasShoes");
s->Show();
ProductRegistrar<Clothes, UniClothes>URegistrar("UniClothes");
Clothes* c = ProductFactory<Clothes>::Instance().GetProduct("UniClothes");
c->Show();
#elif 0
//련狂諒꿎桿
Book book;
Apple apple;
ShoppingCart basket;
basket.addProduct(&book);
basket.addProduct(&apple);
Customer customer;
customer.set_name("鬼蠟");
basket.accept(&customer);
Saler saler;
saler.set_name("鬼쟀");
basket.accept(&saler);
#elif 1
//밖뀁諒꿎桿
Cat cat;
AbstractObserver* mouse = new Mouse;
AbstractObserver* dog = new Dog;
cat.attach(mouse);
cat.attach(dog);
cat.cry();
cat.detach(dog);
cat.cry();
cat.detach(mouse);
cat.cry();
#endif // 0
return 0;
}