Source

Kata Tennis C++ / src / Game.h

Full commit

#ifndef GAME_H_
#define GAME_H_

#include<string>
#include<map>
#include<vector>

class Player;

enum GameState {
	INITIAL = 1,
	DEUCE,
	ADVANTAGE,
	GAME_OVER
};

class Game {
	public:
		Game(Player * player1, Player * player2);
		virtual ~Game();

		void pointTo(Player * player);

		std::string score() const;

		bool gameStateIsGameOver() const;

	private:
		Player * player1;
		Player * player2;
		std::vector<std::string> scores;

		GameState state;

		void updateState();

		bool thereIsDeuce() const;
		bool playersAreTight() const;
		bool isGameOver() const;

		bool gameStateIsDeuce() const;
		bool gameStateIsAdvantage() const;

		Player * whoWon() const;

		std::string victoryMessage() const;
		std::string advantageMessage() const;

		std::string computeScore(Player * player) const;

		Player * getOtherPlayer(Player * player) const;

		bool playerWon(Player * player) const;
};

#endif /* GAME_H_ */