Question

A “Person” class holds the first and last names of a person. In addition to its constructors, it has a Show() method that displays both names.

A “PokerPlayer” class derives virtually from the Person class. You will use “: virtual public” for the inheritance type. It has a Draw() member that returns a random number in the range 1 through 52, representing the card value. The PokerPlayer class uses the Person Show() function.

The “Gunslinger” class derives virtually from the Person class in the same way as PokerPlayer. It has a Draw() member that returns a type double value representing the gunslinger’s draw time. The class also has an int member representing the number of times the gunslinger has won. Finally, it has a Show() member function that displays all of the information.

The “BadDude” class derives publically from the Gunslinger and PokerPlayer classes. It has a Gdraw() member that returns the draw time and a Cdraw() function that returns the next card drawn. It has an appropriate Show() function.

Define all of these classes and methods, along with any other necessary methods (such as methods for setting object values) and test them in a simple program.

To generate random numbers:
#include <stdlib.h>
#include <time.h>
srand(time(NULL));
x=rand() %52 +1;

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include "Gunslinger.h"
#include <iostream>

Gunslinger::Gunslinger()
{
    wins = 0;
}


Gunslinger::~Gunslinger(void)
{
}

double Gunslinger::Draw()
{
    return (rand()%200) / 200.0;
}

void Gunslinger::Show()
{
    std::cout << "Name: " << firstName << " " << lastName << " " << ", Wins: " << wins << std::endl;
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

C: Multiple Programs
Homework Solution
$68.00
C
Computer
Science
Remove
Occurrences
Character
String
Pointer
Functioin
Local
Rmchr
Rmstr
Record
Monitor
Screen
Prime Factors in C++
Homework Solution
$20.00
Programming
Coding
Computer Science
C++
Prime Factors
Integers
Recursive Methods
Input
Output
Multiplication
Division
Shapes Program in C++
Homework Solution
$30.00
Programming
C++
Shapes
Codes
Metric Conversions
Mathematics
Functions
Area
Centimeters
Kilos
Points
Celsius
Fahrenheit
Circle
Square
Rectangle
Display Choices
Radius
Side Lengths
Input
Output
Attributes & Methods in C++
Homework Solution
$10.00
Programming
C++
Computer Science
Attributes
Methods
Students
People
Inheritance
Employees
Salaries
Job Titles
Classes
Statements
Variables
Get help from a qualified tutor
Live Chats