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 "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <string>
#include <windows.h>

class Person
{
private:
std::string firstName;
std::string lastName;
public:
Person(std::string fn, std::string ln); //constructor
void Show();
};

Person::Person(std::string fn, std::string ln) //constructor with 2 arguments, fn - first name, ln - last name. Simply assigns the arguments to attributes
{
firstName = fn;
lastName = ln;
}

void Person::Show() //Print Persons first and last name
{
std::cout << firstName << " " << lastName << std::endl;
}

class PokerPlayer:virtual public Person
{
public:
PokerPlayer(std::string fn, std::string ln):Person(fn, ln) //inherited constructor from Person
{
//There is nothing in the body, as constructor is same as Persons, it is just inherited
};
int Draw(); //Draw method
};...

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

Assisting Tutor

Related Homework Solutions

Software Defects And Human Injuries
Homework Solution
$15.00
Computer Science
Software Defects
Human Injuries
Radiation
Patients
System Runs
Overdosage
US Army
International Airports
Death
Discussion
Software Development
Coding
Software Application Development Scenarios
Homework Solution
$15.00
Computer Science
Software Development
Bank Application
Credit Cards
Repair Shops
Cars
Tokens
Booking
Registration Forms
Payments
Customer Representatives
Finite State Machines Questions
Homework Solution
$45.00
Finite State Machines
Computer Science
Algorithms
Lamps
Buttons
Safe Combinations
Locks
Alarms
Strings
Binary Numbers
Substrings
Functional Requirements
Formalism
Computer Science and Business Questions
Homework Solution
$200.00
Computer Science
Communication Diagram
Business Process
Case Labels
Data Analysis
State Machine
Control Interface
Customers
Tasks
Payments
Car Details
Garage Manager
Boundary Controls
Accuracy
Consistency
Airbnb For The Homeless
Homework Solution
$40.00
Computer Science
Airbnb
Homeless
Accommodation
Booking
Reservations
Experience
Shelter System
Children
Women
Elderly People
Waiting List
Voice Mail
Software Specification
Event Driven System
Rule Drove Subsystem
Payments
Performances
Instruction Set Using Adobe InDesign
Homework Solution
$43.00
Computer Science
Graphic Design
Layout
Screenshots
Textual Instructions
Business
Marketing
Production
Graphic Elements
Colors
Background Information
Sequentially Ordered Steps
Get help from a qualified tutor
Live Chats