Write a code for OOP based game in which a player (human) will play against computer, and the player to score 100 points first, will win the game. Follow these steps to complete your code. • Create a class named game, with score as its private data Define a function which will generate random numbers between 1 and 10 and store it to private data of the class and will add it to previous score • Another function will display the scores after each turn and if the score is 100 or more then declare the player (who scored 100 in less attempts) as a winner Create two objects in the main program named as player and computer Player will press a specific key to play in his turn The computer's turn will be executed after the player's turn Keep on doing this until one of them scores 100 points To generate the random numbers the following two lines must be there

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.2: Basic Class Functions
Problem 5E
icon
Related questions
Question
Write a code for OOP based game in which a player (human) will play against computer, and the
player to score 100 points first, will win the game. Follow these steps to complete your code.
Create a class named game, with score as its private data
• Define a function which will generate random numbers between 1 and 10 and store it to
private data of the class and will add it to previous score
• Another function will display the scores after each turn and if the score is 100 or more then
declare the player (who scored 100 in less attempts) as a winner
Create two objects in the main program named as player and computer
• Player will press a specific key to play in his turn
• The computer's turn will be executed after the player's turn
• Keep on doing this until one of them scores 100 points
To generate the random numbers the following two lines must be there
srand (time (0)); // to make sure that different number is generated in each turn
rand ();
// it will generate random numbers
You also need to include cstdlib, time.h and conio.h header file to use rand (), time (0)
and getche () functions.
Transcribed Image Text:Write a code for OOP based game in which a player (human) will play against computer, and the player to score 100 points first, will win the game. Follow these steps to complete your code. Create a class named game, with score as its private data • Define a function which will generate random numbers between 1 and 10 and store it to private data of the class and will add it to previous score • Another function will display the scores after each turn and if the score is 100 or more then declare the player (who scored 100 in less attempts) as a winner Create two objects in the main program named as player and computer • Player will press a specific key to play in his turn • The computer's turn will be executed after the player's turn • Keep on doing this until one of them scores 100 points To generate the random numbers the following two lines must be there srand (time (0)); // to make sure that different number is generated in each turn rand (); // it will generate random numbers You also need to include cstdlib, time.h and conio.h header file to use rand (), time (0) and getche () functions.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr