< previous page page_564 next page >

Page 564
    // Play a series of games and keep track of who wins

    GetPlays(playForA, playForB, legal);
    while (fileA && fileB)
    {
            // Invariant (prior to test):
            //     gameNumber pairs of input data have been
            //     input and processed

        gameNumber++;
        if (legal)
            ProcessPlays(gameNumber, playForA, playForB, winsForA, 
                         winsForB);
        else
            cout < Game number  < gameNumber
                 <  contained an illegal play. < endl;
        GetPlays(playForA, playForB, legal);
    }
    // Print overall winner

    PrintBigWinner(winsForA, winsForB);

    return 0;
}
//******************************************************************

void GetPlays( /* out */ PlayType& playForA,    // A's play
               /* out */ PlayType& playForB,    // B's play
               /* out */ Boolean&  legal    )   // True if plays
                                                    //   are legal
// Reads the players' plays from the data files, converts the plays
// from char form to PlayType form, and reports whether the plays
// are legal. If end-of-file is encountered on either file, the
// outgoing parameters are undefined. Files fileA and fileB are
// accessed globally

// Precondition:
//     fileA and fileB have been successfully opened
// Postcondition:
//     IF input from either file failed due to end-of-file
//          playForA, playForB, and legal are undefined
//     ELSE

 
< previous page page_564 next page >