#include <IOStream.h> //Base Class class Player { public: virtual int getGuess(){ return 0; } } //Human Class to accept the value from human by using getGuess() method class HumanPlayer : public Player { public: int getGuess(){ cout<<"Guess the number" int guess; cin>>guess; return guess; } } // Class to choose the value by Computer by using getGuess() method class ComputerPlayer : public Player { public: int getGuess(){ int guess2=rand()%100; return guess2; } } class GamePlay { bool checkForWin( int guess, int answer ) { cout<< “You guessed ” << guess << “.”; if ( answer == guess ) { cout<< “You’re right! You win!” <<endl; return true; } else if (answer < guess ) cout<< “Your guess is too high.” <<endl; else cout<< “Your guess is too low.” <<endl; return false; } void play( Player &player1, Player &player2 ) { int answer = 0, guess = 0; answer = rand( ) % 100; // requires <cstdlib> bool win = false; while( !win ) { cout<< “Player 1’s turn to guess.” <<endl; guess = player1.getGuess(); win = checkForWin( guess, answer ); if ( win ) return; cout<< “Player 2’s turn to guess.” <<endl; guess = player2.getGuess(); win = checkForWin( guess, answer ); } } char ch; int main() { cout<<"choose 1 :playing game between Human and Computer" cout<<"choose 2 :playing game between computer and Computer" cout<<"choose 3 :playing game between Human and Computer" switch(ch) { case '1' : HumanPlayer player1; ComputerPlayer player2; GamePlay gp; gp.play(player1,player2); break; case '2' : ComputerPlayer player1; ComputerPlayer player2; GamePlay gp; gp.play(player1,player2); break; case '3' : HumanPlayer player1; HumanPlayer player2; GamePlay gp; gp.play(player1,player2); break; default: cout<<"u are not specified the correct option" } }
Standard input is empty
prog.cpp:2:22: error: IOStream.h: No such file or directory prog.cpp:40: error: stray ‘\342’ in program prog.cpp:40: error: stray ‘\200’ in program prog.cpp:40: error: stray ‘\234’ in program prog.cpp:40: error: stray ‘\342’ in program prog.cpp:40: error: stray ‘\200’ in program prog.cpp:40: error: stray ‘\235’ in program prog.cpp:40: error: stray ‘\342’ in program prog.cpp:40: error: stray ‘\200’ in program prog.cpp:40: error: stray ‘\234’ in program prog.cpp:40: error: stray ‘\342’ in program prog.cpp:40: error: stray ‘\200’ in program prog.cpp:40: error: stray ‘\235’ in program prog.cpp:43: error: stray ‘\342’ in program prog.cpp:43: error: stray ‘\200’ in program prog.cpp:43: error: stray ‘\234’ in program prog.cpp:43: error: stray ‘\342’ in program prog.cpp:43: error: stray ‘\200’ in program prog.cpp:43: error: stray ‘\231’ in program prog.cpp:43: error: stray ‘\342’ in program prog.cpp:43: error: stray ‘\200’ in program prog.cpp:43: error: stray ‘\235’ in program prog.cpp:47: error: stray ‘\342’ in program prog.cpp:47: error: stray ‘\200’ in program prog.cpp:47: error: stray ‘\234’ in program prog.cpp:47: error: stray ‘\342’ in program prog.cpp:47: error: stray ‘\200’ in program prog.cpp:47: error: stray ‘\235’ in program prog.cpp:49: error: stray ‘\342’ in program prog.cpp:49: error: stray ‘\200’ in program prog.cpp:49: error: stray ‘\234’ in program prog.cpp:49: error: stray ‘\342’ in program prog.cpp:49: error: stray ‘\200’ in program prog.cpp:49: error: stray ‘\235’ in program prog.cpp:63: error: stray ‘\342’ in program prog.cpp:63: error: stray ‘\200’ in program prog.cpp:63: error: stray ‘\234’ in program prog.cpp:63: error: stray ‘\342’ in program prog.cpp:63: error: stray ‘\200’ in program prog.cpp:63: error: stray ‘\231’ in program prog.cpp:63: error: stray ‘\342’ in program prog.cpp:63: error: stray ‘\200’ in program prog.cpp:63: error: stray ‘\235’ in program prog.cpp:67: error: stray ‘\342’ in program prog.cpp:67: error: stray ‘\200’ in program prog.cpp:67: error: stray ‘\234’ in program prog.cpp:67: error: stray ‘\342’ in program prog.cpp:67: error: stray ‘\200’ in program prog.cpp:67: error: stray ‘\231’ in program prog.cpp:67: error: stray ‘\342’ in program prog.cpp:67: error: stray ‘\200’ in program prog.cpp:67: error: stray ‘\235’ in program prog.cpp: In member function ‘virtual int HumanPlayer::getGuess()’: prog.cpp:17: error: ‘cout’ was not declared in this scope prog.cpp:18: error: expected `;' before ‘int’ prog.cpp:19: error: ‘cin’ was not declared in this scope prog.cpp:19: error: ‘guess’ was not declared in this scope prog.cpp: In member function ‘virtual int ComputerPlayer::getGuess()’: prog.cpp:30: error: ‘rand’ was not declared in this scope prog.cpp: At global scope: prog.cpp:109: error: expected `}' at end of input prog.cpp: In member function ‘bool GamePlay::checkForWin(int, int)’: prog.cpp:40: error: ‘cout’ was not declared in this scope prog.cpp:40: error: ‘You’ was not declared in this scope prog.cpp:40: error: expected `;' before ‘guessed’ prog.cpp:43: error: expected `;' before ‘re’ prog.cpp:47: error: ‘Your’ was not declared in this scope prog.cpp:47: error: expected `;' before ‘guess’ prog.cpp:49: error: ‘Your’ was not declared in this scope prog.cpp:49: error: expected `;' before ‘guess’ prog.cpp: In member function ‘void GamePlay::play(Player&, Player&)’: prog.cpp:58: error: ‘rand’ was not declared in this scope prog.cpp:63: error: ‘cout’ was not declared in this scope prog.cpp:63: error: expected primary-expression before numeric constant prog.cpp:63: error: expected `;' before numeric constant prog.cpp:67: error: expected primary-expression before numeric constant prog.cpp:67: error: expected `;' before numeric constant prog.cpp: In member function ‘int GamePlay::main()’: prog.cpp:78: error: ‘cout’ was not declared in this scope prog.cpp:79: error: expected `;' before ‘cout’ prog.cpp:109: warning: no return statement in function returning non-void prog.cpp: At global scope: prog.cpp:109: error: expected unqualified-id at end of input
Standard output is empty