diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
| commit | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch) | |
| tree | 3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/cpp/exception/main.cc | |
add: graphs et rushs
Diffstat (limited to 'graphs/cpp/exception/main.cc')
| -rw-r--r-- | graphs/cpp/exception/main.cc | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/graphs/cpp/exception/main.cc b/graphs/cpp/exception/main.cc new file mode 100644 index 0000000..7881a4c --- /dev/null +++ b/graphs/cpp/exception/main.cc @@ -0,0 +1,80 @@ +#include <iostream> + +#include "game.hh" +#include "invalid_argument.hh" +#include "player.hh" + +int main() +{ + Game g(42); + std::string n1 = "Toto"; + std::string n2 = "Frodo"; + std::string n3 = "Feanor"; + std::string n4 = "Pikachu"; + std::string n5 = "Baby"; + std::string n6 = ""; + + try + { + Player p1 = Player(n1, 9, 3); + } + catch (InvalidArgumentException& e) + { + std::cout << e.what() << std::endl; + } + try + { + Player p2 = Player(n2, 51, 5); + } + catch (InvalidArgumentException& e) + { + std::cout << e.what() << std::endl; + } + try + { + Player p3 = Player(n3, 3142, 42); + } + catch (InvalidArgumentException& e) + { + std::cout << e.what() << std::endl; + } + try + { + Player p4 = Player(n4, 25, 5000); + } + catch (InvalidArgumentException& e) + { + std::cout << e.what() << std::endl; + } + try + { + Player p5 = Player(n5, -1, 1); + } + catch (InvalidArgumentException& e) + { + std::cout << e.what() << std::endl; + } + try + { + Player p6 = Player(n6, 19, 1); + } + catch (InvalidArgumentException& e) + { + std::cout << e.what() << std::endl; + } + + try + { + Player p1 = Player(n1, 9, 3); + Player p2 = Player(n2, 51, -18); + g.play(p1, p1); + } + catch (InvalidArgumentException& e) + { + std::cout << e.what() << std::endl; + } + + Player p1 = Player(n1, 9, 3); + Player p2 = Player(n2, 51, -18); + g.play(p1, p2); +} |
