Unverified Commit b96b5fc7 authored by Merwane Bouri's avatar Merwane Bouri
Browse files

Ajout de historyException

parent f4225402
Pipeline #77752 passed with stages
in 17 seconds
...@@ -13,9 +13,20 @@ Cette classe représente un historique de Grids. ...@@ -13,9 +13,20 @@ Cette classe représente un historique de Grids.
#define HISTORY_H #define HISTORY_H
#include "grid.h" #include "grid.h"
#include <string>
#include <deque> #include <deque>
#include <exception>
class HistoryException : public std::exception
{
std::string _msg;
public:
HistoryException(const std::string& msg) : _msg(msg){}
virtual const char* what() const noexcept override
{
return _msg.c_str();
}
};
class History{ class History{
unsigned int nbMax; unsigned int nbMax;
std::deque<Grid> tab; std::deque<Grid> tab;
...@@ -30,7 +41,7 @@ public: ...@@ -30,7 +41,7 @@ public:
{ {
if(tab.size()>0) if(tab.size()>0)
return tab.back(); return tab.back();
throw "wtf dude"; throw HistoryException("La pile est vide. \n");
} }
bool isEmpty() bool isEmpty()
{ {
......
...@@ -33,5 +33,5 @@ Grid History::popGrid(){ ...@@ -33,5 +33,5 @@ Grid History::popGrid(){
tab.pop_back(); tab.pop_back();
return tmp; return tmp;
} }
throw "bad"; throw HistoryException("La pile est vide. \n");
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment