next up previous
Next: C++ Implementation 9/11 Up: Von C++ zu Java Previous: C++ Implementation 7/11

C++ Implementation 8/11

Player.cc

#include "Player.h"

Player::Player()
{
  the_players_counter = Counter(SELECT_REPRESENTATION);
}

int Player::get_move(const Boolean first) const
{
  int move;
  if (first != TRUE)
    cout << "Error Invalid choice" << "\n";
  cout << "Move for player ";
  cout << the_players_counter.colour() << " is ";
  cin >> move;
  return move-1;
}

Counter Player::get_counter(void) const
{
  return the_players_counter;
}

void Player::announce(const BoardState what) const
{
  cout << "Player " << the_players_counter.colour();
  switch(what)
  {
  case WIN:
    cout << " wins\n";
    break;
  case DRAW:
    cout << " has filled the board\n";
    break;
  }
}


next up previous
Next: C++ Implementation 9/11 Up: Von C++ zu Java Previous: C++ Implementation 7/11

© 1997 Gottfried Rudorfer, C++-AG, Lehrveranstaltungen, Abteilung für Angewandte Informatik, Wirtschaftsuniversität Wien, 3/19/1998