previous | index | next

Testing the GameInfo Class

Here is how the client code would look:

void testGame() {
  cout << "Welcome to the Game of Nim.\n\nWhat is your name? ";
  string name = "                    ";
  cin >> name;
  Player player1 = new PlayerInfo(name);
  Player player2 = new AutomatedPlayerInfo("HAL 9000", new IntermediateStrategyInfo);
  GameState initialState = new GameStateInfo(5, 8, 6);
  Game game = new GameInfo(player1, player2, initialState);
  Player winner = game->play();
  cout << winner->getName() << " wins.\n";
}


previous | index | next