Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1. (Class Card) The class Card should provide: Data members face and suit of type Face and Suit respectively. A constructor that receives a

Problem 1. (Class Card) The class Card should provide:

Data members face and suit of type Face and Suit respectively.

A constructor that receives a Face and Suit argument representing the face and suit of the card and uses them to initialize the data members.

Getter functions for the data members of the class.

Two scoped enumerations with typenames Face and Suit with enumeration constants representing the various suits and faces of each card.

Two static const arrays of std::strings representing the faces and suits. Note: The order of the array elements should match the order of the scoped enumeration constants.

Two static const size t variables representing the total number of faces and suits for a standard set of playing cards.

A toString function that returns the Card as a string in the form face of suit. You can use either the + operator to concatenation the std::strings or the std::ostringstream object for more efficient std::string concatenation.

You may use the following header file as a reference:

#ifndef CARD_H

#define CARD_H

#include

class Card {

public: static const size_t FACES{13}; // total number of faces

static const size_t SUITS{4}; // total number of suits

enum class Face {...}; // Complete this line

enum class Suit {...}; // Complete this line

Card(Face, Suit); // initialize face and suit

std::string toString() const; // returns a string representation of a Card

Face getFace() const { return face; }

Suit getSuit() const { return suit; }

private:

Face face;

Suit suit; static

const std::string faceNames[FACES];

static const std::string suitNames[SUITS]; };

#endif

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

What is the growth rate of GDP per capita?

Answered: 1 week ago