forked from tyassine/CooCoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemento.cpp
46 lines (38 loc) · 783 Bytes
/
memento.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
#include "memento.h"
#include "pile.h"
#include <iostream>
Gardien::~Gardien()
{
for (int i=0; i<tabPile.size(); i++) delete tabPile[i];
}
void Gardien::addMemento(Pile* aPile)
{
current++;
tabPile[current] = aPile->cloner();
}
Pile* Gardien::undo()
{
if(current > 0)
{
current--;
return tabPile[current]->cloner();
}
return 0; // NULL
// Gérer le cas de pile vide, ce qu'il doit renvoyer!
// C'est la fonction appelante qui devra vérifier si elle n'obtient pas 0!
}
Pile* Gardien::redo()
{
if (tabPile[current+1] != NULL)
{
current++;
return tabPile[current]->cloner();
}
return 0; // Idem qu'au dessus
}
/*
void Gardien::execute(Pile p){
tabPile.append(p.clone);
curPile++;
}
*/