Blackjack
Loading...
Searching...
No Matches
Enumerations | Functions
suit.h File Reference

Defines CardSuit. More...

#include <cstddef>
#include <iostream>

Go to the source code of this file.

Enumerations

enum class  CardSuit {
  club , diamond , heart , spade ,
  max_suits
}
 The suit of a card. More...
 

Functions

char getName (const CardSuit)
 Get the string representation of a card's suit.
 
CardSuit getSuit (std::size_t suit)
 Given a suit, return its corresponding suit enum.
 
int getValue (const CardSuit)
 Get the numeric value of a card's suit.
 
std::size_t getNumSuits ()
 Get the max number of suits a deck of cards can have.
 
std::ostream & operator<< (std::ostream &out, const CardSuit &suit)
 Overloads << to print the suit of a card.
 

Detailed Description

Defines CardSuit.

Author
DSN
Version
0.1
Date
2023-08-19

Enumeration Type Documentation

◆ CardSuit

enum class CardSuit
strong

The suit of a card.

Enumerator
club 
diamond 
heart 
spade 
max_suits 

Function Documentation

◆ getName()

char getName ( const CardSuit  suit)

Get the string representation of a card's suit.

Returns
char
  • The string representations of the club, diamond, heart, and spade suits are 'C', 'D', 'H', and 'S', respectively.
  • For an invalid suit, ? is returned.

◆ getSuit()

CardSuit getSuit ( std::size_t  suit)

Given a suit, return its corresponding suit enum.

Parameters
suit
Returns
CardSuit

Type-cast suit to CardSuit

◆ getValue()

int getValue ( const CardSuit  suit)

Get the numeric value of a card's suit.

Returns
int

suit is an enumeration; so, it's type-casted to an int

◆ getNumSuits()

std::size_t getNumSuits ( )

Get the max number of suits a deck of cards can have.

Returns
std::size_t

max_suits is an enumeration; so, it's type-casted to std::size_t

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const CardSuit suit 
)

Overloads << to print the suit of a card.

Parameters
out
suit
Returns
std::ostream&