-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommandeAvancer.cpp
43 lines (34 loc) · 1.03 KB
/
CommandeAvancer.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
#include <exception>
#include <string>
using namespace std;
#include "CommandeAvancer.h"
#include "Commande.h"
#include "Parser.h"
#include "Robot.h"
CommandeAvancer CommandeAvancer::monExemplaire("AVANCER");
CommandeAvancer::CommandeAvancer(string nom) {
Commande::commandesInscrites()[nom] = this;
}
CommandeAvancer::CommandeAvancer(int x, int y) {
this->_x = x;
this->_y = y;
}
Commande* CommandeAvancer::virtualConstructor(Parser* p) {
_x = p->getInt();
_y = p->getInt();
return new CommandeAvancer(_x, _y);
}
void CommandeAvancer::executer(Robot* r) {
_oldX = r->GetPosition().getX();
_oldY = r->GetPosition().getY();
cout << "EXECUTION DE AVANCER " << _x << " ; " << _y << endl;
r->avancer(_x, _y);
//Commande::commandes_executees.push_back(this);
}
void CommandeAvancer::annuler(Robot* r) {
cout << "ANNULATION DE AVANCER(" << _x << ", " << _y << ") RETOUR A (" << _oldX << ", " << _oldY << ")" << endl;
r->avancer(_oldX, _oldY);
}
bool CommandeAvancer::estAnnulable() {
return true;
}