//-------------------------------------------------------------------------------------------------------------------- // Creates the tasks and starts the game. The game simulates the old telephone message where a message is passed // around the circle. At the end of the game, the original message is compared to the final result to see how much // it changed. In our case, we just print the message as it travels the circle until the game is done. //-------------------------------------------------------------------------------------------------------------------- #include "player.h" #include using namespace std; void uMain::main() { Player *players[5]; // List of players. int i; // Loop index. char message[15] = "abcdefghijkl\0"; // Test message to send around the chain. int numberOfPasses = 0; // Number of times the message is passed. srandom((int) &uThisTask()); // Seed the random number generator. // Start up the players for the game. for ( i = 0; i < 5; i += 1 ) { players[i] = new Player(numberOfPasses, NULL, i); } for ( i = 0; i < 5; i += 1 ) { players[i]->SetPlayer(players[(i+1)%5]); } players[0]->SendMessage(message); // Start off the game. for ( i = 0; i < 5; i += 1) { delete players[i]; } // for cout << "Final message was: '" << message << "'" << endl; } // uMain::main // Local Variables: // compile-command: "u++ -g -o telephone player.C driver.C" // End: