-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·49 lines (38 loc) · 1.01 KB
/
main.cpp
File metadata and controls
executable file
·49 lines (38 loc) · 1.01 KB
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
#include "goose_adapter.h"
#include "counting_duck_factory.h"
class DuckSimulator
{
public:
void Simulator()
{
CountingDuckFactory countDuckFactory;
Quackable *mallardDuck = countDuckFactory.CreateMallardDuck();
Quackable *redheadDuck = countDuckFactory.CreateRedheadDuck();
Quackable *duckCall = countDuckFactory.CreateDuckCall();
Quackable *rubberDuck = countDuckFactory.CreateRubberDuck();
Goose g;
Quackable *gooseAdapter = new GooseAdapter(&g);
cout << endl << "Duck Simulator: With Abstract Factory" << endl;
Simulator(*mallardDuck);
Simulator(*redheadDuck);
Simulator(*duckCall);
Simulator(*rubberDuck);
Simulator(*gooseAdapter);
cout << "The ducks quacked " << QuackCounter::GetQuacks() << " times" << endl;
delete mallardDuck;
delete redheadDuck;
delete duckCall;
delete rubberDuck;
delete gooseAdapter;
}
void Simulator(Quackable &duck)
{
duck.Quack();
}
};
int main()
{
DuckSimulator ds;
ds.Simulator();
return 0;
}