blob: 1c8002a0b706e41ea9787063df14e8446aef0494 (
plain) (
blame)
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
|
#ifndef GAME_H
#define GAME_H
#include <stdexcept>
#include <string>
#include <tuple>
#include <vector>
template<const char* keyword, typename CharT, typename Traits>
std::basic_istream<CharT, Traits>& skip(std::basic_istream<CharT, Traits>& stream)
{
std::string word;
stream >> word;
if (word != keyword)
{
throw std::invalid_argument("Malformed input");
}
return stream;
}
class Game
{
int id_;
std::vector<std::vector<int>> draws{};
static constexpr char game_t[] = "Game";
public:
Game(int id);
inline int id() const
{
return id_;
}
bool is_valid(int blue, int red, int green) const;
int power() const;
void push_back(const std::vector<int>& draw);
std::string to_string() const;
static Game from_string(const std::string& line);
};
#endif //GAME_H
|