Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS A C++ CODE This is a simulation of an Old West Saloon. You will create several classes which show how the various players

THIS IS A C++ CODE

This is a simulation of an Old West Saloon. You will create several classes which show how the various players interact.

A Person class holds the name of a person/character. It has a Play() method which causes the class to execute all the actions required of it every turn. It also has a Drink() method which causes the bartender to pour a drink and the class will drink it. This method has a 10% chance of getting called every turn. Person() is not supposed to be instantiated.

A PokerPlayer class derives virtually from the Person class. The Play() method plays poker by returning a random number in the range 1 .. 52, representing a card value. The highest card value wins.

A Gunslinger class is a child class. It has a Draw() method that returns a type double value representing a gunslingers draw time (from 1 to 10). The class also has an int member representing the number of notches on the gunslingers gun.

A CardSharp() class is also a child class. It has a Draw() method that also returns a draw time, but it is an int ranging from 5 to 15. There is a Play() method which returns a random card, like PokerPlayer(), but part of the time (25%) it will cheat and use a card already used. The Gunslinger() class has a 50% chance of detecting this and shooting the CardSharp(). See the shooting behavior below. Each drink increases the chance of cheating by +5%.

Finally, we have a Bartender() class. The Draw() method for this class will cause it to pour a beer.

Create a saloon where 4 random players are playing poker. If two players shoot each other, the one with the lowest number returned from Draw()wins. Shot players are always killed and replaced with a random player. Every turn display what the various characters are doing while they play poker. The game ends when all the cards are played and the player who has won the most hands is the winner.

Constraints.

Include methods for setting object values.

Overload the insertion operator () to show class details.

Randomly select a name for each character.

Make sure you have 1 of each class playing to start.

Iterate through a dynamic memory structure of classes and callplay()to execute each players actions every turn.

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions