// Programmer: Gregory A. Perkins // Class: CS 66 // Due: 3 March 1997 // This program accepts the probability that a player will win a racquetball service // on his/her serve for two players. It then prompts the user to enter the number of // games to play. Upon completion, the program displays the number of games won by // each player and the number of shutouts achieved by each player. // rball2.cc -- structuring racquetball simulation using classes. // by: John Zelle (2/27/97) // Code for SimStat class has been excised. #include#include #include #include "rballgame.h" #include "simstats.h" //====================================> main <================================== void getInputs( float& Aprob, float& Bprob, int& numGames ); void main() { srand(clock()); // seed the random number generator float Aprob, Bprob; int numGames; SimStats stats; getInputs( Aprob, Bprob, numGames); for(int i = 0; i < numGames; i++) { RBallGame theGame(Aprob, Bprob); while ( !theGame.isOver() ) theGame.doRally(); stats.Update(theGame); } stats.PrintSummary(); } //==============================> getInputs <================== void getInputs( float& A, float& B, int& N ) { cout << "Enter A prob: "; cin >> A; cout << "Enter B prob: "; cin >> B; cout << "\nHow many games> "; cin >> N; }