< previous page page_563 next page >

Page 563
typedef int Boolean;
const Boolean TRUE = 1;
const Boolean FALSE = 0;
The preprocessor directive #includebool.h causes these declarations to be inserted into our program.
//******************************************************************
// Game program
// This program simulates the children's game 'rock, paper, and
// scissors.' Each game consists of inputs from two players,
// coming from fileA and fileB. A winner is determined for each
// individual game, and for the games overall
//*****************************************************************
#include <iostream.h>
#include <fstream.h>    // For file I/O
#include bool.h       // For Boolean type

enum PlayType {ROCK, PAPER, SCISSORS};

PlayType ConversionVa1( char );
void GetPlays( PlayType&, PlayType&, Boolean& );
void PrintBigWinner( int, int );
void ProcessPlays( int, PlayType, PlayType, int&, int& );
void RecordAWin( char, int, int& );

ifstream fileA;     // Player A's plays
ifstream fileB;     // Player B's plays

int main()
{
    PlayType playForA;              // Player A's play
    PlayType playForB;              // Player B's play
    int      winsForA = 0;          // Number of games A wins
    int      winsForB = 0;          // Number of games B wins
    int      gameNumber = 0;        // Number of games played
    Boolean legal;                 // True if play is legal

    // Open the input files

    fileA.open(filea.dat);
    fileB.open(fileb.dat);
    if ( !fileA || !fileB )
    {
        cout < ** Can't open input file(s) ** < endl;
        return 1;
     }

 
< previous page page_563 next page >