Blackjack
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Player Class Referenceabstract

A player is defined by the score that he earns through his chances, in which he can either hit or stand. More...

#include <player.h>

Inheritance diagram for Player:
Dealer User

Public Member Functions

 Player ()
 
 Player (std::string_view name, const int playerLimit)
 
virtual ~Player ()=default
 
std::string_view getName () const
 Get the player's name.
 
int getScore () const
 Get the player's score.
 
bool isBusted () const
 Return if a player is busted.
 
bool isStand () const
 Return if a player STANDS.
 
void setOutcome (Outcome outcome)
 Set the player's outcome upon finishing the game.
 
Outcome getOutcome () const
 Get the outcome of the player's game.
 
void reset ()
 Reset the scores and status of the players (to play another game)
 
virtual void chance (Deck &deck)=0
 Defines the chance of a player.
 
virtual void hit (Deck &deck)=0
 Defines the actions performed when a player HITS (as opposed to STANDS).
 

Protected Attributes

std::string_view m_name {}
 
const int m_limit {}
 
int m_score {}
 
bool m_stand {}
 
bool m_busted {}
 
Outcome m_outcome {}
 

Detailed Description

A player is defined by the score that he earns through his chances, in which he can either hit or stand.

Constructor & Destructor Documentation

◆ Player() [1/2]

Player::Player ( )
inline

◆ Player() [2/2]

Player::Player ( std::string_view  name,
const int  playerLimit 
)
inline

◆ ~Player()

virtual Player::~Player ( )
virtualdefault

Member Function Documentation

◆ getName()

std::string_view Player::getName ( ) const
inline

Get the player's name.

Returns
std::string_view

◆ getScore()

int Player::getScore ( ) const
inline

Get the player's score.

Returns
int

◆ isBusted()

bool Player::isBusted ( ) const
inline

Return if a player is busted.

Returns
true : if the player's score has crossed the given limit
false : the player isn't busted yet

◆ isStand()

bool Player::isStand ( ) const
inline

Return if a player STANDS.

Returns
true : if the players STANDS
false : the player HITS

◆ setOutcome()

void Player::setOutcome ( Outcome  outcome)
inline

Set the player's outcome upon finishing the game.

Parameters
outcome

◆ getOutcome()

Outcome Player::getOutcome ( ) const
inline

Get the outcome of the player's game.

Returns
Outcome

◆ reset()

void Player::reset ( )
inline

Reset the scores and status of the players (to play another game)

◆ chance()

virtual void Player::chance ( Deck deck)
pure virtual

Defines the chance of a player.

Parameters
deck

Implemented in Dealer, and User.

◆ hit()

virtual void Player::hit ( Deck deck)
pure virtual

Defines the actions performed when a player HITS (as opposed to STANDS).

Parameters
deck

Implemented in Dealer, and User.

Member Data Documentation

◆ m_name

std::string_view Player::m_name {}
protected

◆ m_limit

const int Player::m_limit {}
protected

◆ m_score

int Player::m_score {}
protected

◆ m_stand

bool Player::m_stand {}
protected

◆ m_busted

bool Player::m_busted {}
protected

◆ m_outcome

Outcome Player::m_outcome {}
protected

The documentation for this class was generated from the following file: