#ifndef GAME_H #define GAME_H /** * Interface for a game instance. This models a game of N players in * a circle. The N players should be identified by values O through N-1. * * Each round of the game results in the removal of one player, based * upon counting K steps around the circle from the spot of the * previously removed player (or 0 if the first round). * * Subclasses should include a constructor with two, non-negative * integer parameters, for specifying N and K, and should leave the * game in its initial state with all players remaining, and player 0 * the next to be 'counted' when a round begins. */ class Game { public: /** * Returns the number of players who currently remaining in the game. */ virtual int size() const =0; /** * Plays a single round, eliminating one player. This method can be * called repeatedly to simulate several consecutive rounds of the * game. * * The ID of the removed player should be returned. */ virtual int playRound() =0; /** * Completes the entire game, from the current state. * (i.e. equivalent to calling playRound repeatedly until size is * one). * * The return value should be the ID of the sole surviving player. */ virtual int completeGame() =0; /** * This method toggles the 'verbose' setting. The return value * indicates the new setting. * * The default behavior should be with verbose set to false, in * which case no output is to be generated by the other methods. * * If verbose is set to true, subsequent steps of the game should * produce a message, printed to the standard output stream, to * document the play of the game. * * This method may be called more than once, if setting changes are * desired while a game is in progress. */ virtual bool toggleVerbose() =0; /** * Virtual Destructor */ virtual ~Game() {}; }; #endif