Exemplo n.º 1
0
Score *Game::play( Player *p ) {
    Score *score = new GameScore( player1(), player2() );

    while( !score->haveAWinner() ) {
      PointScore *pointScore = reinterpret_cast<PointScore *>( p->serveAPoint() );
      score->addScore( pointScore->getWinner() );
      delete pointScore;
    }
    return score;

}
Exemplo n.º 2
0
Score *Game::play( Player *p ) { 
  /****
       Derived function of play from base Competition class. Driver for a match 
       between the two players.
  ****/
  //creates new instance of score (0-0 game)
  Score *score = new GameScore( player1(), player2() );
  int i = 0;
  while( !score->haveAWinner() ) { 
    /****
	 Checks to see if either of the players has won yet. If not, it creates 
	 a new PointScore object and has a player server, which will result 
	 in a point.
     ****/
    PointScore *pointScore; 
    pointScore = reinterpret_cast<PointScore *>( p->serveAPoint() );
    score->addScore( pointScore->getWinner() );
    delete pointScore; //delete the player point
  }
  //returns the score of a game between two players
  return score;
}