-
Notifications
You must be signed in to change notification settings - Fork 0
/
Strategist.cpp
30 lines (28 loc) · 1014 Bytes
/
Strategist.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
#include "Strategist.h"
using namespace std;
void Strategist::strategy(Car* car1, Car* car2, RaceWeekend* race) {
// rather implement using switch
switch(race->getStrategy()) {
case AGGRESSIVE: {
AggressiveStrategy* a = new AggressiveStrategy();
static_cast<BaseCar*>(car1)->setTyres(a->strategy());
static_cast<BaseCar*>(car2)->setTyres(a->strategy());
delete a;
break;
}
case BALANCED: {
BalancedStrategy* b = new BalancedStrategy();
static_cast<BaseCar*>(car1)->setTyres(b->strategy());
static_cast<BaseCar*>(car2)->setTyres(b->strategy());
delete b;
break;
}
case CONSERVATIVE: {
ConservativeStrategy* c = new ConservativeStrategy();
static_cast<BaseCar*>(car1)->setTyres(c->strategy());
static_cast<BaseCar*>(car2)->setTyres(c->strategy());
delete c;
break;
}
}
}