Section C - Poker
Section C - Poker
`game.h`
```cpp
#ifndef GAME_H
#define GAME_H
#include <string>
#include <vector>
class Game {
public:
static std::string evaluateHand(const std::vector<std::string>& cards);
static std::pair<std::vector<std::string>, std::string> determineWinner(const
std::vector<std::vector<std::string>>& hands);
private:
static bool isRoyalFlush(const std::vector<std::string>& cards);
static bool isStraightFlush(const std::vector<std::string>& cards);
static bool isFourOfAKind(const std::vector<std::string>& cards);
static bool isFullHouse(const std::vector<std::string>& cards);
static bool isFlush(const std::vector<std::string>& cards);
static bool isStraight(const std::vector<std::string>& cards);
static bool isThreeOfAKind(const std::vector<std::string>& cards);
static bool isTwoPair(const std::vector<std::string>& cards);
static bool isPair(const std::vector<std::string>& cards);
#endif // GAME_H
```
`game.cpp`
```cpp
#include "game.h"
#include <algorithm>
std::vector<std::string> Game::RANKS = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
std::vector<std::string> Game::SUITS = {" ♥", "♦", "♣", "♠"};
std::vector<std::pair<std::string, int>> Game::COMBINATIONS = {
{"Royal Flush", 9},
{"Straight Flush", 8},
{"Four of a Kind", 7},
{"Full House", 6},
{"Flush", 5},
{"Straight", 4},
{"Three of a Kind", 3},
{"Two Pair", 2},
{"Pair", 1},
{"High Card", 0}
};
Ce code implémente les mêmes fonctionnalités que le code précédent, mais en utilisant C++ et en séparant le
code dans deux fichiers : `game.h` et `game.cpp`.
La classe `Game` contient les fonctions statiques nécessaires pour évaluer une main de poker et déterminer le
gagnant parmi plusieurs mains. Les fonctions privées `isRoyalFlush()`, `isStraightFlush()`, etc. implémentent
les différentes combinaisons de poker.
Vous pouvez utiliser cette implémentation dans votre système de jeu de poker en C++.