summaryrefslogtreecommitdiff
path: root/graphs/cpp/exception/main.cc
blob: 7881a4c66a0be251ec7155d6e4fae97d497f46a4 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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);
}