forked from jaredtao/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
36 lines (36 loc) · 804 Bytes
/
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
#include "Player.h"
#include "ProbStrategy.h"
#include "WinningStrategy.h"
#include <iostream>
#include <memory>
#include <string>
int main()
{
std::shared_ptr<IStrategy> s1(new WinningStrategy);
std::shared_ptr<IStrategy> s2(new ProbStrategy);
Player p1("SmallTao", s1.get());
Player p2("BigTao", s2.get());
for (int i = 0; i < 100000; ++i)
{
Hand h1 = p1.nextHand();
Hand h2 = p2.nextHand();
if (h1 == h2)
{
p1.even();
p2.even();
}
else if (h1 > h2)
{
p1.win();
p2.lose();
}
else
{
p1.lose();
p2.win();
}
}
std::cout << p1.getString() << std::endl;
std::cout << p2.getString() << std::endl;
return 0;
}