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

C++ Implementation 10/11

main.cc

#include "Board.h"
#include "Player.h"

void play()
{
  Board c_4; // The playing board
  Player contestant[NO_OF_PLAYERS]; // No of players
  BoardState state = PLAY; // Contestants can Play
  int no = 0; // First contestand

  c_4.display(); // display the board
  while (state == PLAY)
  {
    int move = contestant[no].get_move(TRUE);
    while(c_4.move_ok_for_column(move) == FALSE)
    {
      move = contestant[no].get_move(FALSE);
    }
    c_4.drop_in_column(move, contestant[no].get_counter());

    c_4.display();
    state = c_4.situation();
    if (state == PLAY)
      no = (no+1)%NO_OF_PLAYERS;
    else 
      contestant[no].announce(state); // The result
  }
}

main()
{
  Counter::prelude();
  play();
}


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

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