-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommandeTourner.cpp
49 lines (39 loc) · 1.14 KB
/
CommandeTourner.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
#include <exception>
#include <string>
using namespace std;
#include "CommandeTourner.h"
#include "Commande.h"
#include "Parser.h"
#include "Robot.h"
map<string, vector<Commande*> > Commande::macroCommandes;
CommandeTourner CommandeTourner::monExemplaire("TOURNER");
CommandeTourner::CommandeTourner(string nom) {
Commande::commandesInscrites()[nom] = this;
}
CommandeTourner::CommandeTourner(string d, bool inscrire) {
if(inscrire){
Commande::commandesInscrites()[d] = this;
}else{
this->_d = d;
}
}
Commande* CommandeTourner::virtualConstructor(Parser* p) {
_d = p->getString();
return new CommandeTourner(_d, false);
}
void CommandeTourner::executer(Robot* r) {
_old_d = r->GetDirection();
_old_p = r->GetPlot();
cout << "EXECUTION DE TOURNER(" << _d << ")" << endl;
r->tourner(_d);
//Commande::commandes_executees.push_back(this);
}
void CommandeTourner::annuler(Robot* r) {
cout << "ANNULATION DE TOURNER(" << _d << ") RETOUR A (" << _old_d << ")" << endl;
r->tourner(_d);
if(_old_p)
r->rencontrerPlot(*_old_p);
}
bool CommandeTourner::estAnnulable() {
return true;
}