previous | index

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";
}

Here is the extended main procedure:

int main(int argc, char** argv) {

  testMove();
  testGameState();
  testPlayer();
  testStrategy();
  testIntermediateStrategy();
  testAutomatedPlayer();
  testGame();
    
  cout << "All tests succeeded.\n";

  return (EXIT_SUCCESS);
}


previous | index