Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that simulates a game of Craps , which is played with two dice. Please split into 3 files : Main.cpp, Craps.cpp,

Write a C++ program that simulates a game of Craps, which is played with two dice. Please split into 3 files: Main.cpp, Craps.cpp, and Craps.h.

Create a class called Die. The class should have one private member called value, (we don't need the member sides - our die will have 6 sides), a constructor, one mutator function (roll to set the value) and one accessor function to return the value. You will use two different die objects to simulate rolling two dice.

On the first roll, the player wins if the sum of the dice is 6 or 7 and they loose if the sum is 2 or 12. Any other sum that is rolled is called the point. On each subsequent roll: the player wins if they roll that sum or point again, and the player loses by rolling either a 6 or 7. Any other roll is ignored and the game continues.

Once the player wins or loses, your program is to ask the player if they wish to play again. If they enter Y or y: play the game again. If they enter N or n, the game ends and your program will print the number of wins and the number of loses. If the user enters any other value, your program is to prompt them again. The game needs to pause after every roll and wait for the user to hit enter to simulate a real game where the player waits while the dice are rolled.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

My opinions/suggestions are valued.

Answered: 1 week ago